diff --git a/ARCHITECTURE.adoc b/ARCHITECTURE.adoc new file mode 100644 index 00000000..1c0a7a69 --- /dev/null +++ b/ARCHITECTURE.adoc @@ -0,0 +1,48 @@ +== 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/ARCHITECTURE.md b/ARCHITECTURE.md deleted file mode 100644 index 607e3d8c..00000000 --- a/ARCHITECTURE.md +++ /dev/null @@ -1,47 +0,0 @@ -# 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/CHANGELOG.adoc b/CHANGELOG.adoc new file mode 100644 index 00000000..36ac9063 --- /dev/null +++ b/CHANGELOG.adoc @@ -0,0 +1,13 @@ +== Changelog + +=== [0.1.0] - 2026-03-03 + +7495dd0 Rescue 7 plugins from hyperpolymath-archive before deletion +d079f00 Auto-commit: Sync changes [2026-02-24] d89d653 chore(deps): bump +bytes (#1) a5077bd Auto-commit: Sync changes [2026-02-21] 45655f8 +Auto-commit: Sync changes [2026-02-15] 235711e feat: add Justfile and +TOPOLOGY.md (RSR compliance) 85407d7 chore: remove sync reports, KDE +metadata, update .gitignore 004089a fix: apply safety triangle fixes +(recipe-remove-believe-me,recipe-shell-quote-vars) dd4064c feat: add RSR +template structure and project metadata 22bc61c feat: create +asdf-tool-plugins monorepo diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 01cd1a0c..00000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,13 +0,0 @@ -# Changelog - -## [0.1.0] - 2026-03-03 -7495dd0 Rescue 7 plugins from hyperpolymath-archive before deletion -d079f00 Auto-commit: Sync changes [2026-02-24] -d89d653 chore(deps): bump bytes (#1) -a5077bd Auto-commit: Sync changes [2026-02-21] -45655f8 Auto-commit: Sync changes [2026-02-15] -235711e feat: add Justfile and TOPOLOGY.md (RSR compliance) -85407d7 chore: remove sync reports, KDE metadata, update .gitignore -004089a fix: apply safety triangle fixes (recipe-remove-believe-me,recipe-shell-quote-vars) -dd4064c feat: add RSR template structure and project metadata -22bc61c feat: create asdf-tool-plugins monorepo diff --git a/CODE_OF_CONDUCT.adoc b/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..09633991 --- /dev/null +++ b/CODE_OF_CONDUCT.adoc @@ -0,0 +1,339 @@ +== Code of Conduct + +=== Our Pledge + +We as members, contributors, and leaders pledge to make participation in +asdf-tool-plugins a harassment-free experience for everyone, regardless +of age, body size, visible or invisible disability, ethnicity, sex +characteristics, gender identity and expression, level of experience, +education, socio-economic status, nationality, personal appearance, +race, caste, colour, religion, or sexual identity and orientation. + +We pledge to act and interact in ways that contribute to an open, +welcoming, diverse, inclusive, and healthy community. + +We recognise that a thriving open source community requires +*psychological safety* — an environment where people can contribute, ask +questions, make mistakes, and learn without fear of ridicule or +retaliation. + +''''' + +=== Our Standards + +==== Expected Behaviour + +The following behaviours contribute to a positive environment: + +*Communication* - Using welcoming and inclusive language - Being +respectful of differing viewpoints and experiences - Giving and +gracefully accepting constructive feedback - Assuming good intent while +addressing impact - Communicating clearly and patiently, especially with +newcomers + +*Collaboration* - Focusing on what is best for the community - Showing +empathy and kindness toward other community members - Being +collaborative rather than competitive - Mentoring and supporting less +experienced contributors - Celebrating others’ contributions and +successes + +*Professionalism* - Accepting responsibility and apologising to those +affected by our mistakes - Learning from the experience and avoiding +repetition - Respecting others’ time and attention - Staying on topic in +project spaces - Following project guidelines and conventions + +*Accessibility* - Using plain language and avoiding unnecessary jargon - +Providing alt text for images and transcripts for audio/video - Being +patient with those using assistive technologies - Accommodating +different communication styles and needs - Recognising that not everyone +communicates the same way + +==== Unacceptable Behaviour + +The following behaviours are considered harassment and are unacceptable: + +*Harassment* - The use of sexualised language or imagery, and sexual +attention or advances of any kind - Trolling, insulting or derogatory +comments, and personal or political attacks - Public or private +harassment - Deliberate intimidation, stalking, or following (online or +in-person) - Unwelcome physical contact or simulated physical contact +(e.g., emoji) - Sustained disruption of talks, events, or online +discussions + +*Discrimination* - Discriminatory jokes and language - Posting or +threatening to post others’ personally identifying information +("`doxing`") - Advocating for, or encouraging, any of the above +behaviour - Microaggressions — subtle, often unintentional, +discriminatory comments or actions + +*Professional Misconduct* - Publishing others’ private information +without explicit permission - Misrepresenting affiliation or +contributions - Plagiarism or claiming credit for others’ work - +Retaliating against anyone who reports a Code of Conduct violation - +Other conduct which could reasonably be considered inappropriate in a +professional setting + +==== Grey Areas + +Some situations require judgement. When uncertain: + +* *Intent vs Impact*: Good intentions do not excuse harmful impact. +Focus on making things right. +* *Power Dynamics*: Those with more power (maintainers, employers, +experienced contributors) must be especially mindful of their impact. +* *Cultural Differences*: What’s acceptable varies by culture. When in +doubt, err on the side of caution and ask. +* *Humour*: Jokes at others’ expense are rarely funny to everyone. Punch +up, not down. + +''''' + +=== Scope + +This Code of Conduct applies within all community spaces, including: + +*Online Spaces* - Repository discussions, issues, and pull/merge +requests - Project chat channels (Matrix, Discord, Slack, IRC) - Mailing +lists and forums - Social media when representing the project - Video +calls and virtual meetings + +*In-Person Spaces* - Conferences, meetups, and events - Workshops and +training sessions - Any gathering where you represent the project + +*Representation* This Code of Conduct also applies when an individual is +officially representing the community in public spaces. Examples +include: + +* Using an official project email address +* Posting via an official social media account +* Acting as an appointed representative at an event +* Speaking on behalf of the project + +''''' + +=== Enforcement + +==== Reporting + +If you experience or witness unacceptable behaviour, or have any other +concerns, please report it as soon as possible. + +*How to Report* + +[width="99%",cols="30%,33%,37%",options="header",] +|=== +|Method |Details |Best For +|*Email* |j.d.a.jewell@open.ac.uk |Detailed reports, sensitive matters + +|*Private Message* |Contact any maintainer directly |Quick questions, +minor issues + +|*Anonymous Form* |[Link to form if available] |When you need anonymity +|=== + +*What to Include* + +* Your contact information (unless anonymous) +* Names/usernames of those involved +* Description of what happened +* When and where it occurred +* Any witnesses +* Any supporting evidence (screenshots, links) +* How you would like us to respond (if you have a preference) + +*What Happens Next* + +[arabic] +. You will receive acknowledgment within *48 hours* +. The Maintainer Team will review the report +. We may ask for additional information +. We will determine appropriate action +. We will inform you of the outcome (respecting others’ privacy) + +==== Confidentiality + +All reports will be handled with discretion: + +* Reporter identity is protected by default +* Details are shared only with those who need to know +* We will ask before naming you in any communication +* Anonymous reports are accepted and investigated + +==== Conflicts of Interest + +If a Maintainer Team member is involved in an incident: + +* They will recuse themselves from the process +* Another maintainer or external party will handle the report +* We will disclose any potential conflicts + +''''' + +=== Enforcement Guidelines + +The Maintainer Team will follow these guidelines in determining +consequences: + +==== 1. Correction + +*Community Impact*: Use of inappropriate language or other behaviour +deemed unprofessional or unwelcome. + +*Consequence*: A private, written warning providing clarity around the +nature of the violation and an explanation of why the behaviour was +inappropriate. A public apology may be requested. + +*Duration*: Immediate + +==== 2. Warning + +*Community Impact*: A violation through a single incident or series of +actions. + +*Consequence*: A warning with consequences for continued behaviour. No +interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, for a specified period. This +includes avoiding interactions in community spaces as well as external +channels like social media. Violating these terms may lead to a +temporary or permanent ban. + +*Duration*: 1-4 weeks + +==== 3. Temporary Ban + +*Community Impact*: A serious violation of community standards, +including sustained inappropriate behaviour. + +*Consequence*: A temporary ban from any sort of interaction or public +communication with the community for a specified period. No public or +private interaction with the people involved, including unsolicited +interaction with those enforcing the Code of Conduct, is allowed during +this period. Violating these terms may lead to a permanent ban. + +*Duration*: 1-6 months + +==== 4. Permanent Ban + +*Community Impact*: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behaviour, harassment of an +individual, or aggression toward or disparagement of classes of +individuals. + +*Consequence*: A permanent ban from any sort of public interaction +within the community. + +*Duration*: Permanent (with appeal rights after 12 months) + +==== Enforcement Across Perimeters + +For contributors with elevated access (Perimeter 2 or 1): + +[cols=",",options="header",] +|=== +|Level |Additional Consequence +|Correction |Noted in contributor record +|Warning |Access privileges may be temporarily reduced +|Temporary Ban |Access reduced to Perimeter 3 for ban duration +|Permanent Ban |All access revoked +|=== + +''''' + +=== Appeals + +If you believe an enforcement decision was made in error: + +[arabic] +. *Wait 7 days* after the decision (cooling-off period) +. *Email* j.d.a.jewell@open.ac.uk with subject line "`Appeal: [Original +Report ID]`" +. *Explain* why you believe the decision should be reconsidered +. *Provide* any new information not previously available + +*Appeals Process* + +* Appeals are reviewed by a different Maintainer Team member than the +original +* You will receive a response within 14 days +* The appeals decision is final +* You may only appeal once per incident + +*Grounds for Appeal* + +* Procedural errors in the original investigation +* New evidence not previously available +* Disproportionate response to the violation +* Misunderstanding of facts + +''''' + +=== Supporting Those Who Report + +We are committed to supporting those who report violations: + +*We Will* - Believe and take all reports seriously - Respect your +privacy and confidentiality preferences - Keep you informed of progress +(if you wish) - Take steps to protect you from retaliation - Provide +resources if you need support + +*We Will Not* - Require you to confront the person directly - Dismiss +reports without investigation - Reveal your identity without consent - +Tolerate retaliation against reporters - Rush you to make decisions + +''''' + +=== Prevention + +Beyond enforcement, we actively work to prevent issues: + +*Onboarding* - All contributors are expected to read this Code of +Conduct - Perimeter 2 applicants must confirm they’ve read and +understood it - Maintainers receive additional training on enforcement + +*Culture* - We model the behaviour we expect - We intervene early when +we see potential issues - We thank people for positive contributions - +We create opportunities for diverse voices + +*Review* - This Code of Conduct is reviewed annually - Community +feedback is welcomed - Changes are communicated clearly + +''''' + +=== Acknowledgments + +This Code of Conduct is adapted from: + +* https://www.contributor-covenant.org/[Contributor Covenant], version +2.1 +* https://www.djangoproject.com/conduct/[Django Code of Conduct] +* https://www.rust-lang.org/policies/code-of-conduct[Rust Code of +Conduct] +* https://www.python.org/psf/conduct/[Python Community Code of Conduct] + +We thank these communities for their leadership in creating welcoming +spaces. + +''''' + +=== Questions? + +If you have questions about this Code of Conduct: + +* Open a +https://github.com/hyperpolymath/asdf-tool-plugins/discussions[Discussion] +(for general questions) +* Email j.d.a.jewell@open.ac.uk (for private questions) +* Contact any maintainer directly + +''''' + +=== Summary + +*Be kind. Be respectful. Be collaborative.* + +We’re all here because we care about this project. Let’s make it a place +where everyone can do their best work. + +''''' + +Last updated: 2026 · Based on Contributor Covenant 2.1 diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md deleted file mode 100644 index 4bf44675..00000000 --- a/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,327 +0,0 @@ -# Code of Conduct - - - -## Our Pledge - -We as members, contributors, and leaders pledge to make participation in asdf-tool-plugins a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, colour, religion, or sexual identity and orientation. - -We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. - -We recognise that a thriving open source community requires **psychological safety** — an environment where people can contribute, ask questions, make mistakes, and learn without fear of ridicule or retaliation. - ---- - -## Our Standards - -### Expected Behaviour - -The following behaviours contribute to a positive environment: - -**Communication** -- Using welcoming and inclusive language -- Being respectful of differing viewpoints and experiences -- Giving and gracefully accepting constructive feedback -- Assuming good intent while addressing impact -- Communicating clearly and patiently, especially with newcomers - -**Collaboration** -- Focusing on what is best for the community -- Showing empathy and kindness toward other community members -- Being collaborative rather than competitive -- Mentoring and supporting less experienced contributors -- Celebrating others' contributions and successes - -**Professionalism** -- Accepting responsibility and apologising to those affected by our mistakes -- Learning from the experience and avoiding repetition -- Respecting others' time and attention -- Staying on topic in project spaces -- Following project guidelines and conventions - -**Accessibility** -- Using plain language and avoiding unnecessary jargon -- Providing alt text for images and transcripts for audio/video -- Being patient with those using assistive technologies -- Accommodating different communication styles and needs -- Recognising that not everyone communicates the same way - -### Unacceptable Behaviour - -The following behaviours are considered harassment and are unacceptable: - -**Harassment** -- The use of sexualised language or imagery, and sexual attention or advances of any kind -- Trolling, insulting or derogatory comments, and personal or political attacks -- Public or private harassment -- Deliberate intimidation, stalking, or following (online or in-person) -- Unwelcome physical contact or simulated physical contact (e.g., emoji) -- Sustained disruption of talks, events, or online discussions - -**Discrimination** -- Discriminatory jokes and language -- Posting or threatening to post others' personally identifying information ("doxing") -- Advocating for, or encouraging, any of the above behaviour -- Microaggressions — subtle, often unintentional, discriminatory comments or actions - -**Professional Misconduct** -- Publishing others' private information without explicit permission -- Misrepresenting affiliation or contributions -- Plagiarism or claiming credit for others' work -- Retaliating against anyone who reports a Code of Conduct violation -- Other conduct which could reasonably be considered inappropriate in a professional setting - -### Grey Areas - -Some situations require judgement. When uncertain: - -- **Intent vs Impact**: Good intentions do not excuse harmful impact. Focus on making things right. -- **Power Dynamics**: Those with more power (maintainers, employers, experienced contributors) must be especially mindful of their impact. -- **Cultural Differences**: What's acceptable varies by culture. When in doubt, err on the side of caution and ask. -- **Humour**: Jokes at others' expense are rarely funny to everyone. Punch up, not down. - ---- - -## Scope - -This Code of Conduct applies within all community spaces, including: - -**Online Spaces** -- Repository discussions, issues, and pull/merge requests -- Project chat channels (Matrix, Discord, Slack, IRC) -- Mailing lists and forums -- Social media when representing the project -- Video calls and virtual meetings - -**In-Person Spaces** -- Conferences, meetups, and events -- Workshops and training sessions -- Any gathering where you represent the project - -**Representation** -This Code of Conduct also applies when an individual is officially representing the community in public spaces. Examples include: - -- Using an official project email address -- Posting via an official social media account -- Acting as an appointed representative at an event -- Speaking on behalf of the project - ---- - -## Enforcement - -### Reporting - -If you experience or witness unacceptable behaviour, or have any other concerns, please report it as soon as possible. - -**How to Report** - -| Method | Details | Best For | -|--------|---------|----------| -| **Email** | j.d.a.jewell@open.ac.uk | Detailed reports, sensitive matters | -| **Private Message** | Contact any maintainer directly | Quick questions, minor issues | -| **Anonymous Form** | [Link to form if available] | When you need anonymity | - -**What to Include** - -- Your contact information (unless anonymous) -- Names/usernames of those involved -- Description of what happened -- When and where it occurred -- Any witnesses -- Any supporting evidence (screenshots, links) -- How you would like us to respond (if you have a preference) - -**What Happens Next** - -1. You will receive acknowledgment within **48 hours** -2. The Maintainer Team will review the report -3. We may ask for additional information -4. We will determine appropriate action -5. We will inform you of the outcome (respecting others' privacy) - -### Confidentiality - -All reports will be handled with discretion: - -- Reporter identity is protected by default -- Details are shared only with those who need to know -- We will ask before naming you in any communication -- Anonymous reports are accepted and investigated - -### Conflicts of Interest - -If a Maintainer Team member is involved in an incident: - -- They will recuse themselves from the process -- Another maintainer or external party will handle the report -- We will disclose any potential conflicts - ---- - -## Enforcement Guidelines - -The Maintainer Team will follow these guidelines in determining consequences: - -### 1. Correction - -**Community Impact**: Use of inappropriate language or other behaviour deemed unprofessional or unwelcome. - -**Consequence**: A private, written warning providing clarity around the nature of the violation and an explanation of why the behaviour was inappropriate. A public apology may be requested. - -**Duration**: Immediate - -### 2. Warning - -**Community Impact**: A violation through a single incident or series of actions. - -**Consequence**: A warning with consequences for continued behaviour. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. - -**Duration**: 1-4 weeks - -### 3. Temporary Ban - -**Community Impact**: A serious violation of community standards, including sustained inappropriate behaviour. - -**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. - -**Duration**: 1-6 months - -### 4. Permanent Ban - -**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behaviour, harassment of an individual, or aggression toward or disparagement of classes of individuals. - -**Consequence**: A permanent ban from any sort of public interaction within the community. - -**Duration**: Permanent (with appeal rights after 12 months) - -### Enforcement Across Perimeters - -For contributors with elevated access (Perimeter 2 or 1): - -| Level | Additional Consequence | -|-------|----------------------| -| Correction | Noted in contributor record | -| Warning | Access privileges may be temporarily reduced | -| Temporary Ban | Access reduced to Perimeter 3 for ban duration | -| Permanent Ban | All access revoked | - ---- - -## Appeals - -If you believe an enforcement decision was made in error: - -1. **Wait 7 days** after the decision (cooling-off period) -2. **Email** j.d.a.jewell@open.ac.uk with subject line "Appeal: [Original Report ID]" -3. **Explain** why you believe the decision should be reconsidered -4. **Provide** any new information not previously available - -**Appeals Process** - -- Appeals are reviewed by a different Maintainer Team member than the original -- You will receive a response within 14 days -- The appeals decision is final -- You may only appeal once per incident - -**Grounds for Appeal** - -- Procedural errors in the original investigation -- New evidence not previously available -- Disproportionate response to the violation -- Misunderstanding of facts - ---- - -## Supporting Those Who Report - -We are committed to supporting those who report violations: - -**We Will** -- Believe and take all reports seriously -- Respect your privacy and confidentiality preferences -- Keep you informed of progress (if you wish) -- Take steps to protect you from retaliation -- Provide resources if you need support - -**We Will Not** -- Require you to confront the person directly -- Dismiss reports without investigation -- Reveal your identity without consent -- Tolerate retaliation against reporters -- Rush you to make decisions - ---- - -## Prevention - -Beyond enforcement, we actively work to prevent issues: - -**Onboarding** -- All contributors are expected to read this Code of Conduct -- Perimeter 2 applicants must confirm they've read and understood it -- Maintainers receive additional training on enforcement - -**Culture** -- We model the behaviour we expect -- We intervene early when we see potential issues -- We thank people for positive contributions -- We create opportunities for diverse voices - -**Review** -- This Code of Conduct is reviewed annually -- Community feedback is welcomed -- Changes are communicated clearly - ---- - -## Acknowledgments - -This Code of Conduct is adapted from: - -- [Contributor Covenant](https://www.contributor-covenant.org/), version 2.1 -- [Django Code of Conduct](https://www.djangoproject.com/conduct/) -- [Rust Code of Conduct](https://www.rust-lang.org/policies/code-of-conduct) -- [Python Community Code of Conduct](https://www.python.org/psf/conduct/) - -We thank these communities for their leadership in creating welcoming spaces. - ---- - -## Questions? - -If you have questions about this Code of Conduct: - -- Open a [Discussion](https://github.com/hyperpolymath/asdf-tool-plugins/discussions) (for general questions) -- Email j.d.a.jewell@open.ac.uk (for private questions) -- Contact any maintainer directly - ---- - -## Summary - -**Be kind. Be respectful. Be collaborative.** - -We're all here because we care about this project. Let's make it a place where everyone can do their best work. - ---- - -Last updated: 2026 · Based on Contributor Covenant 2.1 diff --git a/CONTRIBUTING.adoc b/CONTRIBUTING.adoc new file mode 100644 index 00000000..084ee525 --- /dev/null +++ b/CONTRIBUTING.adoc @@ -0,0 +1,109 @@ +== Clone the repository + +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins + +== Using Guix (recommended for reproducibility) + +guix develop + +== Or using toolbox/distrobox + +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually + +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/GOVERNANCE.adoc b/GOVERNANCE.adoc new file mode 100644 index 00000000..9b836fb2 --- /dev/null +++ b/GOVERNANCE.adoc @@ -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/GOVERNANCE.md b/GOVERNANCE.md deleted file mode 100644 index e27364c7..00000000 --- a/GOVERNANCE.md +++ /dev/null @@ -1,60 +0,0 @@ -# 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/REQUIRES_INITIALISATION.adoc b/REQUIRES_INITIALISATION.adoc new file mode 100644 index 00000000..2b5a9ea8 --- /dev/null +++ b/REQUIRES_INITIALISATION.adoc @@ -0,0 +1,220 @@ +== REQUIRES INITIALISATION + +*This repository is not finished being set up.* 19 substitution token(s) +across 15 file(s) still have no value. + +=== Why this is not already done + +This repo was created from `+hyperpolymath/rsr-template-repo+`. The mint +(`+just repo-init+`) fills every token that has a single mechanical +answer — owner, repo, author, dates, licence, branch — and it has done +so here. + +The tokens below are the ones it _deliberately cannot_ answer. They need +a decision or a fact that exists only in your head: what this project is +for, what command builds it, which port the service listens on, whether +a PGP key is held at all. The template’s own token vocabulary says as +much — you cannot sensibly answer "`required invariants`" in a +thirty-second bootstrap. + +They were left *visibly unfilled on purpose*. The alternatives were both +worse: inventing plausible values would put confident falsehoods into a +security policy and an architecture document, and silently deleting the +sections would hide the fact that a decision is owed. A visible gap is +honest; a fabricated answer is not. + +=== Do not delete this file until every item below is resolved + +This file is the only marker that the work is outstanding. Deleting it +early does not finish the setup, it just conceals it — and the next +person or agent to arrive will reasonably assume the repo is complete. + +* *If you are a person:* delete this file yourself once the last item is +done. +* *If you are an agent:* resolve what you legitimately can, leave the +rest, and delete this file only when no token below remains anywhere in +the tree. Do not delete it to make a gate go green. + +Re-running the estate top-up tool will remove this file automatically +once nothing is outstanding, so the safest way to finish is to fix the +tokens and let the check confirm it. + +=== What is needed, and where it goes + +==== `+{{CONDUCT_TEAM}}+` + +Name of the conduct body. If there is no committee, rewrite the sentence +rather than substituting a plural noun into '`a \{\{CONDUCT_TEAM}} +member`'. + +Appears in: + +* `+asdf-augmenters/CODE_OF_CONDUCT.md+` +* `+asdf-augmenters/asdf-plugin-collection/plugins/nickel/CODE_OF_CONDUCT (1).md+` +* `+asdf-nickel-plugin/CODE_OF_CONDUCT (1).md+` +* `+asdf-plugin-collection/plugins/nickel/CODE_OF_CONDUCT (1).md+` + +==== `+{{CONSUMER1}}+` + +A downstream repo that consumes this one. + +Appears in: + +* `+.machine_readable/INTENT.contractile+` + +==== `+{{CONSUMER2}}+` + +A second downstream consumer. + +Appears in: + +* `+.machine_readable/INTENT.contractile+` + +==== `+{{DEP1}}+` + +First named dependency, in .machine_readable/INTENT.contractile. + +Appears in: + +* `+.machine_readable/INTENT.contractile+` + +==== `+{{DEP2}}+` + +Second named dependency, in .machine_readable/INTENT.contractile. + +Appears in: + +* `+.machine_readable/INTENT.contractile+` + +==== `+{{FILE}}+` + +Appears in: + +* `+asdf-augmenters/asdf-ghjk/Justfile+` +* `+asdf-ghjk/Justfile+` + +==== `+{{MESSAGE}}+` + +Appears in: + +* `+asdf-augmenters/asdf-ghjk/Justfile+` +* `+asdf-ghjk/Justfile+` + +==== `+{{MONOREPO_OR_STANDALONE}}+` + +Literally '`monorepo`' or '`standalone`'. + +Appears in: + +* `+.machine_readable/INTENT.contractile+` + +==== `+{{NAME}}+` + +Appears in: + +* `+asdf-augmenters/asdf-ghjk/Justfile+` +* `+asdf-ghjk/Justfile+` + +==== `+{{ONE_PARAGRAPH_ANTI_PURPOSE}}+` + +A paragraph on what this deliberately is NOT for. + +Appears in: + +* `+.machine_readable/INTENT.contractile+` + +==== `+{{ONE_PARAGRAPH_PURPOSE}}+` + +A paragraph on what this is for. + +Appears in: + +* `+.machine_readable/INTENT.contractile+` + +==== `+{{PGP_FINGERPRINT}}+` + +Full fingerprint of the security-contact PGP key. NOTE: no key is +published anywhere in this estate — if none is held, delete the PGP +block rather than inventing one. + +Appears in: + +* `+asdf-augmenters/asdf-plugin-collection/plugins/nickel/SECURITY (1).md+` +* `+asdf-nickel-plugin/SECURITY (1).md+` +* `+asdf-plugin-collection/plugins/nickel/SECURITY (1).md+` + +==== `+{{PGP_KEY_URL}}+` + +Public URL the PGP key can be fetched from. Same caveat as +PGP_FINGERPRINT. + +Appears in: + +* `+asdf-augmenters/asdf-plugin-collection/plugins/nickel/SECURITY (1).md+` +* `+asdf-nickel-plugin/SECURITY (1).md+` +* `+asdf-plugin-collection/plugins/nickel/SECURITY (1).md+` + +==== `+{{PORT}}+` + +Port the container service listens on. + +Appears in: + +* `+asdf-augmenters/asdf-ghjk/Justfile+` +* `+asdf-ghjk/Justfile+` + +==== `+{{PROJECT_UNIQUE_STRENGTH}}+` + +What this does that its alternatives do not. + +Appears in: + +* `+.machine_readable/agent_instructions/methodology.a2ml+` + +==== `+{{RESPONSE_TIME}}+` + +Initial-response SLA for a security or conduct report. Promise only what +a solo maintainer can actually meet. + +Appears in: + +* `+asdf-augmenters/CODE_OF_CONDUCT.md+` +* `+asdf-augmenters/asdf-plugin-collection/plugins/nickel/CODE_OF_CONDUCT (1).md+` +* `+asdf-nickel-plugin/CODE_OF_CONDUCT (1).md+` +* `+asdf-plugin-collection/plugins/nickel/CODE_OF_CONDUCT (1).md+` + +==== `+{{SCRIPT}}+` + +Appears in: + +* `+asdf-augmenters/asdf-ghjk/Justfile+` +* `+asdf-ghjk/Justfile+` + +==== `+{{VERSION}}+` + +Version/tag for the container image. + +Appears in: + +* `+asdf-augmenters/asdf-ghjk/Justfile+` +* `+asdf-augmenters/asdf-metaiconic-plugin/Justfile+` +* `+asdf-augmenters/asdf-plugin-collection/plugins/metaiconic/Justfile+` +* `+asdf-ghjk/Justfile+` +* `+asdf-metaiconic-plugin/Justfile+` +* `+asdf-plugin-collection/plugins/metaiconic/Justfile+` + +==== `+{{WEBSITE}}+` + +Project homepage URL, or delete the field if there is none. + +Appears in: + +* `+asdf-augmenters/asdf-plugin-collection/plugins/nickel/SECURITY (1).md+` +* `+asdf-nickel-plugin/SECURITY (1).md+` +* `+asdf-plugin-collection/plugins/nickel/SECURITY (1).md+` + +''''' + +Generated by the estate top-up pass. Rationale and the governing rulings +are in `+hyperpolymath/standards+`; the token vocabulary is +`+.machine_readable/ai/PLACEHOLDERS.adoc+` in `+rsr-template-repo+`. diff --git a/REQUIRES_INITIALISATION.md b/REQUIRES_INITIALISATION.md deleted file mode 100644 index f6cd0e77..00000000 --- a/REQUIRES_INITIALISATION.md +++ /dev/null @@ -1,212 +0,0 @@ - - -# REQUIRES INITIALISATION - -**This repository is not finished being set up.** 19 substitution token(s) across 15 file(s) still have no value. - -## Why this is not already done - -This repo was created from `hyperpolymath/rsr-template-repo`. The mint -(`just repo-init`) fills every token that has a single mechanical answer — -owner, repo, author, dates, licence, branch — and it has done so here. - -The tokens below are the ones it *deliberately cannot* answer. They need a -decision or a fact that exists only in your head: what this project is for, -what command builds it, which port the service listens on, whether a PGP key -is held at all. The template's own token vocabulary says as much — you cannot -sensibly answer "required invariants" in a thirty-second bootstrap. - -They were left **visibly unfilled on purpose**. The alternatives were both -worse: inventing plausible values would put confident falsehoods into a -security policy and an architecture document, and silently deleting the -sections would hide the fact that a decision is owed. A visible gap is -honest; a fabricated answer is not. - -## Do not delete this file until every item below is resolved - -This file is the only marker that the work is outstanding. Deleting it early -does not finish the setup, it just conceals it — and the next person or agent -to arrive will reasonably assume the repo is complete. - -- **If you are a person:** delete this file yourself once the last item is done. -- **If you are an agent:** resolve what you legitimately can, leave the rest, - and delete this file only when no token below remains anywhere in the tree. - Do not delete it to make a gate go green. - -Re-running the estate top-up tool will remove this file automatically once -nothing is outstanding, so the safest way to finish is to fix the tokens and -let the check confirm it. - -## What is needed, and where it goes - -### `{{CONDUCT_TEAM}}` - -Name of the conduct body. If there is no committee, rewrite the sentence rather than substituting a plural noun into 'a {{CONDUCT_TEAM}} member'. - -Appears in: - -- `asdf-augmenters/CODE_OF_CONDUCT.md` -- `asdf-augmenters/asdf-plugin-collection/plugins/nickel/CODE_OF_CONDUCT (1).md` -- `asdf-nickel-plugin/CODE_OF_CONDUCT (1).md` -- `asdf-plugin-collection/plugins/nickel/CODE_OF_CONDUCT (1).md` - -### `{{CONSUMER1}}` - -A downstream repo that consumes this one. - -Appears in: - -- `.machine_readable/INTENT.contractile` - -### `{{CONSUMER2}}` - -A second downstream consumer. - -Appears in: - -- `.machine_readable/INTENT.contractile` - -### `{{DEP1}}` - -First named dependency, in .machine_readable/INTENT.contractile. - -Appears in: - -- `.machine_readable/INTENT.contractile` - -### `{{DEP2}}` - -Second named dependency, in .machine_readable/INTENT.contractile. - -Appears in: - -- `.machine_readable/INTENT.contractile` - -### `{{FILE}}` - -Appears in: - -- `asdf-augmenters/asdf-ghjk/Justfile` -- `asdf-ghjk/Justfile` - -### `{{MESSAGE}}` - -Appears in: - -- `asdf-augmenters/asdf-ghjk/Justfile` -- `asdf-ghjk/Justfile` - -### `{{MONOREPO_OR_STANDALONE}}` - -Literally 'monorepo' or 'standalone'. - -Appears in: - -- `.machine_readable/INTENT.contractile` - -### `{{NAME}}` - -Appears in: - -- `asdf-augmenters/asdf-ghjk/Justfile` -- `asdf-ghjk/Justfile` - -### `{{ONE_PARAGRAPH_ANTI_PURPOSE}}` - -A paragraph on what this deliberately is NOT for. - -Appears in: - -- `.machine_readable/INTENT.contractile` - -### `{{ONE_PARAGRAPH_PURPOSE}}` - -A paragraph on what this is for. - -Appears in: - -- `.machine_readable/INTENT.contractile` - -### `{{PGP_FINGERPRINT}}` - -Full fingerprint of the security-contact PGP key. NOTE: no key is published anywhere in this estate — if none is held, delete the PGP block rather than inventing one. - -Appears in: - -- `asdf-augmenters/asdf-plugin-collection/plugins/nickel/SECURITY (1).md` -- `asdf-nickel-plugin/SECURITY (1).md` -- `asdf-plugin-collection/plugins/nickel/SECURITY (1).md` - -### `{{PGP_KEY_URL}}` - -Public URL the PGP key can be fetched from. Same caveat as PGP_FINGERPRINT. - -Appears in: - -- `asdf-augmenters/asdf-plugin-collection/plugins/nickel/SECURITY (1).md` -- `asdf-nickel-plugin/SECURITY (1).md` -- `asdf-plugin-collection/plugins/nickel/SECURITY (1).md` - -### `{{PORT}}` - -Port the container service listens on. - -Appears in: - -- `asdf-augmenters/asdf-ghjk/Justfile` -- `asdf-ghjk/Justfile` - -### `{{PROJECT_UNIQUE_STRENGTH}}` - -What this does that its alternatives do not. - -Appears in: - -- `.machine_readable/agent_instructions/methodology.a2ml` - -### `{{RESPONSE_TIME}}` - -Initial-response SLA for a security or conduct report. Promise only what a solo maintainer can actually meet. - -Appears in: - -- `asdf-augmenters/CODE_OF_CONDUCT.md` -- `asdf-augmenters/asdf-plugin-collection/plugins/nickel/CODE_OF_CONDUCT (1).md` -- `asdf-nickel-plugin/CODE_OF_CONDUCT (1).md` -- `asdf-plugin-collection/plugins/nickel/CODE_OF_CONDUCT (1).md` - -### `{{SCRIPT}}` - -Appears in: - -- `asdf-augmenters/asdf-ghjk/Justfile` -- `asdf-ghjk/Justfile` - -### `{{VERSION}}` - -Version/tag for the container image. - -Appears in: - -- `asdf-augmenters/asdf-ghjk/Justfile` -- `asdf-augmenters/asdf-metaiconic-plugin/Justfile` -- `asdf-augmenters/asdf-plugin-collection/plugins/metaiconic/Justfile` -- `asdf-ghjk/Justfile` -- `asdf-metaiconic-plugin/Justfile` -- `asdf-plugin-collection/plugins/metaiconic/Justfile` - -### `{{WEBSITE}}` - -Project homepage URL, or delete the field if there is none. - -Appears in: - -- `asdf-augmenters/asdf-plugin-collection/plugins/nickel/SECURITY (1).md` -- `asdf-nickel-plugin/SECURITY (1).md` -- `asdf-plugin-collection/plugins/nickel/SECURITY (1).md` - ---- - -Generated by the estate top-up pass. Rationale and the governing rulings are -in `hyperpolymath/standards`; the token vocabulary is -`.machine_readable/ai/PLACEHOLDERS.adoc` in `rsr-template-repo`. diff --git a/SECURITY.adoc b/SECURITY.adoc new file mode 100644 index 00000000..71e249fd --- /dev/null +++ b/SECURITY.adoc @@ -0,0 +1,452 @@ +== Security Policy + +We take security seriously. We appreciate your efforts to responsibly +disclose vulnerabilities and will make every effort to acknowledge your +contributions. + +=== Table of Contents + +* link:#reporting-a-vulnerability[Reporting a Vulnerability] +* link:#what-to-include[What to Include] +* link:#response-timeline[Response Timeline] +* link:#disclosure-policy[Disclosure Policy] +* link:#scope[Scope] +* link:#safe-harbour[Safe Harbour] +* link:#recognition[Recognition] +* link:#security-updates[Security Updates] +* link:#security-best-practices[Security Best Practices] + +''''' + +=== Reporting a Vulnerability + +==== Preferred Method: GitHub Security Advisories + +The preferred method for reporting security vulnerabilities is through +GitHub’s Security Advisory feature: + +[arabic] +. Navigate to +https://github.com/hyperpolymath/asdf-tool-plugins/security/advisories/new[Report +a Vulnerability] +. Click *"`Report a vulnerability`"* +. Complete the form with as much detail as possible +. Submit — we’ll receive a private notification + +This method ensures: + +* End-to-end encryption of your report +* Private discussion space for collaboration +* Coordinated disclosure tooling +* Automatic credit when the advisory is published + +==== Alternative: Encrypted Email + +If you cannot use GitHub Security Advisories, you may email us directly: + +[width="100%",cols="50%,50%",] +|=== +|*Email* |j.d.a.jewell@open.ac.uk +|*PGP Key* |https://hyperpolymath.github.io/pgp.asc[Download Public Key] +|*Fingerprint* |`+TBD+` +|=== + +[source,bash] +---- +# Import our PGP key +curl -sSL https://hyperpolymath.github.io/pgp.asc | gpg --import + +# Verify fingerprint +gpg --fingerprint j.d.a.jewell@open.ac.uk + +# Encrypt your report +gpg --armor --encrypt --recipient j.d.a.jewell@open.ac.uk report.txt +---- + +____ +*⚠️ Important:* Do not report security vulnerabilities through public +GitHub issues, pull requests, discussions, or social media. +____ + +''''' + +=== What to Include + +A good vulnerability report helps us understand and reproduce the issue +quickly. + +==== Required Information + +* *Description*: Clear explanation of the vulnerability +* *Impact*: What an attacker could achieve (confidentiality, integrity, +availability) +* *Affected versions*: Which versions/commits are affected +* *Reproduction steps*: Detailed steps to reproduce the issue + +==== Helpful Additional Information + +* *Proof of concept*: Code, scripts, or screenshots demonstrating the +vulnerability +* *Attack scenario*: Realistic attack scenario showing exploitability +* *CVSS score*: Your assessment of severity (use +https://www.first.org/cvss/calculator/3.1[CVSS 3.1 Calculator]) +* *CWE ID*: Common Weakness Enumeration identifier if known +* *Suggested fix*: If you have ideas for remediation +* *References*: Links to related vulnerabilities, research, or +advisories + +==== Example Report Structure + +[source,markdown] +---- +## Summary +[One-sentence description of the vulnerability] + +## Vulnerability Type +[e.g., SQL Injection, XSS, SSRF, Path Traversal, etc.] + +## Affected Component +[File path, function name, API endpoint, etc.] + +## Affected Versions +[Version range or specific commits] + +## Severity Assessment +- CVSS 3.1 Score: [X.X] +- CVSS Vector: [CVSS:3.1/AV:X/AC:X/PR:X/UI:X/S:X/C:X/I:X/A:X] + +## Description +[Detailed technical description] + +## Steps to Reproduce +1. [First step] +2. [Second step] +3. [...] + +## Proof of Concept +[Code, curl commands, screenshots, etc.] + +## Impact +[What can an attacker achieve?] + +## Suggested Remediation +[Optional: your ideas for fixing] + +## References +[Links to related issues, CVEs, research] +---- + +''''' + +=== Response Timeline + +We commit to the following response times: + +[width="100%",cols="24%,35%,41%",options="header",] +|=== +|Stage |Timeframe |Description +|*Initial Response* |48 hours |We acknowledge receipt and confirm we’re +investigating + +|*Triage* |7 days |We assess severity, confirm the vulnerability, and +estimate timeline + +|*Status Update* |Every 7 days |Regular updates on remediation progress + +|*Resolution* |90 days |Target for fix development and release (complex +issues may take longer) + +|*Disclosure* |90 days |Public disclosure after fix is available +(coordinated with you) +|=== + +____ +*Note:* These are targets, not guarantees. Complex vulnerabilities may +require more time. We’ll communicate openly about any delays. +____ + +''''' + +=== Disclosure Policy + +We follow *coordinated disclosure* (also known as responsible +disclosure): + +[arabic] +. *You report* the vulnerability privately +. *We acknowledge* and begin investigation +. *We develop* a fix and prepare a release +. *We coordinate* disclosure timing with you +. *We publish* security advisory and fix simultaneously +. *You may publish* your research after disclosure + +==== Our Commitments + +* We will not take legal action against researchers who follow this +policy +* We will work with you to understand and resolve the issue +* We will credit you in the security advisory (unless you prefer +anonymity) +* We will notify you before public disclosure +* We will publish advisories with sufficient detail for users to assess +risk + +==== Your Commitments + +* Report vulnerabilities promptly after discovery +* Give us reasonable time to address the issue before disclosure +* Do not access, modify, or delete data beyond what’s necessary to +demonstrate the vulnerability +* Do not degrade service availability (no DoS testing on production) +* Do not share vulnerability details with others until coordinated +disclosure + +==== Disclosure Timeline + +.... +Day 0 You report vulnerability +Day 1-2 We acknowledge receipt +Day 7 We confirm vulnerability and share initial assessment +Day 7-90 We develop and test fix +Day 90 Coordinated public disclosure + (earlier if fix is ready; later by mutual agreement) +.... + +If we cannot reach agreement on disclosure timing, we default to 90 days +from your initial report. + +''''' + +=== Scope + +==== In Scope ✅ + +The following are within scope for security research: + +* This repository (`+hyperpolymath/asdf-tool-plugins+`) and all its code +* Official releases and packages published from this repository +* Documentation that could lead to security issues +* Build and deployment configurations in this repository +* Dependencies (report here, we’ll coordinate with upstream) + +==== Out of Scope ❌ + +The following are *not* in scope: + +* Third-party services we integrate with (report directly to them) +* Social engineering attacks against maintainers +* Physical security +* Denial of service attacks against production infrastructure +* Spam, phishing, or other non-technical attacks +* Issues already reported or publicly known +* Theoretical vulnerabilities without proof of concept + +==== Qualifying Vulnerabilities + +We’re particularly interested in: + +* Remote code execution +* SQL injection, command injection, code injection +* Authentication/authorisation bypass +* Cross-site scripting (XSS) and cross-site request forgery (CSRF) +* Server-side request forgery (SSRF) +* Path traversal / local file inclusion +* Information disclosure (credentials, PII, secrets) +* Cryptographic weaknesses +* Deserialisation vulnerabilities +* Memory safety issues (buffer overflows, use-after-free, etc.) +* Supply chain vulnerabilities (dependency confusion, etc.) +* Significant logic flaws + +==== Non-Qualifying Issues + +The following generally do not qualify as security vulnerabilities: + +* Missing security headers on non-sensitive pages +* Clickjacking on pages without sensitive actions +* Self-XSS (requires victim to paste code) +* Missing rate limiting (unless it enables a specific attack) +* Username/email enumeration (unless high-risk context) +* Missing cookie flags on non-sensitive cookies +* Software version disclosure +* Verbose error messages (unless exposing secrets) +* Best practice deviations without demonstrable impact + +''''' + +=== Safe Harbour + +We support security research conducted in good faith. + +==== Our Promise + +If you conduct security research in accordance with this policy: + +* ✅ We will not initiate legal action against you +* ✅ We will not report your activity to law enforcement +* ✅ We will work with you in good faith to resolve issues +* ✅ We consider your research authorised under the Computer Fraud and +Abuse Act (CFAA), UK Computer Misuse Act, and similar laws +* ✅ We waive any potential claim against you for circumvention of +security controls + +==== Good Faith Requirements + +To qualify for safe harbour, you must: + +* Comply with this security policy +* Report vulnerabilities promptly +* Avoid privacy violations (do not access others’ data) +* Avoid service degradation (no destructive testing) +* Not exploit vulnerabilities beyond proof-of-concept +* Not use vulnerabilities for profit (beyond bug bounties where offered) + +____ +*⚠️ Important:* This safe harbour does not extend to third-party +systems. Always check their policies before testing. +____ + +''''' + +=== Recognition + +We believe in recognising security researchers who help us improve. + +==== Hall of Fame + +Researchers who report valid vulnerabilities will be acknowledged in our +link:SECURITY-ACKNOWLEDGMENTS.md[Security Acknowledgments] (unless they +prefer anonymity). + +Recognition includes: + +* Your name (or chosen alias) +* Link to your website/profile (optional) +* Brief description of the vulnerability class +* Date of report + +==== What We Offer + +* ✅ Public credit in security advisories +* ✅ Acknowledgment in release notes +* ✅ Entry in our Hall of Fame +* ✅ Reference/recommendation letter upon request (for significant +findings) + +==== What We Don’t Currently Offer + +* ❌ Monetary bug bounties +* ❌ Hardware or swag +* ❌ Paid security research contracts + +____ +*Note:* We’re a community project with limited resources. Your +contributions help everyone who uses this software. +____ + +''''' + +=== Security Updates + +==== Receiving Updates + +To stay informed about security updates: + +* *Watch this repository*: Click "`Watch`" → "`Custom`" → Select +"`Security alerts`" +* *GitHub Security Advisories*: Published at +https://github.com/hyperpolymath/asdf-tool-plugins/security/advisories[Security +Advisories] +* *Release notes*: Security fixes noted in link:CHANGELOG.md[CHANGELOG] + +==== Update Policy + +[cols=",",options="header",] +|=== +|Severity |Response +|*Critical/High* |Patch release as soon as fix is ready +|*Medium* |Included in next scheduled release (or earlier) +|*Low* |Included in next scheduled release +|=== + +==== Supported Versions + +[cols=",,",options="header",] +|=== +|Version |Supported |Notes +|`+main+` branch |✅ Yes |Latest development +|Latest release |✅ Yes |Current stable +|Previous minor release |✅ Yes |Security fixes backported +|Older versions |❌ No |Please upgrade +|=== + +''''' + +=== Security Best Practices + +When using asdf-tool-plugins, we recommend: + +==== General + +* Keep dependencies up to date +* Use the latest stable release +* Subscribe to security notifications +* Review configuration against security documentation +* Follow principle of least privilege + +==== For Contributors + +* Never commit secrets, credentials, or API keys +* Use signed commits (`+git config commit.gpgsign true+`) +* Review dependencies before adding them +* Run security linters locally before pushing +* Report any concerns about existing code + +''''' + +=== Additional Resources + +* https://hyperpolymath.github.io/pgp.asc[Our PGP Public Key] +* https://github.com/hyperpolymath/asdf-tool-plugins/security/advisories[Security +Advisories] +* link:CHANGELOG.md[Changelog] +* link:CONTRIBUTING.md[Contributing Guidelines] +* https://cve.mitre.org/[CVE Database] +* https://www.first.org/cvss/calculator/3.1[CVSS Calculator] + +''''' + +=== Contact + +[width="100%",cols="50%,50%",options="header",] +|=== +|Purpose |Contact +|*Security issues* +|https://github.com/hyperpolymath/asdf-tool-plugins/security/advisories/new[Report +via GitHub] or j.d.a.jewell@open.ac.uk + +|*General questions* +|https://github.com/hyperpolymath/asdf-tool-plugins/discussions[GitHub +Discussions] + +|*Other enquiries* |See link:README.md[README] for contact information +|=== + +''''' + +=== Policy Changes + +This security policy may be updated from time to time. Significant +changes will be: + +* Committed to this repository with a clear commit message +* Noted in the changelog +* Announced via GitHub Discussions (for major changes) + +''''' + +_Thank you for helping keep asdf-tool-plugins and its users safe._ 🛡️ + +''''' + +Last updated: 2026 · Policy version: 1.0.0 diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 8b15dffc..00000000 --- a/SECURITY.md +++ /dev/null @@ -1,406 +0,0 @@ -# Security Policy - - - -We take security seriously. We appreciate your efforts to responsibly disclose vulnerabilities and will make every effort to acknowledge your contributions. - -## Table of Contents - -- [Reporting a Vulnerability](#reporting-a-vulnerability) -- [What to Include](#what-to-include) -- [Response Timeline](#response-timeline) -- [Disclosure Policy](#disclosure-policy) -- [Scope](#scope) -- [Safe Harbour](#safe-harbour) -- [Recognition](#recognition) -- [Security Updates](#security-updates) -- [Security Best Practices](#security-best-practices) - ---- - -## Reporting a Vulnerability - -### Preferred Method: GitHub Security Advisories - -The preferred method for reporting security vulnerabilities is through GitHub's Security Advisory feature: - -1. Navigate to [Report a Vulnerability](https://github.com/hyperpolymath/asdf-tool-plugins/security/advisories/new) -2. Click **"Report a vulnerability"** -3. Complete the form with as much detail as possible -4. Submit — we'll receive a private notification - -This method ensures: - -- End-to-end encryption of your report -- Private discussion space for collaboration -- Coordinated disclosure tooling -- Automatic credit when the advisory is published - -### Alternative: Encrypted Email - -If you cannot use GitHub Security Advisories, you may email us directly: - -| | | -|---|---| -| **Email** | j.d.a.jewell@open.ac.uk | -| **PGP Key** | [Download Public Key](https://hyperpolymath.github.io/pgp.asc) | -| **Fingerprint** | `TBD` | - -```bash -# Import our PGP key -curl -sSL https://hyperpolymath.github.io/pgp.asc | gpg --import - -# Verify fingerprint -gpg --fingerprint j.d.a.jewell@open.ac.uk - -# Encrypt your report -gpg --armor --encrypt --recipient j.d.a.jewell@open.ac.uk report.txt -``` - -> **⚠️ Important:** Do not report security vulnerabilities through public GitHub issues, pull requests, discussions, or social media. - ---- - -## What to Include - -A good vulnerability report helps us understand and reproduce the issue quickly. - -### Required Information - -- **Description**: Clear explanation of the vulnerability -- **Impact**: What an attacker could achieve (confidentiality, integrity, availability) -- **Affected versions**: Which versions/commits are affected -- **Reproduction steps**: Detailed steps to reproduce the issue - -### Helpful Additional Information - -- **Proof of concept**: Code, scripts, or screenshots demonstrating the vulnerability -- **Attack scenario**: Realistic attack scenario showing exploitability -- **CVSS score**: Your assessment of severity (use [CVSS 3.1 Calculator](https://www.first.org/cvss/calculator/3.1)) -- **CWE ID**: Common Weakness Enumeration identifier if known -- **Suggested fix**: If you have ideas for remediation -- **References**: Links to related vulnerabilities, research, or advisories - -### Example Report Structure - -```markdown -## Summary -[One-sentence description of the vulnerability] - -## Vulnerability Type -[e.g., SQL Injection, XSS, SSRF, Path Traversal, etc.] - -## Affected Component -[File path, function name, API endpoint, etc.] - -## Affected Versions -[Version range or specific commits] - -## Severity Assessment -- CVSS 3.1 Score: [X.X] -- CVSS Vector: [CVSS:3.1/AV:X/AC:X/PR:X/UI:X/S:X/C:X/I:X/A:X] - -## Description -[Detailed technical description] - -## Steps to Reproduce -1. [First step] -2. [Second step] -3. [...] - -## Proof of Concept -[Code, curl commands, screenshots, etc.] - -## Impact -[What can an attacker achieve?] - -## Suggested Remediation -[Optional: your ideas for fixing] - -## References -[Links to related issues, CVEs, research] -``` - ---- - -## Response Timeline - -We commit to the following response times: - -| Stage | Timeframe | Description | -|-------|-----------|-------------| -| **Initial Response** | 48 hours | We acknowledge receipt and confirm we're investigating | -| **Triage** | 7 days | We assess severity, confirm the vulnerability, and estimate timeline | -| **Status Update** | Every 7 days | Regular updates on remediation progress | -| **Resolution** | 90 days | Target for fix development and release (complex issues may take longer) | -| **Disclosure** | 90 days | Public disclosure after fix is available (coordinated with you) | - -> **Note:** These are targets, not guarantees. Complex vulnerabilities may require more time. We'll communicate openly about any delays. - ---- - -## Disclosure Policy - -We follow **coordinated disclosure** (also known as responsible disclosure): - -1. **You report** the vulnerability privately -2. **We acknowledge** and begin investigation -3. **We develop** a fix and prepare a release -4. **We coordinate** disclosure timing with you -5. **We publish** security advisory and fix simultaneously -6. **You may publish** your research after disclosure - -### Our Commitments - -- We will not take legal action against researchers who follow this policy -- We will work with you to understand and resolve the issue -- We will credit you in the security advisory (unless you prefer anonymity) -- We will notify you before public disclosure -- We will publish advisories with sufficient detail for users to assess risk - -### Your Commitments - -- Report vulnerabilities promptly after discovery -- Give us reasonable time to address the issue before disclosure -- Do not access, modify, or delete data beyond what's necessary to demonstrate the vulnerability -- Do not degrade service availability (no DoS testing on production) -- Do not share vulnerability details with others until coordinated disclosure - -### Disclosure Timeline - -``` -Day 0 You report vulnerability -Day 1-2 We acknowledge receipt -Day 7 We confirm vulnerability and share initial assessment -Day 7-90 We develop and test fix -Day 90 Coordinated public disclosure - (earlier if fix is ready; later by mutual agreement) -``` - -If we cannot reach agreement on disclosure timing, we default to 90 days from your initial report. - ---- - -## Scope - -### In Scope ✅ - -The following are within scope for security research: - -- This repository (`hyperpolymath/asdf-tool-plugins`) and all its code -- Official releases and packages published from this repository -- Documentation that could lead to security issues -- Build and deployment configurations in this repository -- Dependencies (report here, we'll coordinate with upstream) - -### Out of Scope ❌ - -The following are **not** in scope: - -- Third-party services we integrate with (report directly to them) -- Social engineering attacks against maintainers -- Physical security -- Denial of service attacks against production infrastructure -- Spam, phishing, or other non-technical attacks -- Issues already reported or publicly known -- Theoretical vulnerabilities without proof of concept - -### Qualifying Vulnerabilities - -We're particularly interested in: - -- Remote code execution -- SQL injection, command injection, code injection -- Authentication/authorisation bypass -- Cross-site scripting (XSS) and cross-site request forgery (CSRF) -- Server-side request forgery (SSRF) -- Path traversal / local file inclusion -- Information disclosure (credentials, PII, secrets) -- Cryptographic weaknesses -- Deserialisation vulnerabilities -- Memory safety issues (buffer overflows, use-after-free, etc.) -- Supply chain vulnerabilities (dependency confusion, etc.) -- Significant logic flaws - -### Non-Qualifying Issues - -The following generally do not qualify as security vulnerabilities: - -- Missing security headers on non-sensitive pages -- Clickjacking on pages without sensitive actions -- Self-XSS (requires victim to paste code) -- Missing rate limiting (unless it enables a specific attack) -- Username/email enumeration (unless high-risk context) -- Missing cookie flags on non-sensitive cookies -- Software version disclosure -- Verbose error messages (unless exposing secrets) -- Best practice deviations without demonstrable impact - ---- - -## Safe Harbour - -We support security research conducted in good faith. - -### Our Promise - -If you conduct security research in accordance with this policy: - -- ✅ We will not initiate legal action against you -- ✅ We will not report your activity to law enforcement -- ✅ We will work with you in good faith to resolve issues -- ✅ We consider your research authorised under the Computer Fraud and Abuse Act (CFAA), UK Computer Misuse Act, and similar laws -- ✅ We waive any potential claim against you for circumvention of security controls - -### Good Faith Requirements - -To qualify for safe harbour, you must: - -- Comply with this security policy -- Report vulnerabilities promptly -- Avoid privacy violations (do not access others' data) -- Avoid service degradation (no destructive testing) -- Not exploit vulnerabilities beyond proof-of-concept -- Not use vulnerabilities for profit (beyond bug bounties where offered) - -> **⚠️ Important:** This safe harbour does not extend to third-party systems. Always check their policies before testing. - ---- - -## Recognition - -We believe in recognising security researchers who help us improve. - -### Hall of Fame - -Researchers who report valid vulnerabilities will be acknowledged in our [Security Acknowledgments](SECURITY-ACKNOWLEDGMENTS.md) (unless they prefer anonymity). - -Recognition includes: - -- Your name (or chosen alias) -- Link to your website/profile (optional) -- Brief description of the vulnerability class -- Date of report - -### What We Offer - -- ✅ Public credit in security advisories -- ✅ Acknowledgment in release notes -- ✅ Entry in our Hall of Fame -- ✅ Reference/recommendation letter upon request (for significant findings) - -### What We Don't Currently Offer - -- ❌ Monetary bug bounties -- ❌ Hardware or swag -- ❌ Paid security research contracts - -> **Note:** We're a community project with limited resources. Your contributions help everyone who uses this software. - ---- - -## Security Updates - -### Receiving Updates - -To stay informed about security updates: - -- **Watch this repository**: Click "Watch" → "Custom" → Select "Security alerts" -- **GitHub Security Advisories**: Published at [Security Advisories](https://github.com/hyperpolymath/asdf-tool-plugins/security/advisories) -- **Release notes**: Security fixes noted in [CHANGELOG](CHANGELOG.md) - -### Update Policy - -| Severity | Response | -|----------|----------| -| **Critical/High** | Patch release as soon as fix is ready | -| **Medium** | Included in next scheduled release (or earlier) | -| **Low** | Included in next scheduled release | - -### Supported Versions - - - -| Version | Supported | Notes | -|---------|-----------|-------| -| `main` branch | ✅ Yes | Latest development | -| Latest release | ✅ Yes | Current stable | -| Previous minor release | ✅ Yes | Security fixes backported | -| Older versions | ❌ No | Please upgrade | - ---- - -## Security Best Practices - -When using asdf-tool-plugins, we recommend: - -### General - -- Keep dependencies up to date -- Use the latest stable release -- Subscribe to security notifications -- Review configuration against security documentation -- Follow principle of least privilege - -### For Contributors - -- Never commit secrets, credentials, or API keys -- Use signed commits (`git config commit.gpgsign true`) -- Review dependencies before adding them -- Run security linters locally before pushing -- Report any concerns about existing code - ---- - -## Additional Resources - -- [Our PGP Public Key](https://hyperpolymath.github.io/pgp.asc) -- [Security Advisories](https://github.com/hyperpolymath/asdf-tool-plugins/security/advisories) -- [Changelog](CHANGELOG.md) -- [Contributing Guidelines](CONTRIBUTING.md) -- [CVE Database](https://cve.mitre.org/) -- [CVSS Calculator](https://www.first.org/cvss/calculator/3.1) - ---- - -## Contact - -| Purpose | Contact | -|---------|---------| -| **Security issues** | [Report via GitHub](https://github.com/hyperpolymath/asdf-tool-plugins/security/advisories/new) or j.d.a.jewell@open.ac.uk | -| **General questions** | [GitHub Discussions](https://github.com/hyperpolymath/asdf-tool-plugins/discussions) | -| **Other enquiries** | See [README](README.md) for contact information | - ---- - -## Policy Changes - -This security policy may be updated from time to time. Significant changes will be: - -- Committed to this repository with a clear commit message -- Noted in the changelog -- Announced via GitHub Discussions (for major changes) - ---- - -*Thank you for helping keep asdf-tool-plugins and its users safe.* 🛡️ - ---- - -Last updated: 2026 · Policy version: 1.0.0 diff --git a/TEST-NEEDS.adoc b/TEST-NEEDS.adoc new file mode 100644 index 00000000..a1b0da69 --- /dev/null +++ b/TEST-NEEDS.adoc @@ -0,0 +1,32 @@ +== TEST-NEEDS.md — asdf-tool-plugins + +=== CRG Grade: C — ACHIEVED 2026-04-04 + +=== Current Test State + +[cols=",,",options="header",] +|=== +|Category |Count |Notes +|Test directories |2 |Location(s): /asdf-ghjk/test, /tests +|CI workflows |18 |Running tests on GitHub Actions +|Tests |Present |Configured in CI workflows +|=== + +=== What’s Covered + +* [x] Tests present and running +* [x] CI integration active + +=== Still Missing (for CRG B+) + +* [ ] Code coverage reports (codecov integration) +* [ ] Detailed test documentation in CONTRIBUTING.md +* [ ] Integration tests beyond unit tests +* [ ] Performance benchmarking suite + +=== Run Tests + +[source,bash] +---- +(check Makefile/justfile/package.json for test command) +---- diff --git a/TEST-NEEDS.md b/TEST-NEEDS.md deleted file mode 100644 index b38d4a06..00000000 --- a/TEST-NEEDS.md +++ /dev/null @@ -1,29 +0,0 @@ -# TEST-NEEDS.md — asdf-tool-plugins - -## CRG Grade: C — ACHIEVED 2026-04-04 - -## Current Test State - -| Category | Count | Notes | -|----------|-------|-------| -| Test directories | 2 | Location(s): /asdf-ghjk/test, /tests | -| CI workflows | 18 | Running tests on GitHub Actions | -| Tests | Present | Configured in CI workflows | - -## What's Covered - -- [x] Tests present and running -- [x] CI integration active - -## Still Missing (for CRG B+) - -- [ ] Code coverage reports (codecov integration) -- [ ] Detailed test documentation in CONTRIBUTING.md -- [ ] Integration tests beyond unit tests -- [ ] Performance benchmarking suite - -## Run Tests - -```bash -(check Makefile/justfile/package.json for test command) -``` diff --git a/TOPOLOGY.adoc b/TOPOLOGY.adoc new file mode 100644 index 00000000..d70fb61b --- /dev/null +++ b/TOPOLOGY.adoc @@ -0,0 +1,84 @@ +== asdf Tool Plugins — Project Topology + +=== System Architecture + +.... + ┌─────────────────────────────────────────┐ + │ DEVELOPER / CLI │ + │ (asdf plugin add ) │ + └───────────────────┬─────────────────────┘ + │ + ▼ + ┌─────────────────────────────────────────┐ + │ PLUGIN COLLECTION HUB │ + │ │ + │ ┌───────────┐ ┌───────────────────┐ │ + │ │ Language │ │ Infrastructure │ │ + │ │ Plugins │ │ Plugins │ │ + │ │ (Ada, OCaml,│ │ (Envoy, Varnish, │ │ + │ │ Zig, etc.) │ │ Coredns, etc.) │ │ + │ └─────┬─────┘ └────────┬──────────┘ │ + │ │ │ │ + │ ┌─────▼─────┐ ┌────────▼──────────┐ │ + │ │ Storage │ │ Security │ │ + │ │ Plugins │ │ Plugins │ │ + │ │(ArangoDB, │ │ (Cosign, Age, │ │ + │ │ MariaDB) │ │ Sops, etc.) │ │ + │ └─────┬─────┘ └────────┬──────────┘ │ + └────────│─────────────────│──────────────┘ + │ │ + ▼ ▼ + ┌─────────────────────────────────────────┐ + │ EXTERNAL TOOL SOURCES │ + │ (GitHub Releases, CDN, etc.) │ + └─────────────────────────────────────────┘ + + ┌─────────────────────────────────────────┐ + │ REPO INFRASTRUCTURE │ + │ .bot_directives/ Justfile │ + │ contractiles/ .github/workflows/ │ + │ .machine_readable/ (STATE.a2ml) │ + └─────────────────────────────────────────┘ +.... + +=== Completion Dashboard + +.... +COMPONENT STATUS NOTES +───────────────────────────────── ────────────────── ───────────────────────────────── +PLUGIN CATEGORIES + Language Plugins (Zig, V, Deno) ██████████ 100% All major runtimes active + Infrastructure (Envoy, Proxy) ████████░░ 80% Scaling logic verified + Storage (Arango, Virtuoso) ██████████ 100% DB installers stable + Security (Age, Sops, Cosign) ██████████ 100% Full toolset available + +SHARED INFRASTRUCTURE + Justfile (Batch Build) ██████████ 100% Standard build automation + .bot_directives/ ██████████ 100% Plugin hygiene rules + .machine_readable/ ██████████ 100% STATE.a2ml tracking + +───────────────────────────────────────────────────────────────────────────── +OVERALL: █████████░ ~90% Robust plugin ecosystem +.... + +=== Key Dependencies + +.... +asdf Core ──────► Plugin Script ──────► Download Source ──────► Install + │ + ▼ + Shim Generation +.... + +=== Update Protocol + +This file is maintained by both humans and AI agents. When updating: + +[arabic] +. *After completing a component*: Change its bar and percentage +. *After adding a component*: Add a new row in the appropriate section +. *After architectural changes*: Update the ASCII diagram +. *Date*: Update the `+Last updated+` comment at the top of this file + +Progress bars use: `+█+` (filled) and `+░+` (empty), 10 characters wide. +Percentages: 0%, 10%, 20%, … 100% (in 10% increments). diff --git a/TOPOLOGY.md b/TOPOLOGY.md deleted file mode 100644 index 7650c39c..00000000 --- a/TOPOLOGY.md +++ /dev/null @@ -1,87 +0,0 @@ - - - - -# asdf Tool Plugins — Project Topology - -## System Architecture - -``` - ┌─────────────────────────────────────────┐ - │ DEVELOPER / CLI │ - │ (asdf plugin add ) │ - └───────────────────┬─────────────────────┘ - │ - ▼ - ┌─────────────────────────────────────────┐ - │ PLUGIN COLLECTION HUB │ - │ │ - │ ┌───────────┐ ┌───────────────────┐ │ - │ │ Language │ │ Infrastructure │ │ - │ │ Plugins │ │ Plugins │ │ - │ │ (Ada, OCaml,│ │ (Envoy, Varnish, │ │ - │ │ Zig, etc.) │ │ Coredns, etc.) │ │ - │ └─────┬─────┘ └────────┬──────────┘ │ - │ │ │ │ - │ ┌─────▼─────┐ ┌────────▼──────────┐ │ - │ │ Storage │ │ Security │ │ - │ │ Plugins │ │ Plugins │ │ - │ │(ArangoDB, │ │ (Cosign, Age, │ │ - │ │ MariaDB) │ │ Sops, etc.) │ │ - │ └─────┬─────┘ └────────┬──────────┘ │ - └────────│─────────────────│──────────────┘ - │ │ - ▼ ▼ - ┌─────────────────────────────────────────┐ - │ EXTERNAL TOOL SOURCES │ - │ (GitHub Releases, CDN, etc.) │ - └─────────────────────────────────────────┘ - - ┌─────────────────────────────────────────┐ - │ REPO INFRASTRUCTURE │ - │ .bot_directives/ Justfile │ - │ contractiles/ .github/workflows/ │ - │ .machine_readable/ (STATE.a2ml) │ - └─────────────────────────────────────────┘ -``` - -## Completion Dashboard - -``` -COMPONENT STATUS NOTES -───────────────────────────────── ────────────────── ───────────────────────────────── -PLUGIN CATEGORIES - Language Plugins (Zig, V, Deno) ██████████ 100% All major runtimes active - Infrastructure (Envoy, Proxy) ████████░░ 80% Scaling logic verified - Storage (Arango, Virtuoso) ██████████ 100% DB installers stable - Security (Age, Sops, Cosign) ██████████ 100% Full toolset available - -SHARED INFRASTRUCTURE - Justfile (Batch Build) ██████████ 100% Standard build automation - .bot_directives/ ██████████ 100% Plugin hygiene rules - .machine_readable/ ██████████ 100% STATE.a2ml tracking - -───────────────────────────────────────────────────────────────────────────── -OVERALL: █████████░ ~90% Robust plugin ecosystem -``` - -## Key Dependencies - -``` -asdf Core ──────► Plugin Script ──────► Download Source ──────► Install - │ - ▼ - Shim Generation -``` - -## Update Protocol - -This file is maintained by both humans and AI agents. When updating: - -1. **After completing a component**: Change its bar and percentage -2. **After adding a component**: Add a new row in the appropriate section -3. **After architectural changes**: Update the ASCII diagram -4. **Date**: Update the `Last updated` comment at the top of this file - -Progress bars use: `█` (filled) and `░` (empty), 10 characters wide. -Percentages: 0%, 10%, 20%, ... 100% (in 10% increments). diff --git a/asdf-acceleration-middleware/ABI-FFI-README.adoc b/asdf-acceleration-middleware/ABI-FFI-README.adoc new file mode 100644 index 00000000..c75b6978 --- /dev/null +++ b/asdf-acceleration-middleware/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== ACCELERATION_MIDDLEWARE ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/acceleration-middleware.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libacceleration-middleware.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +acceleration-middleware/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── acceleration-middleware.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── acceleration-middleware.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/acceleration-middleware.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "acceleration-middleware.h" + +int main() { + void* handle = acceleration-middleware_init(); + if (!handle) return 1; + + int result = acceleration-middleware_process(handle, 42); + if (result != 0) { + const char* err = acceleration-middleware_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + acceleration-middleware_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lacceleration-middleware -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import ACCELERATION_MIDDLEWARE.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "acceleration-middleware")] +extern "C" { + fn acceleration-middleware_init() -> *mut std::ffi::c_void; + fn acceleration-middleware_free(handle: *mut std::ffi::c_void); + fn acceleration-middleware_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = acceleration-middleware_init(); + assert!(!handle.is_null()); + + let result = acceleration-middleware_process(handle, 42); + assert_eq!(result, 0); + + acceleration-middleware_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libacceleration-middleware = "libacceleration-middleware" + +function init() + handle = ccall((:acceleration-middleware_init, libacceleration-middleware), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:acceleration-middleware_process, libacceleration-middleware), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:acceleration-middleware_free, libacceleration-middleware), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/acceleration-middleware.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-acceleration-middleware/ABI-FFI-README.md b/asdf-acceleration-middleware/ABI-FFI-README.md deleted file mode 100644 index 4ea6bbd7..00000000 --- a/asdf-acceleration-middleware/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# ACCELERATION_MIDDLEWARE ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/acceleration-middleware.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libacceleration-middleware.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -acceleration-middleware/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── acceleration-middleware.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── acceleration-middleware.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/acceleration-middleware.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "acceleration-middleware.h" - -int main() { - void* handle = acceleration-middleware_init(); - if (!handle) return 1; - - int result = acceleration-middleware_process(handle, 42); - if (result != 0) { - const char* err = acceleration-middleware_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - acceleration-middleware_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lacceleration-middleware -L./zig-out/lib -``` - -### From Idris2 - -```idris -import ACCELERATION_MIDDLEWARE.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "acceleration-middleware")] -extern "C" { - fn acceleration-middleware_init() -> *mut std::ffi::c_void; - fn acceleration-middleware_free(handle: *mut std::ffi::c_void); - fn acceleration-middleware_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = acceleration-middleware_init(); - assert!(!handle.is_null()); - - let result = acceleration-middleware_process(handle, 42); - assert_eq!(result, 0); - - acceleration-middleware_free(handle); - } -} -``` - -### From Julia - -```julia -const libacceleration-middleware = "libacceleration-middleware" - -function init() - handle = ccall((:acceleration-middleware_init, libacceleration-middleware), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:acceleration-middleware_process, libacceleration-middleware), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:acceleration-middleware_free, libacceleration-middleware), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/acceleration-middleware.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-acceleration-middleware/CODE_OF_CONDUCT.adoc b/asdf-acceleration-middleware/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..3895211c --- /dev/null +++ b/asdf-acceleration-middleware/CODE_OF_CONDUCT.adoc @@ -0,0 +1,176 @@ +== Code of Conduct + +=== Our Pledge + +We as members, contributors, and leaders pledge to make participation in +our community a harassment-free experience for everyone, regardless of +age, body size, visible or invisible disability, ethnicity, sex +characteristics, gender identity and expression, level of experience, +education, socio-economic status, nationality, personal appearance, +race, caste, color, religion, or sexual identity and orientation. + +We pledge to act and interact in ways that contribute to an open, +welcoming, diverse, inclusive, and healthy community. + +=== Our Standards + +==== Examples of behavior that contributes to a positive environment: + +* ✅ Demonstrating empathy and kindness toward other people +* ✅ Being respectful of differing opinions, viewpoints, and experiences +* ✅ Giving and gracefully accepting constructive feedback +* ✅ Accepting responsibility and apologizing to those affected by our +mistakes, and learning from the experience +* ✅ Focusing on what is best not just for us as individuals, but for +the overall community +* ✅ Using welcoming and inclusive language +* ✅ Respecting people’s boundaries and privacy +* ✅ Assuming good intent + +==== Examples of unacceptable behavior: + +* ❌ The use of sexualized language or imagery, and sexual attention or +advances of any kind +* ❌ Trolling, insulting or derogatory comments, and personal or +political attacks +* ❌ Public or private harassment +* ❌ Publishing others’ private information, such as a physical or email +address, without their explicit permission +* ❌ Other conduct which could reasonably be considered inappropriate in +a professional setting +* ❌ Dismissing or attacking minority viewpoints +* ❌ Pattern of boundary violations + +=== Emotional Safety (Palimpsest License Principles) + +In alignment with the Palimpsest License emotional safety clause: + +==== Attribution and Recognition + +* Contributors maintain the right to have their work acknowledged +* No erasure of historical contributions +* Maintain visible chain of authorship +* Credit original ideas and implementations + +==== Reversibility and Autonomy + +* Respect people’s right to fork and maintain alternatives +* No lock-in or coercive practices +* Support migration and portability +* Welcome healthy competition + +==== Psychological Safety + +* Create space for learning and mistakes +* Reduce anxiety through clear processes +* Support experimentation +* Celebrate incremental progress + +=== Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our +standards of acceptable behavior and will take appropriate and fair +corrective action in response to any behavior that they deem +inappropriate, threatening, offensive, or harmful. + +Community leaders have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other +contributions that are not aligned to this Code of Conduct, and will +communicate reasons for moderation decisions when appropriate. + +=== Scope + +This Code of Conduct applies within all community spaces, and also +applies when an individual is officially representing the community in +public spaces. Examples of representing our community include using an +official e-mail address, posting via an official social media account, +or acting as an appointed representative at an online or offline event. + +=== Enforcement + +==== Reporting + +Instances of abusive, harassing, or otherwise unacceptable behavior may +be reported to the community leaders responsible for enforcement at the +contact information listed in MAINTAINERS.md. + +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security +of the reporter of any incident. + +==== Process + +[arabic] +. *Report*: Submit to maintainers (see MAINTAINERS.md) +. *Acknowledgment*: Within 48 hours +. *Investigation*: Gather facts from all parties +. *Decision*: Within 7 days +. *Appeal*: Available within 14 days + +=== Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in +determining the consequences for any action they deem in violation of +this Code of Conduct: + +==== 1. Correction + +*Community Impact*: Use of inappropriate language or other behavior +deemed unprofessional or unwelcome in the community. + +*Consequence*: A private, written warning from community leaders, +providing clarity around the nature of the violation and an explanation +of why the behavior was inappropriate. A public apology may be +requested. + +==== 2. Warning + +*Community Impact*: A violation through a single incident or series of +actions. + +*Consequence*: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, for a specified period of +time. This includes avoiding interactions in community spaces as well as +external channels like social media. Violating these terms may lead to a +temporary or permanent ban. + +==== 3. Temporary Ban + +*Community Impact*: A serious violation of community standards, +including sustained inappropriate behavior. + +*Consequence*: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No +public or private interaction with the people involved, including +unsolicited interaction with those enforcing the Code of Conduct, is +allowed during this period. Violating these terms may lead to a +permanent ban. + +==== 4. Permanent Ban + +*Community Impact*: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of +individuals. + +*Consequence*: A permanent ban from any sort of public interaction +within the community. + +=== Attribution + +This Code of Conduct is adapted from: - +https://www.contributor-covenant.org[Contributor Covenant], version 2.1 +- Palimpsest License emotional safety principles - +https://www.rust-lang.org/policies/code-of-conduct[Rust Code of Conduct] + +=== Questions + +For questions about this Code of Conduct, contact maintainers listed in +MAINTAINERS.md. + +''''' + +*Remember*: Be kind, be respectful, and assume good intent. We’re all +here to build great software together. diff --git a/asdf-acceleration-middleware/CODE_OF_CONDUCT.md b/asdf-acceleration-middleware/CODE_OF_CONDUCT.md deleted file mode 100644 index a942c383..00000000 --- a/asdf-acceleration-middleware/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,126 +0,0 @@ -# Code of Conduct - -## Our Pledge - -We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation. - -We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. - -## Our Standards - -### Examples of behavior that contributes to a positive environment: - -- ✅ Demonstrating empathy and kindness toward other people -- ✅ Being respectful of differing opinions, viewpoints, and experiences -- ✅ Giving and gracefully accepting constructive feedback -- ✅ Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience -- ✅ Focusing on what is best not just for us as individuals, but for the overall community -- ✅ Using welcoming and inclusive language -- ✅ Respecting people's boundaries and privacy -- ✅ Assuming good intent - -### Examples of unacceptable behavior: - -- ❌ The use of sexualized language or imagery, and sexual attention or advances of any kind -- ❌ Trolling, insulting or derogatory comments, and personal or political attacks -- ❌ Public or private harassment -- ❌ Publishing others' private information, such as a physical or email address, without their explicit permission -- ❌ Other conduct which could reasonably be considered inappropriate in a professional setting -- ❌ Dismissing or attacking minority viewpoints -- ❌ Pattern of boundary violations - -## Emotional Safety (Palimpsest License Principles) - -In alignment with the Palimpsest License emotional safety clause: - -### Attribution and Recognition - -- Contributors maintain the right to have their work acknowledged -- No erasure of historical contributions -- Maintain visible chain of authorship -- Credit original ideas and implementations - -### Reversibility and Autonomy - -- Respect people's right to fork and maintain alternatives -- No lock-in or coercive practices -- Support migration and portability -- Welcome healthy competition - -### Psychological Safety - -- Create space for learning and mistakes -- Reduce anxiety through clear processes -- Support experimentation -- Celebrate incremental progress - -## Enforcement Responsibilities - -Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. - -Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. - -## Scope - -This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. - -## Enforcement - -### Reporting - -Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at the contact information listed in MAINTAINERS.md. - -All complaints will be reviewed and investigated promptly and fairly. - -All community leaders are obligated to respect the privacy and security of the reporter of any incident. - -### Process - -1. **Report**: Submit to maintainers (see MAINTAINERS.md) -2. **Acknowledgment**: Within 48 hours -3. **Investigation**: Gather facts from all parties -4. **Decision**: Within 7 days -5. **Appeal**: Available within 14 days - -## Enforcement Guidelines - -Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: - -### 1. Correction - -**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. - -**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. - -### 2. Warning - -**Community Impact**: A violation through a single incident or series of actions. - -**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. - -### 3. Temporary Ban - -**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior. - -**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. - -### 4. Permanent Ban - -**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. - -**Consequence**: A permanent ban from any sort of public interaction within the community. - -## Attribution - -This Code of Conduct is adapted from: -- [Contributor Covenant](https://www.contributor-covenant.org), version 2.1 -- Palimpsest License emotional safety principles -- [Rust Code of Conduct](https://www.rust-lang.org/policies/code-of-conduct) - -## Questions - -For questions about this Code of Conduct, contact maintainers listed in MAINTAINERS.md. - ---- - -**Remember**: Be kind, be respectful, and assume good intent. We're all here to build great software together. diff --git a/asdf-acceleration-middleware/CONTRIBUTING.adoc b/asdf-acceleration-middleware/CONTRIBUTING.adoc index eb045d61..084ee525 100644 --- a/asdf-acceleration-middleware/CONTRIBUTING.adoc +++ b/asdf-acceleration-middleware/CONTRIBUTING.adoc @@ -1,20 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-acceleration-middleware/CONTRIBUTING.md b/asdf-acceleration-middleware/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-acceleration-middleware/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-acceleration-middleware/MAINTAINERS.adoc b/asdf-acceleration-middleware/MAINTAINERS.adoc index 48d97817..35e1f390 100644 --- a/asdf-acceleration-middleware/MAINTAINERS.adoc +++ b/asdf-acceleration-middleware/MAINTAINERS.adoc @@ -1,47 +1,151 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Maintainers -:toc: preamble +== Maintainers -This document lists the maintainers of this project and their responsibilities. +This document lists the maintainers of the asdf-acceleration-middleware +project. -== Current Maintainers +=== Current Maintainers -[cols="2,3,2",options="header"] -|=== -| Name | Role | Contact +==== Core Team -| Jonathan D.A. Jewell -| Lead Maintainer -| https://github.com/hyperpolymath[@hyperpolymath] -|=== +*Lead Maintainer* - Role: Project leadership, architecture decisions, +release management - Responsibilities: Strategic direction, final +approval on major changes - Contact: See `+.well-known/security.txt+` -== Responsibilities +==== Responsibilities -Maintainers are responsible for: +===== All Maintainers -* Reviewing and merging pull requests -* Triaging issues and feature requests -* Ensuring code quality and security standards -* Managing releases and versioning -* Upholding the project's code of conduct +* Review and merge pull requests +* Triage issues +* Maintain code quality standards +* Ensure RSR compliance +* Respond to security reports +* Foster community growth +* Uphold Code of Conduct -== Becoming a Maintainer +===== Release Process -Contributors who demonstrate: +Maintainers coordinate releases following semantic versioning: -* Consistent, high-quality contributions -* Understanding of the project's goals and standards -* Constructive participation in discussions -* Commitment to the project's long-term health +[arabic] +. Version bump in `+Cargo.toml+` +. Update `+CHANGELOG.md+` +. Tag release: `+git tag -a v0.1.0 -m "Release v0.1.0"+` +. Push tag: `+git push origin v0.1.0+` +. Publish to crates.io: `+cargo publish+` +. Create GitHub release with notes -May be invited to become maintainers at the discretion of existing maintainers. +=== Becoming a Maintainer -== Decision Making +==== Path to Maintainership -* Routine decisions (bug fixes, minor improvements) can be made by any maintainer -* Significant changes require discussion and consensus among maintainers -* Breaking changes or major features should be discussed in issues before implementation +The project follows the TPCF (Tri-Perimeter Contribution Framework): -== Contact +*Perimeter 3 → Perimeter 2 → Perimeter 1* -For questions about project governance, open an issue or contact the maintainers listed above. +===== Perimeter 3: Community Sandbox (Current for new contributors) + +* Public contributions +* Code review required +* Fork/PR workflow + +===== Perimeter 2: Trusted Contributors + +* Consistent high-quality contributions +* Deep understanding of codebase +* Demonstrated adherence to Code of Conduct +* Nominated by existing maintainers +* Rights: Direct commit access to feature branches + +===== Perimeter 1: Core Maintainers + +* Extensive contribution history +* Architecture expertise +* Community leadership +* Nominated by Perimeter 1 maintainers +* Rights: Release authority, main branch access + +==== Criteria for Promotion + +*To Perimeter 2 (Trusted Contributor)*: - ✅ 10+ merged PRs - ✅ 6+ +months of consistent contributions - ✅ Code review participation - ✅ +Zero Code of Conduct violations - ✅ Demonstrated technical expertise + +*To Perimeter 1 (Core Maintainer)*: - ✅ 50+ merged PRs - ✅ 1+ year in +Perimeter 2 - ✅ Architecture contributions - ✅ Mentoring other +contributors - ✅ Community building + +==== Nomination Process + +[arabic] +. Self-nomination or nomination by existing maintainer +. Discussion among current Perimeter 1 maintainers +. Vote (requires 2/3 majority) +. Onboarding and access provisioning + +=== Emeritus Maintainers + +Maintainers who have stepped down are recognized here for their +contributions: + +(None yet) + +=== Contact + +* *GitHub*: https://github.com/Hyperpolymath[@Hyperpolymath] +* *Email*: See `+.well-known/security.txt+` +* *Discussions*: +https://github.com/Hyperpolymath/asdf-acceleration-middleware/discussions[GitHub +Discussions] + +=== Decision Making + +==== Consensus Model + +* *Small changes*: Any maintainer can approve +* *Moderate changes*: 2 maintainer approvals +* *Major changes*: Discussion + consensus of Perimeter 1 +* *Breaking changes*: RFC process + community input + +==== RFC Process + +For major architectural changes: + +[arabic] +. Create RFC document in `+docs/rfcs/+` +. Open discussion issue +. Gather feedback (minimum 2 weeks) +. Revise based on feedback +. Final decision by Perimeter 1 maintainers +. Implementation + +=== Conflict Resolution + +If conflicts arise: + +[arabic] +. *First*: Direct discussion between parties +. *Second*: Involve neutral maintainer as mediator +. *Third*: Escalate to full Perimeter 1 team +. *Last resort*: Code of Conduct enforcement + +=== Time Commitment + +Maintainers are expected to: - Review PRs within 3 days - Respond to +security issues within 48 hours - Participate in monthly maintainer +meetings - Be active in the community + +==== Stepping Down + +Maintainers may step down at any time: - Notify other maintainers - +Complete transition of responsibilities - Move to Emeritus status with +recognition + +=== Acknowledgments + +Thank you to all maintainers, past and present, for your dedication to +this project! + +''''' + +*Last Updated*: 2024-11-22 diff --git a/asdf-acceleration-middleware/MAINTAINERS.md b/asdf-acceleration-middleware/MAINTAINERS.md deleted file mode 100644 index b758c461..00000000 --- a/asdf-acceleration-middleware/MAINTAINERS.md +++ /dev/null @@ -1,149 +0,0 @@ -# Maintainers - -This document lists the maintainers of the asdf-acceleration-middleware project. - -## Current Maintainers - -### Core Team - -**Lead Maintainer** -- Role: Project leadership, architecture decisions, release management -- Responsibilities: Strategic direction, final approval on major changes -- Contact: See `.well-known/security.txt` - -### Responsibilities - -#### All Maintainers - -- Review and merge pull requests -- Triage issues -- Maintain code quality standards -- Ensure RSR compliance -- Respond to security reports -- Foster community growth -- Uphold Code of Conduct - -#### Release Process - -Maintainers coordinate releases following semantic versioning: - -1. Version bump in `Cargo.toml` -2. Update `CHANGELOG.md` -3. Tag release: `git tag -a v0.1.0 -m "Release v0.1.0"` -4. Push tag: `git push origin v0.1.0` -5. Publish to crates.io: `cargo publish` -6. Create GitHub release with notes - -## Becoming a Maintainer - -### Path to Maintainership - -The project follows the TPCF (Tri-Perimeter Contribution Framework): - -**Perimeter 3 → Perimeter 2 → Perimeter 1** - -#### Perimeter 3: Community Sandbox (Current for new contributors) -- Public contributions -- Code review required -- Fork/PR workflow - -#### Perimeter 2: Trusted Contributors -- Consistent high-quality contributions -- Deep understanding of codebase -- Demonstrated adherence to Code of Conduct -- Nominated by existing maintainers -- Rights: Direct commit access to feature branches - -#### Perimeter 1: Core Maintainers -- Extensive contribution history -- Architecture expertise -- Community leadership -- Nominated by Perimeter 1 maintainers -- Rights: Release authority, main branch access - -### Criteria for Promotion - -**To Perimeter 2 (Trusted Contributor)**: -- ✅ 10+ merged PRs -- ✅ 6+ months of consistent contributions -- ✅ Code review participation -- ✅ Zero Code of Conduct violations -- ✅ Demonstrated technical expertise - -**To Perimeter 1 (Core Maintainer)**: -- ✅ 50+ merged PRs -- ✅ 1+ year in Perimeter 2 -- ✅ Architecture contributions -- ✅ Mentoring other contributors -- ✅ Community building - -### Nomination Process - -1. Self-nomination or nomination by existing maintainer -2. Discussion among current Perimeter 1 maintainers -3. Vote (requires 2/3 majority) -4. Onboarding and access provisioning - -## Emeritus Maintainers - -Maintainers who have stepped down are recognized here for their contributions: - -(None yet) - -## Contact - -- **GitHub**: [@Hyperpolymath](https://github.com/Hyperpolymath) -- **Email**: See `.well-known/security.txt` -- **Discussions**: [GitHub Discussions](https://github.com/Hyperpolymath/asdf-acceleration-middleware/discussions) - -## Decision Making - -### Consensus Model - -- **Small changes**: Any maintainer can approve -- **Moderate changes**: 2 maintainer approvals -- **Major changes**: Discussion + consensus of Perimeter 1 -- **Breaking changes**: RFC process + community input - -### RFC Process - -For major architectural changes: - -1. Create RFC document in `docs/rfcs/` -2. Open discussion issue -3. Gather feedback (minimum 2 weeks) -4. Revise based on feedback -5. Final decision by Perimeter 1 maintainers -6. Implementation - -## Conflict Resolution - -If conflicts arise: - -1. **First**: Direct discussion between parties -2. **Second**: Involve neutral maintainer as mediator -3. **Third**: Escalate to full Perimeter 1 team -4. **Last resort**: Code of Conduct enforcement - -## Time Commitment - -Maintainers are expected to: -- Review PRs within 3 days -- Respond to security issues within 48 hours -- Participate in monthly maintainer meetings -- Be active in the community - -### Stepping Down - -Maintainers may step down at any time: -- Notify other maintainers -- Complete transition of responsibilities -- Move to Emeritus status with recognition - -## Acknowledgments - -Thank you to all maintainers, past and present, for your dedication to this project! - ---- - -**Last Updated**: 2024-11-22 diff --git a/asdf-acceleration-middleware/SECURITY.adoc b/asdf-acceleration-middleware/SECURITY.adoc new file mode 100644 index 00000000..ecaed205 --- /dev/null +++ b/asdf-acceleration-middleware/SECURITY.adoc @@ -0,0 +1,177 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|0.1.x |:white_check_mark: +|=== + +=== Reporting a Vulnerability + +*Please DO NOT report security vulnerabilities through public GitHub +issues.* + +==== Reporting Process + +[arabic] +. *Email*: Send details to security contact listed in +`+.well-known/security.txt+` +. *Encryption*: Use PGP key if available (see +`+.well-known/security.txt+`) +. *Information*: Include: +* Description of the vulnerability +* Steps to reproduce +* Potential impact +* Suggested fix (if any) + +==== Response Timeline + +* *Initial Response*: Within 48 hours +* *Status Update*: Within 7 days +* *Fix Timeline*: Depends on severity +** Critical: 7 days +** High: 14 days +** Medium: 30 days +** Low: 90 days + +==== Disclosure Policy + +* We follow *responsible disclosure* practices +* Security advisories will be published after: +** Fix is available +** Users have had time to update (typically 7-14 days) +** Coordination with affected parties + +==== Security Best Practices + +===== For Users + +[arabic] +. *Keep Updated*: Always use the latest version +. *Verify Downloads*: Check signatures and checksums +. *Review Permissions*: Understand what access the tool requires +. *Audit Configurations*: Review generated configs before use +. *Report Issues*: Help us identify vulnerabilities + +===== For Contributors + +[arabic] +. *Input Validation*: Always validate external input +. *Avoid Shell Injection*: Use safe subprocess APIs (duct) +. *No Unsafe Rust*: Avoid `+unsafe+` blocks unless absolutely necessary +. *Dependency Audits*: Run `+cargo audit+` regularly +. *Secrets Management*: Never commit secrets or credentials +. *Code Review*: All changes require review + +==== Security Features + +===== Built-In Security + +* ✅ *Type Safety*: Rust compile-time guarantees +* ✅ *Memory Safety*: No buffer overflows, use-after-free +* ✅ *Safe Subprocess*: `+duct+` for shell command execution +* ✅ *Input Validation*: Strict parsing and validation +* ✅ *Audit Logging*: Track all operations +* ✅ *SELinux Support*: Context-aware security + +===== Security Checks + +[source,bash] +---- +# Run security audit +cargo audit + +# Check for unsafe code +cargo geiger + +# Dependency tree +cargo tree + +# License compliance +cargo license +---- + +==== Known Security Considerations + +===== 1. Shell Command Execution + +The tool executes `+asdf+` commands via subprocess. Mitigations: - Input +sanitization - No shell interpolation - Allowlist of valid commands - +Audit logging + +===== 2. Filesystem Access + +Requires read/write to: - `+~/.asdf/+` directory - Cache directory - +Configuration files + +Mitigations: - Path validation - No symbolic link following - Permission +checks + +===== 3. Cache Poisoning + +Cache could be manipulated. Mitigations: - Integrity verification - TTL +enforcement - Cache validation - Secure permissions (0600) + +===== 4. Dependency Chain + +Rust dependencies could introduce vulnerabilities. Mitigations: - +`+cargo audit+` in CI - Minimal dependency footprint - Regular updates - +Review of dependency changes + +==== Security Tooling + +[source,bash] +---- +# Audit dependencies +just audit + +# Check for unsafe code +just security-check + +# Verify RSR compliance +just rsr-verify + +# Run all security checks +just security-full +---- + +==== Threat Model + +===== In Scope + +* Command injection via asdf arguments +* Path traversal attacks +* Cache poisoning +* Dependency vulnerabilities +* Denial of service (resource exhaustion) + +===== Out of Scope + +* Vulnerabilities in asdf itself +* OS-level exploits +* Social engineering +* Physical access attacks + +==== Security Contacts + +See `+.well-known/security.txt+` for current contact information. + +==== Security Hall of Fame + +We acknowledge security researchers who responsibly disclose +vulnerabilities: + +(None yet - be the first!) + +==== References + +* https://owasp.org/www-project-top-ten/[OWASP Top 10] +* https://anssi-fr.github.io/rust-guide/[Rust Security Guidelines] +* https://www.rfc-editor.org/rfc/rfc9116.html[RFC 9116: security.txt] +* https://cwe.mitre.org/top25/[CWE Top 25] + +''''' + +*Last Updated*: 2024-11-22 diff --git a/asdf-acceleration-middleware/SECURITY.md b/asdf-acceleration-middleware/SECURITY.md deleted file mode 100644 index 4742a6dc..00000000 --- a/asdf-acceleration-middleware/SECURITY.md +++ /dev/null @@ -1,177 +0,0 @@ -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| 0.1.x | :white_check_mark: | - -## Reporting a Vulnerability - -**Please DO NOT report security vulnerabilities through public GitHub issues.** - -### Reporting Process - -1. **Email**: Send details to security contact listed in `.well-known/security.txt` -2. **Encryption**: Use PGP key if available (see `.well-known/security.txt`) -3. **Information**: Include: - - Description of the vulnerability - - Steps to reproduce - - Potential impact - - Suggested fix (if any) - -### Response Timeline - -- **Initial Response**: Within 48 hours -- **Status Update**: Within 7 days -- **Fix Timeline**: Depends on severity - - Critical: 7 days - - High: 14 days - - Medium: 30 days - - Low: 90 days - -### Disclosure Policy - -- We follow **responsible disclosure** practices -- Security advisories will be published after: - - Fix is available - - Users have had time to update (typically 7-14 days) - - Coordination with affected parties - -### Security Best Practices - -#### For Users - -1. **Keep Updated**: Always use the latest version -2. **Verify Downloads**: Check signatures and checksums -3. **Review Permissions**: Understand what access the tool requires -4. **Audit Configurations**: Review generated configs before use -5. **Report Issues**: Help us identify vulnerabilities - -#### For Contributors - -1. **Input Validation**: Always validate external input -2. **Avoid Shell Injection**: Use safe subprocess APIs (duct) -3. **No Unsafe Rust**: Avoid `unsafe` blocks unless absolutely necessary -4. **Dependency Audits**: Run `cargo audit` regularly -5. **Secrets Management**: Never commit secrets or credentials -6. **Code Review**: All changes require review - -### Security Features - -#### Built-In Security - -- ✅ **Type Safety**: Rust compile-time guarantees -- ✅ **Memory Safety**: No buffer overflows, use-after-free -- ✅ **Safe Subprocess**: `duct` for shell command execution -- ✅ **Input Validation**: Strict parsing and validation -- ✅ **Audit Logging**: Track all operations -- ✅ **SELinux Support**: Context-aware security - -#### Security Checks - -```bash -# Run security audit -cargo audit - -# Check for unsafe code -cargo geiger - -# Dependency tree -cargo tree - -# License compliance -cargo license -``` - -### Known Security Considerations - -#### 1. Shell Command Execution - -The tool executes `asdf` commands via subprocess. Mitigations: -- Input sanitization -- No shell interpolation -- Allowlist of valid commands -- Audit logging - -#### 2. Filesystem Access - -Requires read/write to: -- `~/.asdf/` directory -- Cache directory -- Configuration files - -Mitigations: -- Path validation -- No symbolic link following -- Permission checks - -#### 3. Cache Poisoning - -Cache could be manipulated. Mitigations: -- Integrity verification -- TTL enforcement -- Cache validation -- Secure permissions (0600) - -#### 4. Dependency Chain - -Rust dependencies could introduce vulnerabilities. Mitigations: -- `cargo audit` in CI -- Minimal dependency footprint -- Regular updates -- Review of dependency changes - -### Security Tooling - -```bash -# Audit dependencies -just audit - -# Check for unsafe code -just security-check - -# Verify RSR compliance -just rsr-verify - -# Run all security checks -just security-full -``` - -### Threat Model - -#### In Scope - -- Command injection via asdf arguments -- Path traversal attacks -- Cache poisoning -- Dependency vulnerabilities -- Denial of service (resource exhaustion) - -#### Out of Scope - -- Vulnerabilities in asdf itself -- OS-level exploits -- Social engineering -- Physical access attacks - -### Security Contacts - -See `.well-known/security.txt` for current contact information. - -### Security Hall of Fame - -We acknowledge security researchers who responsibly disclose vulnerabilities: - -(None yet - be the first!) - -### References - -- [OWASP Top 10](https://owasp.org/www-project-top-ten/) -- [Rust Security Guidelines](https://anssi-fr.github.io/rust-guide/) -- [RFC 9116: security.txt](https://www.rfc-editor.org/rfc/rfc9116.html) -- [CWE Top 25](https://cwe.mitre.org/top25/) - ---- - -**Last Updated**: 2024-11-22 diff --git a/asdf-acceleration-middleware/docs/ARCHITECTURE.adoc b/asdf-acceleration-middleware/docs/ARCHITECTURE.adoc new file mode 100644 index 00000000..9f9a14bb --- /dev/null +++ b/asdf-acceleration-middleware/docs/ARCHITECTURE.adoc @@ -0,0 +1,299 @@ +== Architecture + +=== Overview + +asdf-acceleration-middleware is built as a modular Rust workspace with +separation of concerns across multiple crates. + +=== Crate Structure + +==== Library Crates + +===== asdf-core + +*Purpose*: Core abstractions for asdf integration + +*Responsibilities*: - Type-safe wrappers around asdf operations - Plugin +management - Runtime version management - Semantic version parsing + +*Key Types*: - `+Plugin+`: Represents an asdf plugin - `+Runtime+`: +Represents an installed runtime version - `+Version+`: Semantic version +with parsing and comparison + +===== asdf-cache + +*Purpose*: Multi-level caching system + +*Architecture*: + +.... +L1 (Memory) → L2 (Disk) → Source + LRU Cache Sled DB asdf +.... + +*Components*: - `+MemoryCache+`: In-memory LRU cache for hot data - +`+DiskCache+`: Sled embedded database for persistence - +`+CacheManager+`: Coordinator managing both levels + +*Performance*: O(1) average for L1 hits, O(log n) for L2 + +===== asdf-parallel + +*Purpose*: Parallel execution engine using Rayon + +*Features*: - Multiple execution strategies (sequential, auto, fixed, +max) - Fail-fast or collect-all error handling - Retry logic with +configurable attempts - Progress tracking integration + +*Key Types*: - `+Executor+`: Main parallel execution coordinator - +`+Strategy+`: Execution strategy enumeration - `+ExecutorConfig+`: +Configuration for execution behavior + +===== asdf-config + +*Purpose*: Configuration management + +*Features*: - Multiple format support (TOML, JSON, Nickel) - Environment +variable overrides - Hierarchical configuration loading - Type-safe +schema with validation + +*Loading Priority*: 1. Environment variables (highest) 2. Config file 3. +Defaults (lowest) + +===== asdf-metrics + +*Purpose*: Metrics collection and reporting + +*Features*: - Operation timing and counting - Success/failure rate +tracking - System resource monitoring - Multiple export formats (text, +JSON, Prometheus) + +==== CLI Crates + +===== asdf-accelerate + +*Purpose*: Main CLI tool for accelerating asdf operations + +*Commands*: - `+update+`: Update plugins in parallel - `+install+`: +Install runtimes with acceleration - `+sync+`: Sync plugin repositories +- `+list+`: List plugins with formatting options - `+cache+`: Manage +cache (clear, stats) + +*Architecture*: + +.... +CLI → Commands → Libraries + ↓ + Executor → asdf-core + ↓ + Progress Bar + ↓ + Metrics +.... + +===== asdf-bench + +*Purpose*: Benchmarking tool + +*Features*: - Operation timing - Baseline comparisons - Multiple output +formats - Performance profiling + +===== asdf-discover + +*Purpose*: Auto-discovery of runtimes + +*Features*: - System scanning for installed runtimes - Configuration +generation (Nickel, JSON, TOML) - Setup validation + +*Use Cases*: - Onboarding new systems - Generating `+.tool-versions+` +equivalents - Auditing installed runtimes + +===== asdf-monitor + +*Purpose*: Monitoring and health checking + +*Features*: - Real-time metrics dashboard (planned TUI) - Health checks +- Prometheus metrics export - System resource monitoring + +=== Data Flow + +==== Plugin Update Flow + +.... +User Command + ↓ +asdf-accelerate + ↓ +Load Config + ↓ +Query Plugins (asdf-core) + ↓ +Check Cache (asdf-cache) + ├─ Hit → Return cached + └─ Miss → Fetch from asdf + ↓ + Update Plugins (asdf-parallel) + ├─ Executor spawns threads + ├─ Each thread updates plugin + └─ Collect results + ↓ +Update Cache + ↓ +Report Metrics +.... + +==== Caching Strategy + +.... +Get Plugin Info + ↓ +Check L1 (Memory LRU) + ├─ Hit → Return (fast path) + └─ Miss + ↓ + Check L2 (Disk Sled) + ├─ Hit → Promote to L1 → Return + └─ Miss + ↓ + Fetch from asdf + ↓ + Store in L2 and L1 + ↓ + Return +.... + +=== Performance Targets + +==== Benchmarks + +[width="100%",cols="20%,23%,17%,20%,20%",options="header",] +|=== +|Operation |Baseline (bash) |Sequential |Parallel (4) |Parallel (8) +|Plugin Update |100s |40s (2.5x) |13s (7.7x) |9s (11x) +|Plugin List |5s |2s (2.5x) |0.8s (6.2x) |0.5s (10x) +|=== + +==== Memory Usage + +* L1 Cache: ~10MB (1000 entries) +* L2 Cache: ~100MB (typical) +* Total: <150MB resident + +==== Scalability + +* *Plugins*: Tested with 50+ plugins +* *Parallel Jobs*: Scales to CPU count +* *Cache Size*: Handles 10k+ entries + +=== Security Considerations + +==== Input Validation + +* All external input sanitized +* No shell interpolation +* Path traversal prevention + +==== Cache Security + +* Cache files: 0600 permissions +* Integrity verification on load +* TTL enforcement + +==== Subprocess Execution + +* Uses `+duct+` for safe subprocess management +* No shell=true +* Argument array passing (no string interpolation) + +=== Error Handling + +==== Strategy + +* Type-safe errors with `+thiserror+` +* Context preservation with `+anyhow+` +* Graceful degradation when possible + +==== Error Types + +[arabic] +. *Recoverable*: Retry with backoff +. *User Errors*: Clear messages and suggestions +. *System Errors*: Detailed context for debugging + +=== Testing Strategy + +==== Unit Tests + +* Each crate has `+#[cfg(test)]+` modules +* Test coverage target: >80% +* Property-based testing for parsers + +==== Integration Tests + +* Cross-crate integration +* End-to-end CLI testing with `+assert_cmd+` +* Fixture-based testing + +==== Benchmarks + +* Criterion-based performance tests +* Regression detection +* Profiling integration + +=== Future Architecture + +==== Planned Enhancements + +[arabic] +. *Async I/O*: Tokio integration for I/O-bound operations +. *Plugin System*: Dynamic plugin loading +. *Distributed Caching*: Redis backend option +. *Web Dashboard*: Browser-based monitoring +. *gRPC API*: Programmatic access + +==== Nickel Integration (Phase 2) + +* Type-safe configuration generation +* Contract-based validation +* Smart defaults with overrides + +=== RSR Compliance + +==== Type Safety + +* Zero `+unsafe+` blocks in core libraries +* Compile-time guarantees via Rust type system +* Newtype pattern for semantic clarity + +==== Memory Safety + +* Ownership model prevents use-after-free +* No buffer overflows +* RAII for resource management + +==== Offline-First + +* No mandatory network calls +* All data cached locally +* Graceful handling of offline mode + +=== Dependencies + +==== Philosophy + +* Minimal but powerful +* Well-maintained crates only +* Regular `+cargo audit+` checks +* Security-first selection + +==== Key Dependencies + +* *rayon*: Data parallelism +* *sled*: Embedded database +* *clap*: CLI parsing +* *serde*: Serialization +* *duct*: Subprocess management + +''''' + +*Last Updated*: 2024-11-22 diff --git a/asdf-acceleration-middleware/docs/ARCHITECTURE.md b/asdf-acceleration-middleware/docs/ARCHITECTURE.md deleted file mode 100644 index 3a61a7fe..00000000 --- a/asdf-acceleration-middleware/docs/ARCHITECTURE.md +++ /dev/null @@ -1,309 +0,0 @@ -# Architecture - -## Overview - -asdf-acceleration-middleware is built as a modular Rust workspace with separation of concerns across multiple crates. - -## Crate Structure - -### Library Crates - -#### asdf-core -**Purpose**: Core abstractions for asdf integration - -**Responsibilities**: -- Type-safe wrappers around asdf operations -- Plugin management -- Runtime version management -- Semantic version parsing - -**Key Types**: -- `Plugin`: Represents an asdf plugin -- `Runtime`: Represents an installed runtime version -- `Version`: Semantic version with parsing and comparison - -#### asdf-cache -**Purpose**: Multi-level caching system - -**Architecture**: -``` -L1 (Memory) → L2 (Disk) → Source - LRU Cache Sled DB asdf -``` - -**Components**: -- `MemoryCache`: In-memory LRU cache for hot data -- `DiskCache`: Sled embedded database for persistence -- `CacheManager`: Coordinator managing both levels - -**Performance**: O(1) average for L1 hits, O(log n) for L2 - -#### asdf-parallel -**Purpose**: Parallel execution engine using Rayon - -**Features**: -- Multiple execution strategies (sequential, auto, fixed, max) -- Fail-fast or collect-all error handling -- Retry logic with configurable attempts -- Progress tracking integration - -**Key Types**: -- `Executor`: Main parallel execution coordinator -- `Strategy`: Execution strategy enumeration -- `ExecutorConfig`: Configuration for execution behavior - -#### asdf-config -**Purpose**: Configuration management - -**Features**: -- Multiple format support (TOML, JSON, Nickel) -- Environment variable overrides -- Hierarchical configuration loading -- Type-safe schema with validation - -**Loading Priority**: -1. Environment variables (highest) -2. Config file -3. Defaults (lowest) - -#### asdf-metrics -**Purpose**: Metrics collection and reporting - -**Features**: -- Operation timing and counting -- Success/failure rate tracking -- System resource monitoring -- Multiple export formats (text, JSON, Prometheus) - -### CLI Crates - -#### asdf-accelerate -**Purpose**: Main CLI tool for accelerating asdf operations - -**Commands**: -- `update`: Update plugins in parallel -- `install`: Install runtimes with acceleration -- `sync`: Sync plugin repositories -- `list`: List plugins with formatting options -- `cache`: Manage cache (clear, stats) - -**Architecture**: -``` -CLI → Commands → Libraries - ↓ - Executor → asdf-core - ↓ - Progress Bar - ↓ - Metrics -``` - -#### asdf-bench -**Purpose**: Benchmarking tool - -**Features**: -- Operation timing -- Baseline comparisons -- Multiple output formats -- Performance profiling - -#### asdf-discover -**Purpose**: Auto-discovery of runtimes - -**Features**: -- System scanning for installed runtimes -- Configuration generation (Nickel, JSON, TOML) -- Setup validation - -**Use Cases**: -- Onboarding new systems -- Generating `.tool-versions` equivalents -- Auditing installed runtimes - -#### asdf-monitor -**Purpose**: Monitoring and health checking - -**Features**: -- Real-time metrics dashboard (planned TUI) -- Health checks -- Prometheus metrics export -- System resource monitoring - -## Data Flow - -### Plugin Update Flow - -``` -User Command - ↓ -asdf-accelerate - ↓ -Load Config - ↓ -Query Plugins (asdf-core) - ↓ -Check Cache (asdf-cache) - ├─ Hit → Return cached - └─ Miss → Fetch from asdf - ↓ - Update Plugins (asdf-parallel) - ├─ Executor spawns threads - ├─ Each thread updates plugin - └─ Collect results - ↓ -Update Cache - ↓ -Report Metrics -``` - -### Caching Strategy - -``` -Get Plugin Info - ↓ -Check L1 (Memory LRU) - ├─ Hit → Return (fast path) - └─ Miss - ↓ - Check L2 (Disk Sled) - ├─ Hit → Promote to L1 → Return - └─ Miss - ↓ - Fetch from asdf - ↓ - Store in L2 and L1 - ↓ - Return -``` - -## Performance Targets - -### Benchmarks - -| Operation | Baseline (bash) | Sequential | Parallel (4) | Parallel (8) | -|-----------|----------------|------------|--------------|--------------| -| Plugin Update | 100s | 40s (2.5x) | 13s (7.7x) | 9s (11x) | -| Plugin List | 5s | 2s (2.5x) | 0.8s (6.2x) | 0.5s (10x) | - -### Memory Usage - -- L1 Cache: ~10MB (1000 entries) -- L2 Cache: ~100MB (typical) -- Total: <150MB resident - -### Scalability - -- **Plugins**: Tested with 50+ plugins -- **Parallel Jobs**: Scales to CPU count -- **Cache Size**: Handles 10k+ entries - -## Security Considerations - -### Input Validation - -- All external input sanitized -- No shell interpolation -- Path traversal prevention - -### Cache Security - -- Cache files: 0600 permissions -- Integrity verification on load -- TTL enforcement - -### Subprocess Execution - -- Uses `duct` for safe subprocess management -- No shell=true -- Argument array passing (no string interpolation) - -## Error Handling - -### Strategy - -- Type-safe errors with `thiserror` -- Context preservation with `anyhow` -- Graceful degradation when possible - -### Error Types - -1. **Recoverable**: Retry with backoff -2. **User Errors**: Clear messages and suggestions -3. **System Errors**: Detailed context for debugging - -## Testing Strategy - -### Unit Tests - -- Each crate has `#[cfg(test)]` modules -- Test coverage target: >80% -- Property-based testing for parsers - -### Integration Tests - -- Cross-crate integration -- End-to-end CLI testing with `assert_cmd` -- Fixture-based testing - -### Benchmarks - -- Criterion-based performance tests -- Regression detection -- Profiling integration - -## Future Architecture - -### Planned Enhancements - -1. **Async I/O**: Tokio integration for I/O-bound operations -2. **Plugin System**: Dynamic plugin loading -3. **Distributed Caching**: Redis backend option -4. **Web Dashboard**: Browser-based monitoring -5. **gRPC API**: Programmatic access - -### Nickel Integration (Phase 2) - -- Type-safe configuration generation -- Contract-based validation -- Smart defaults with overrides - -## RSR Compliance - -### Type Safety - -- Zero `unsafe` blocks in core libraries -- Compile-time guarantees via Rust type system -- Newtype pattern for semantic clarity - -### Memory Safety - -- Ownership model prevents use-after-free -- No buffer overflows -- RAII for resource management - -### Offline-First - -- No mandatory network calls -- All data cached locally -- Graceful handling of offline mode - -## Dependencies - -### Philosophy - -- Minimal but powerful -- Well-maintained crates only -- Regular `cargo audit` checks -- Security-first selection - -### Key Dependencies - -- **rayon**: Data parallelism -- **sled**: Embedded database -- **clap**: CLI parsing -- **serde**: Serialization -- **duct**: Subprocess management - ---- - -**Last Updated**: 2024-11-22 diff --git a/asdf-acceleration-middleware/docs/QUICKSTART.adoc b/asdf-acceleration-middleware/docs/QUICKSTART.adoc new file mode 100644 index 00000000..dff8f252 --- /dev/null +++ b/asdf-acceleration-middleware/docs/QUICKSTART.adoc @@ -0,0 +1,287 @@ +== Quick Start Guide + +Get started with asdf-acceleration-middleware in 5 minutes. + +=== Prerequisites + +* Rust 1.70.0 or later +* asdf version manager installed +* Git + +=== Installation + +==== From Source + +[source,bash] +---- +# Clone the repository +git clone https://github.com/Hyperpolymath/asdf-acceleration-middleware +cd asdf-acceleration-middleware + +# Build and install +cargo install --path crates/asdf-accelerate +cargo install --path crates/asdf-bench +cargo install --path crates/asdf-discover +cargo install --path crates/asdf-monitor + +# Or use just +just install +---- + +==== Using Cargo + +[source,bash] +---- +cargo install asdf-accelerate +cargo install asdf-bench +cargo install asdf-discover +cargo install asdf-monitor +---- + +=== Basic Usage + +==== Update Plugins + +[source,bash] +---- +# Update all plugins in parallel +asdf-accelerate update --all --jobs 8 + +# Update specific plugins +asdf-accelerate update nodejs ruby python + +# Exclude certain plugins +asdf-accelerate update --all --exclude rust golang +---- + +==== Install Runtimes + +[source,bash] +---- +# Install single runtime +asdf-accelerate install nodejs@20.0.0 + +# Install multiple runtimes in parallel +asdf-accelerate install nodejs@20.0.0 ruby@3.2.0 --parallel +---- + +==== List Plugins + +[source,bash] +---- +# List all plugins +asdf-accelerate list + +# List with URLs +asdf-accelerate list --urls + +# JSON output +asdf-accelerate list --format json +---- + +==== Cache Management + +[source,bash] +---- +# Show cache statistics +asdf-accelerate cache --stats + +# Clear cache +asdf-accelerate cache --clear +---- + +==== Benchmarking + +[source,bash] +---- +# Run benchmarks +asdf-bench --all + +# Generate HTML report +asdf-bench --all --format html --output benchmark.html +---- + +==== Discovery + +[source,bash] +---- +# Scan system for runtimes +asdf-discover scan + +# Generate Nickel configuration +asdf-discover generate --format nickel --output asdf-config.ncl + +# Validate setup +asdf-discover validate +---- + +==== Monitoring + +[source,bash] +---- +# Health check +asdf-monitor health + +# Export metrics +asdf-monitor metrics --format json + +# Launch dashboard +asdf-monitor dashboard +---- + +=== Configuration + +==== Create Configuration File + +[source,bash] +---- +# Copy example configuration +cp examples/config.toml ~/.config/asdf-acceleration/config.toml + +# Edit as needed +$EDITOR ~/.config/asdf-acceleration/config.toml +---- + +==== Example Configuration + +[source,toml] +---- +[cache] +enabled = true +ttl_secs = 3600 +max_size_mb = 500 + +[parallel] +strategy = "auto" +fail_fast = false + +[notifications] +enabled = true +level = "errors_only" + +[plugins] +exclude = [] +auto_update = true +---- + +==== Environment Variables + +Override configuration with environment variables: + +[source,bash] +---- +# Set cache TTL +export ASDF_ACCEL__CACHE__TTL_SECS=7200 + +# Set parallel jobs +export ASDF_ACCEL__PARALLEL__MAX_JOBS=4 + +# Disable notifications +export ASDF_ACCEL__NOTIFICATIONS__ENABLED=false +---- + +=== Common Workflows + +==== Daily Update Routine + +[source,bash] +---- +# Morning routine: update all plugins +asdf-accelerate update --all --jobs 8 + +# Check for new versions +asdf-discover scan +---- + +==== Setting Up New Machine + +[source,bash] +---- +# Validate asdf installation +asdf-discover validate + +# Scan existing runtimes +asdf-discover scan --deep + +# Generate configuration +asdf-discover generate --format nickel > asdf-config.ncl +---- + +==== Performance Optimization + +[source,bash] +---- +# Benchmark current performance +asdf-bench --all + +# Clear cache to free space +asdf-accelerate cache --clear + +# Monitor system resources +asdf-monitor health +---- + +=== Performance Tips + +[arabic] +. *Use parallel jobs*: `+--jobs 8+` can speed up operations 7-11x +. *Enable caching*: Reduces redundant asdf calls +. *Background mode*: Run long operations in background +. *Exclude inactive plugins*: Faster updates + +=== Troubleshooting + +==== asdf not found + +[source,bash] +---- +# Ensure asdf is in PATH +which asdf + +# Or set ASDF_DIR +export ASDF_DIR=$HOME/.asdf +---- + +==== Cache issues + +[source,bash] +---- +# Clear cache +asdf-accelerate cache --clear + +# Check cache location +asdf-accelerate cache --stats +---- + +==== Permission errors + +[source,bash] +---- +# Check cache directory permissions +ls -la ~/.cache/asdf-acceleration + +# Fix if needed +chmod 700 ~/.cache/asdf-acceleration +---- + +=== Next Steps + +* Read link:ARCHITECTURE.md[Architecture Documentation] +* Review link:../CONTRIBUTING.md[Contributing Guidelines] +* Explore link:../examples/[Example Configurations] +* Join +https://github.com/Hyperpolymath/asdf-acceleration-middleware/discussions[Discussions] + +=== Getting Help + +* 📖 link:README.md[Full Documentation] +* 🐛 +https://github.com/Hyperpolymath/asdf-acceleration-middleware/issues[Report +Issues] +* 💬 +https://github.com/Hyperpolymath/asdf-acceleration-middleware/discussions[Ask +Questions] + +''''' + +*Happy accelerating!* 🚀 diff --git a/asdf-acceleration-middleware/docs/QUICKSTART.md b/asdf-acceleration-middleware/docs/QUICKSTART.md deleted file mode 100644 index 801208b4..00000000 --- a/asdf-acceleration-middleware/docs/QUICKSTART.md +++ /dev/null @@ -1,263 +0,0 @@ -# Quick Start Guide - -Get started with asdf-acceleration-middleware in 5 minutes. - -## Prerequisites - -- Rust 1.70.0 or later -- asdf version manager installed -- Git - -## Installation - -### From Source - -```bash -# Clone the repository -git clone https://github.com/Hyperpolymath/asdf-acceleration-middleware -cd asdf-acceleration-middleware - -# Build and install -cargo install --path crates/asdf-accelerate -cargo install --path crates/asdf-bench -cargo install --path crates/asdf-discover -cargo install --path crates/asdf-monitor - -# Or use just -just install -``` - -### Using Cargo - -```bash -cargo install asdf-accelerate -cargo install asdf-bench -cargo install asdf-discover -cargo install asdf-monitor -``` - -## Basic Usage - -### Update Plugins - -```bash -# Update all plugins in parallel -asdf-accelerate update --all --jobs 8 - -# Update specific plugins -asdf-accelerate update nodejs ruby python - -# Exclude certain plugins -asdf-accelerate update --all --exclude rust golang -``` - -### Install Runtimes - -```bash -# Install single runtime -asdf-accelerate install nodejs@20.0.0 - -# Install multiple runtimes in parallel -asdf-accelerate install nodejs@20.0.0 ruby@3.2.0 --parallel -``` - -### List Plugins - -```bash -# List all plugins -asdf-accelerate list - -# List with URLs -asdf-accelerate list --urls - -# JSON output -asdf-accelerate list --format json -``` - -### Cache Management - -```bash -# Show cache statistics -asdf-accelerate cache --stats - -# Clear cache -asdf-accelerate cache --clear -``` - -### Benchmarking - -```bash -# Run benchmarks -asdf-bench --all - -# Generate HTML report -asdf-bench --all --format html --output benchmark.html -``` - -### Discovery - -```bash -# Scan system for runtimes -asdf-discover scan - -# Generate Nickel configuration -asdf-discover generate --format nickel --output asdf-config.ncl - -# Validate setup -asdf-discover validate -``` - -### Monitoring - -```bash -# Health check -asdf-monitor health - -# Export metrics -asdf-monitor metrics --format json - -# Launch dashboard -asdf-monitor dashboard -``` - -## Configuration - -### Create Configuration File - -```bash -# Copy example configuration -cp examples/config.toml ~/.config/asdf-acceleration/config.toml - -# Edit as needed -$EDITOR ~/.config/asdf-acceleration/config.toml -``` - -### Example Configuration - -```toml -[cache] -enabled = true -ttl_secs = 3600 -max_size_mb = 500 - -[parallel] -strategy = "auto" -fail_fast = false - -[notifications] -enabled = true -level = "errors_only" - -[plugins] -exclude = [] -auto_update = true -``` - -### Environment Variables - -Override configuration with environment variables: - -```bash -# Set cache TTL -export ASDF_ACCEL__CACHE__TTL_SECS=7200 - -# Set parallel jobs -export ASDF_ACCEL__PARALLEL__MAX_JOBS=4 - -# Disable notifications -export ASDF_ACCEL__NOTIFICATIONS__ENABLED=false -``` - -## Common Workflows - -### Daily Update Routine - -```bash -# Morning routine: update all plugins -asdf-accelerate update --all --jobs 8 - -# Check for new versions -asdf-discover scan -``` - -### Setting Up New Machine - -```bash -# Validate asdf installation -asdf-discover validate - -# Scan existing runtimes -asdf-discover scan --deep - -# Generate configuration -asdf-discover generate --format nickel > asdf-config.ncl -``` - -### Performance Optimization - -```bash -# Benchmark current performance -asdf-bench --all - -# Clear cache to free space -asdf-accelerate cache --clear - -# Monitor system resources -asdf-monitor health -``` - -## Performance Tips - -1. **Use parallel jobs**: `--jobs 8` can speed up operations 7-11x -2. **Enable caching**: Reduces redundant asdf calls -3. **Background mode**: Run long operations in background -4. **Exclude inactive plugins**: Faster updates - -## Troubleshooting - -### asdf not found - -```bash -# Ensure asdf is in PATH -which asdf - -# Or set ASDF_DIR -export ASDF_DIR=$HOME/.asdf -``` - -### Cache issues - -```bash -# Clear cache -asdf-accelerate cache --clear - -# Check cache location -asdf-accelerate cache --stats -``` - -### Permission errors - -```bash -# Check cache directory permissions -ls -la ~/.cache/asdf-acceleration - -# Fix if needed -chmod 700 ~/.cache/asdf-acceleration -``` - -## Next Steps - -- Read [Architecture Documentation](ARCHITECTURE.md) -- Review [Contributing Guidelines](../CONTRIBUTING.md) -- Explore [Example Configurations](../examples/) -- Join [Discussions](https://github.com/Hyperpolymath/asdf-acceleration-middleware/discussions) - -## Getting Help - -- 📖 [Full Documentation](README.md) -- 🐛 [Report Issues](https://github.com/Hyperpolymath/asdf-acceleration-middleware/issues) -- 💬 [Ask Questions](https://github.com/Hyperpolymath/asdf-acceleration-middleware/discussions) - ---- - -**Happy accelerating!** 🚀 diff --git a/asdf-acceleration-middleware/docs/TPCF.adoc b/asdf-acceleration-middleware/docs/TPCF.adoc new file mode 100644 index 00000000..4751277f --- /dev/null +++ b/asdf-acceleration-middleware/docs/TPCF.adoc @@ -0,0 +1,215 @@ +== Tri-Perimeter Contribution Framework (TPCF) + +This project implements the *Tri-Perimeter Contribution Framework* +(TPCF), a graduated trust model for open source contributions. + +=== Overview + +TPCF organizes contributors into three concentric perimeters based on +trust level and contribution history, providing a clear path for +community members to increase their involvement. + +=== Perimeters + +==== Perimeter 3: Community Sandbox + +*Current Status*: ✅ Active + +*Access Level*: Public contributions welcomed + +*Who*: All external contributors + +*Privileges*: - Fork repository - Submit pull requests - Participate in +discussions - Report issues + +*Requirements*: - Follow Code of Conduct - Pass all CI checks - Obtain +code review approval from Perimeter 1 or 2 maintainers + +*Workflow*: 1. Fork the repository 2. Create feature branch 3. Make +changes 4. Submit pull request 5. Address review feedback 6. Await +approval and merge + +*Graduation Criteria* to Perimeter 2: - ✅ 10+ merged pull requests - ✅ +6+ months of consistent contributions - ✅ Active code review +participation - ✅ Zero Code of Conduct violations - ✅ Demonstrated +technical expertise in project domain + +==== Perimeter 2: Trusted Contributors + +*Current Status*: 🔜 Planned + +*Access Level*: Direct repository access + +*Who*: Experienced contributors with proven track record + +*Privileges*: - Direct commit access to feature branches - Review and +approve pull requests - Participate in architectural discussions - +Mentor new contributors + +*Requirements*: - All Perimeter 3 requirements met - Nominated by +existing Perimeter 1 maintainer - Approval vote by Perimeter 1 (2/3 +majority) + +*Responsibilities*: - Maintain code quality standards - Review +contributions promptly - Uphold Code of Conduct - Support community +growth + +*Graduation Criteria* to Perimeter 1: - ✅ 50+ merged pull requests - ✅ +1+ year in Perimeter 2 - ✅ Significant architectural contributions - ✅ +Active mentoring of other contributors - ✅ Demonstrated project +leadership + +==== Perimeter 1: Core Maintainers + +*Current Status*: 🔜 To be established + +*Access Level*: Full repository control + +*Who*: Project leaders and primary maintainers + +*Privileges*: - Release authority - Main branch access - Security issue +triage - Governance decisions - Perimeter promotions + +*Requirements*: - All Perimeter 2 requirements met - Extensive +contribution history - Community leadership demonstrated - Approval vote +by existing Perimeter 1 (2/3 majority) + +*Responsibilities*: - Strategic direction - Release management - +Security response - Governance and policy - Community health + +=== Benefits of TPCF + +==== For Contributors + +[arabic] +. *Clear Path*: Transparent progression from contributor to maintainer +. *Recognition*: Formal acknowledgment of contributions +. *Meritocratic*: Advancement based on actual contributions +. *Safety*: Reduced anxiety through clear expectations + +==== For the Project + +[arabic] +. *Security*: Graduated trust reduces risk +. *Sustainability*: Distributed maintenance burden +. *Quality*: Multiple review layers +. *Growth*: Structured onboarding for new contributors + +==== For Users + +[arabic] +. *Stability*: Experienced maintainers with skin in the game +. *Accountability*: Clear ownership and responsibility +. *Continuity*: Multiple maintainers prevent single points of failure + +=== Comparison with Traditional Models + +[width="100%",cols="27%,53%,20%",options="header",] +|=== +|Aspect |Traditional OSS |TPCF +|Contribution |Binary (contributor/maintainer) |Graduated (3 levels) +|Trust |All or nothing |Incremental +|Onboarding |Informal |Structured +|Recognition |Often implicit |Explicit perimeters +|Security |Single barrier |Defense in depth +|=== + +=== Emotional Safety (Palimpsest Alignment) + +TPCF aligns with Palimpsest License emotional safety principles: + +==== Attribution Persistence + +* Git history preserved permanently +* CHANGELOG.md credits contributors +* humans.txt recognition +* Perimeter promotions publicly acknowledged + +==== Reversibility + +* Contributors can fork at any time +* No lock-in mechanisms +* Clear migration paths documented +* Perimeter demotion possible (with due process) + +==== Psychological Safety + +* Clear expectations reduce anxiety +* Structured feedback through reviews +* Mentorship opportunities +* Experimentation encouraged in feature branches + +==== Autonomy + +* Contributors control their involvement level +* No pressure to advance perimeters +* Fork-friendly governance +* Diverse contribution types valued + +=== Perimeter Transitions + +==== Nomination Process + +[arabic] +. *Self-nomination* or nomination by existing member +. *Discussion* among current perimeter members +. *Vote* (2/3 majority required) +. *Onboarding* and access provisioning +. *Announcement* in CHANGELOG and discussions + +==== Demotion Process + +Rare but possible for: - Extended inactivity (voluntary step-down) - +Repeated Code of Conduct violations - Security policy breaches + +*Process*: 1. Private discussion with maintainers 2. Opportunity to +respond 3. Vote if necessary (2/3 majority) 4. Transition support + +==== Emeritus Status + +Contributors who step down gracefully receive *Emeritus* recognition: - +Listed in MAINTAINERS.md - Contribution history preserved - Welcome to +return - Consulting/advisory role available + +=== Current State + +As of 2024-11-22: + +* *Perimeter 3*: ✅ Active and accepting contributions +* *Perimeter 2*: 🔜 No members yet (project in initial phase) +* *Perimeter 1*: 🔜 Founding maintainer(s) to be established + +=== Metrics and Transparency + +==== Public Dashboards + +(Planned): - Contribution statistics per perimeter - Time to review for +each level - Graduation timeline tracking + +==== Regular Reports + +Quarterly reports will include: - New perimeter promotions - +Contribution highlights - Community growth metrics - Governance +decisions + +=== Integration with RSR + +TPCF is a component of RSR (Rhodium Standard Repository) compliance: + +* ✅ Community governance structure +* ✅ Clear contribution pathways +* ✅ Security through graduated trust +* ✅ Emotional safety preservation + +=== References + +* link:../CODE_OF_CONDUCT.md[Code of Conduct] +* link:../CONTRIBUTING.md[Contributing Guidelines] +* link:../MAINTAINERS.md[Maintainers] +* link:../SECURITY.md[Security Policy] +* Palimpsest License: link:../LICENSE.txt[LICENSE.txt] + +''''' + +*Questions?* Open a discussion or contact maintainers (see +MAINTAINERS.md) diff --git a/asdf-acceleration-middleware/docs/TPCF.md b/asdf-acceleration-middleware/docs/TPCF.md deleted file mode 100644 index 8d896726..00000000 --- a/asdf-acceleration-middleware/docs/TPCF.md +++ /dev/null @@ -1,244 +0,0 @@ -# Tri-Perimeter Contribution Framework (TPCF) - -This project implements the **Tri-Perimeter Contribution Framework** (TPCF), a graduated trust model for open source contributions. - -## Overview - -TPCF organizes contributors into three concentric perimeters based on trust level and contribution history, providing a clear path for community members to increase their involvement. - -## Perimeters - -### Perimeter 3: Community Sandbox - -**Current Status**: ✅ Active - -**Access Level**: Public contributions welcomed - -**Who**: All external contributors - -**Privileges**: -- Fork repository -- Submit pull requests -- Participate in discussions -- Report issues - -**Requirements**: -- Follow Code of Conduct -- Pass all CI checks -- Obtain code review approval from Perimeter 1 or 2 maintainers - -**Workflow**: -1. Fork the repository -2. Create feature branch -3. Make changes -4. Submit pull request -5. Address review feedback -6. Await approval and merge - -**Graduation Criteria** to Perimeter 2: -- ✅ 10+ merged pull requests -- ✅ 6+ months of consistent contributions -- ✅ Active code review participation -- ✅ Zero Code of Conduct violations -- ✅ Demonstrated technical expertise in project domain - -### Perimeter 2: Trusted Contributors - -**Current Status**: 🔜 Planned - -**Access Level**: Direct repository access - -**Who**: Experienced contributors with proven track record - -**Privileges**: -- Direct commit access to feature branches -- Review and approve pull requests -- Participate in architectural discussions -- Mentor new contributors - -**Requirements**: -- All Perimeter 3 requirements met -- Nominated by existing Perimeter 1 maintainer -- Approval vote by Perimeter 1 (2/3 majority) - -**Responsibilities**: -- Maintain code quality standards -- Review contributions promptly -- Uphold Code of Conduct -- Support community growth - -**Graduation Criteria** to Perimeter 1: -- ✅ 50+ merged pull requests -- ✅ 1+ year in Perimeter 2 -- ✅ Significant architectural contributions -- ✅ Active mentoring of other contributors -- ✅ Demonstrated project leadership - -### Perimeter 1: Core Maintainers - -**Current Status**: 🔜 To be established - -**Access Level**: Full repository control - -**Who**: Project leaders and primary maintainers - -**Privileges**: -- Release authority -- Main branch access -- Security issue triage -- Governance decisions -- Perimeter promotions - -**Requirements**: -- All Perimeter 2 requirements met -- Extensive contribution history -- Community leadership demonstrated -- Approval vote by existing Perimeter 1 (2/3 majority) - -**Responsibilities**: -- Strategic direction -- Release management -- Security response -- Governance and policy -- Community health - -## Benefits of TPCF - -### For Contributors - -1. **Clear Path**: Transparent progression from contributor to maintainer -2. **Recognition**: Formal acknowledgment of contributions -3. **Meritocratic**: Advancement based on actual contributions -4. **Safety**: Reduced anxiety through clear expectations - -### For the Project - -1. **Security**: Graduated trust reduces risk -2. **Sustainability**: Distributed maintenance burden -3. **Quality**: Multiple review layers -4. **Growth**: Structured onboarding for new contributors - -### For Users - -1. **Stability**: Experienced maintainers with skin in the game -2. **Accountability**: Clear ownership and responsibility -3. **Continuity**: Multiple maintainers prevent single points of failure - -## Comparison with Traditional Models - -| Aspect | Traditional OSS | TPCF | -|--------|----------------|------| -| Contribution | Binary (contributor/maintainer) | Graduated (3 levels) | -| Trust | All or nothing | Incremental | -| Onboarding | Informal | Structured | -| Recognition | Often implicit | Explicit perimeters | -| Security | Single barrier | Defense in depth | - -## Emotional Safety (Palimpsest Alignment) - -TPCF aligns with Palimpsest License emotional safety principles: - -### Attribution Persistence - -- Git history preserved permanently -- CHANGELOG.md credits contributors -- humans.txt recognition -- Perimeter promotions publicly acknowledged - -### Reversibility - -- Contributors can fork at any time -- No lock-in mechanisms -- Clear migration paths documented -- Perimeter demotion possible (with due process) - -### Psychological Safety - -- Clear expectations reduce anxiety -- Structured feedback through reviews -- Mentorship opportunities -- Experimentation encouraged in feature branches - -### Autonomy - -- Contributors control their involvement level -- No pressure to advance perimeters -- Fork-friendly governance -- Diverse contribution types valued - -## Perimeter Transitions - -### Nomination Process - -1. **Self-nomination** or nomination by existing member -2. **Discussion** among current perimeter members -3. **Vote** (2/3 majority required) -4. **Onboarding** and access provisioning -5. **Announcement** in CHANGELOG and discussions - -### Demotion Process - -Rare but possible for: -- Extended inactivity (voluntary step-down) -- Repeated Code of Conduct violations -- Security policy breaches - -**Process**: -1. Private discussion with maintainers -2. Opportunity to respond -3. Vote if necessary (2/3 majority) -4. Transition support - -### Emeritus Status - -Contributors who step down gracefully receive **Emeritus** recognition: -- Listed in MAINTAINERS.md -- Contribution history preserved -- Welcome to return -- Consulting/advisory role available - -## Current State - -As of 2024-11-22: - -- **Perimeter 3**: ✅ Active and accepting contributions -- **Perimeter 2**: 🔜 No members yet (project in initial phase) -- **Perimeter 1**: 🔜 Founding maintainer(s) to be established - -## Metrics and Transparency - -### Public Dashboards - -(Planned): -- Contribution statistics per perimeter -- Time to review for each level -- Graduation timeline tracking - -### Regular Reports - -Quarterly reports will include: -- New perimeter promotions -- Contribution highlights -- Community growth metrics -- Governance decisions - -## Integration with RSR - -TPCF is a component of RSR (Rhodium Standard Repository) compliance: - -- ✅ Community governance structure -- ✅ Clear contribution pathways -- ✅ Security through graduated trust -- ✅ Emotional safety preservation - -## References - -- [Code of Conduct](../CODE_OF_CONDUCT.md) -- [Contributing Guidelines](../CONTRIBUTING.md) -- [Maintainers](../MAINTAINERS.md) -- [Security Policy](../SECURITY.md) -- Palimpsest License: [LICENSE.txt](../LICENSE.txt) - ---- - -**Questions?** Open a discussion or contact maintainers (see MAINTAINERS.md) diff --git a/asdf-ada-plugin/ABI-FFI-README.adoc b/asdf-ada-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..e958d332 --- /dev/null +++ b/asdf-ada-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== ADA ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/ada.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libada.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +ada/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── ada.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── ada.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/ada.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "ada.h" + +int main() { + void* handle = ada_init(); + if (!handle) return 1; + + int result = ada_process(handle, 42); + if (result != 0) { + const char* err = ada_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + ada_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lada -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import ADA.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "ada")] +extern "C" { + fn ada_init() -> *mut std::ffi::c_void; + fn ada_free(handle: *mut std::ffi::c_void); + fn ada_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = ada_init(); + assert!(!handle.is_null()); + + let result = ada_process(handle, 42); + assert_eq!(result, 0); + + ada_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libada = "libada" + +function init() + handle = ccall((:ada_init, libada), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:ada_process, libada), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:ada_free, libada), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/ada.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-ada-plugin/ABI-FFI-README.md b/asdf-ada-plugin/ABI-FFI-README.md deleted file mode 100644 index c9cb98b9..00000000 --- a/asdf-ada-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# ADA ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/ada.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libada.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -ada/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── ada.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── ada.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/ada.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "ada.h" - -int main() { - void* handle = ada_init(); - if (!handle) return 1; - - int result = ada_process(handle, 42); - if (result != 0) { - const char* err = ada_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - ada_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lada -L./zig-out/lib -``` - -### From Idris2 - -```idris -import ADA.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "ada")] -extern "C" { - fn ada_init() -> *mut std::ffi::c_void; - fn ada_free(handle: *mut std::ffi::c_void); - fn ada_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = ada_init(); - assert!(!handle.is_null()); - - let result = ada_process(handle, 42); - assert_eq!(result, 0); - - ada_free(handle); - } -} -``` - -### From Julia - -```julia -const libada = "libada" - -function init() - handle = ccall((:ada_init, libada), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:ada_process, libada), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:ada_free, libada), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/ada.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-ada-plugin/CODE_OF_CONDUCT.adoc b/asdf-ada-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-ada-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-ada-plugin/CODE_OF_CONDUCT.md b/asdf-ada-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index caeda1c6..00000000 --- a/asdf-ada-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,27 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. - diff --git a/asdf-ada-plugin/CONTRIBUTING.adoc b/asdf-ada-plugin/CONTRIBUTING.adoc index eb045d61..084ee525 100644 --- a/asdf-ada-plugin/CONTRIBUTING.adoc +++ b/asdf-ada-plugin/CONTRIBUTING.adoc @@ -1,20 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-ada-plugin/CONTRIBUTING.md b/asdf-ada-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-ada-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-ada-plugin/README.adoc b/asdf-ada-plugin/README.adoc index 99d06e54..339286c8 100644 --- a/asdf-ada-plugin/README.adoc +++ b/asdf-ada-plugin/README.adoc @@ -1,632 +1,83 @@ -= asdf-ada +== asdf-ada -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] -image:https://img.shields.io/badge/Philosophy-Palimpsest-indigo.svg[Palimpsest,link="https://github.com/hyperpolymath/palimpsest-license"] +https://github.com/hyperpolymath/asdf-ada-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-ada-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-ada-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-ada-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] +https://asdf-vm.com[asdf] plugin for +https://www.adacore.com/community[GNAT Ada Compiler]. -:author: hyperpolymath -:revnumber: 0.1.0 -:toc: macro -:toclevels: 3 -:icons: font -:source-highlighter: rouge -:experimental: -:url-asdf: https://asdf-vm.com -:url-gnat: https://www.adacore.com/download -:url-alire: https://alire.ada.dev -:url-ada-lang: https://ada-lang.io -:url-repo: https://github.com/hyperpolymath/asdf-ada-plugin +Ada compiler from AdaCore. -image:https://img.shields.io/github/license/hyperpolymath/asdf-ada-plugin?style=flat-square[License,link=LICENSE] -image:https://img.shields.io/github/v/release/hyperpolymath/asdf-ada-plugin?style=flat-square[Release,link={url-repo}/releases] -image:https://img.shields.io/github/actions/workflow/status/hyperpolymath/asdf-ada-plugin/ci.yml?branch=main&style=flat-square[Build Status,link={url-repo}/actions] -image:https://img.shields.io/badge/asdf-plugin-blue?style=flat-square[asdf Plugin,link={url-asdf}] +=== Contents -[.lead] -An {url-asdf}[asdf] plugin to manage https://ada-lang.io[Ada/GNAT] compiler versions seamlessly across projects. - -toc::[] - -== Overview - -=== What is Ada? - -https://ada-lang.io[Ada] is a structured, statically typed, imperative, and object-oriented high-level programming language designed for safety-critical and mission-critical systems. Originally developed in the 1980s for the U.S. Department of Defense, Ada is renowned for: - -* **Strong typing** — Catches errors at compile time rather than runtime -* **Built-in concurrency** — Native tasking support for parallel programming -* **Contract-based programming** — Pre/post conditions and type invariants -* **Real-time systems support** — Deterministic behavior for embedded systems -* **Long-term maintainability** — Designed for systems with 30+ year lifecycles - -Ada is used in aerospace (Boeing, Airbus), defense systems, rail transportation, medical devices, and financial systems where reliability is paramount. - -=== What is asdf? - -{url-asdf}[asdf] is a universal version manager that allows you to manage multiple runtime versions with a single CLI tool. Instead of juggling separate version managers for each language, asdf provides one interface to rule them all. - -=== Why asdf-ada? - -Managing Ada/GNAT compiler versions traditionally requires manual downloads, environment variable configuration, and careful PATH management. `asdf-ada` simplifies this by providing: - -[cols="1,3"] -|=== -|Feature |Benefit - -|**Version Switching** -|Switch between GNAT versions instantly per project - -|**Project Isolation** -|Each project can specify its required Ada version via `.tool-versions` - -|**Reproducible Builds** -|Team members and CI/CD pipelines use identical compiler versions - -|**Multiple Distributions** -|Support for FSF GNAT, GNAT Community, and Alire-managed toolchains - -|**Cross-Platform** -|Works on Linux, macOS, and Windows (via WSL) -|=== - -== Prerequisites - -=== System Requirements - -[cols="1,2,3"] -|=== -|Platform |Minimum Version |Notes - -|**Linux** -|Ubuntu 20.04+ / Fedora 35+ / Debian 11+ -|x86_64 and aarch64 supported - -|**macOS** -|macOS 11 (Big Sur)+ -|Intel and Apple Silicon (M1/M2/M3) - -|**Windows** -|Windows 10+ with WSL2 -|Native support planned for future releases -|=== +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] === Dependencies -Before installing the plugin, ensure you have the following: - -[source,bash] ----- -# Debian/Ubuntu -sudo apt-get update -sudo apt-get install -y curl git build-essential libc6-dev - -# Fedora/RHEL -sudo dnf install -y curl git gcc glibc-devel - -# macOS (via Homebrew) -brew install curl git -xcode-select --install # For build tools - -# Arch Linux -sudo pacman -S curl git base-devel ----- - -=== asdf Installation - -If you haven't installed asdf yet: - -[source,bash] ----- -# Clone asdf -git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.0 - -# Add to your shell (bash) -echo '. "$HOME/.asdf/asdf.sh"' >> ~/.bashrc -echo '. "$HOME/.asdf/completions/asdf.bash"' >> ~/.bashrc - -# Add to your shell (zsh) -echo '. "$HOME/.asdf/asdf.sh"' >> ~/.zshrc +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -# Add to your shell (fish) -echo 'source ~/.asdf/asdf.fish' >> ~/.config/fish/config.fish +=== Install -# Reload your shell -exec $SHELL ----- - -== Installation - -=== Adding the Plugin +Plugin: [source,bash] ---- -# Add the asdf-ada plugin asdf plugin add ada https://github.com/hyperpolymath/asdf-ada-plugin.git - -# Verify installation -asdf plugin list ---- -=== Installing Ada/GNAT Versions +ada: [source,bash] ---- -# List all available versions -asdf list all ada - -# Install a specific version -asdf install ada 14.1.0 # FSF GNAT 14.1.0 -asdf install ada community-2021 # GNAT Community 2021 -asdf install ada alire-latest # Latest via Alire +# Show all installable versions +asdf list-all ada -# Install the latest stable version +# Install specific version asdf install ada latest ----- - -=== Setting the Version - -[source,bash] ----- -# Set global default (used when no local version is specified) -asdf global ada 14.1.0 - -# Set local version for current project (creates .tool-versions) -asdf local ada 14.1.0 - -# Set version for current shell session only -asdf shell ada 14.1.0 -# Verify the active version -asdf current ada -gnatmake --version ----- - -== Usage - -=== Project Configuration +# Set a version globally (in your ~/.tool-versions file) +asdf global ada latest -Create a `.tool-versions` file in your project root: - -[source] ----- -ada 14.1.0 +# Now ada commands are available +ada --version ---- -When you `cd` into the project directory, asdf automatically activates the specified version. +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -=== Available Commands +=== Usage [source,bash] ---- # List installed versions asdf list ada -# Show current version -asdf current ada +# Set local version for current directory +asdf local ada # Uninstall a version -asdf uninstall ada 13.2.0 - -# Reshim after installing Ada tools (e.g., via Alire) -asdf reshim ada - -# Show installation path -asdf where ada 14.1.0 ----- - -=== Environment Variables - -The plugin respects and sets the following environment variables: - -[cols="2,3,2"] -|=== -|Variable |Description |Default - -|`ASDF_ADA_DISTRIBUTION` -|Preferred distribution (`fsf`, `community`, `alire`) -|`fsf` - -|`ASDF_ADA_MIRROR` -|Custom mirror URL for downloads -|Official sources - -|`ASDF_ADA_SKIP_VERIFY` -|Skip checksum verification (`true`/`false`) -|`false` - -|`ASDF_ADA_INSTALL_GPRBUILD` -|Auto-install GPRbuild (`true`/`false`) -|`true` -|=== - -=== Integration with Build Tools - -==== GPRbuild - -[source,bash] ----- -# GPRbuild is included with most GNAT installations -gprbuild --version - -# Build an Ada project -gprbuild -P my_project.gpr ----- - -==== Alire - -{url-alire}[Alire] is Ada's package manager. You can use it alongside asdf: - -[source,bash] ----- -# Install Alire separately or use asdf-managed version -asdf install ada alire-latest - -# Initialize an Alire project -alr init my_project -cd my_project -alr build ----- - -==== SPARK Formal Verification - -For SPARK Pro users: - -[source,bash] ----- -# SPARK is included in GNAT Community editions -gnatprove --version - -# Run formal verification -gnatprove -P my_project.gpr ----- - -== Supported Versions - -=== FSF GNAT (GNU Ada) - -Official GNU Compiler Collection Ada frontend: - -[source] ----- -14.1.0, 14.0.0, 13.3.0, 13.2.0, 13.1.0 -12.4.0, 12.3.0, 12.2.0, 12.1.0 -11.5.0, 11.4.0, 11.3.0, 11.2.0, 11.1.0 -10.5.0, 10.4.0, 10.3.0 ----- - -=== GNAT Community Edition - -AdaCore's free community releases (discontinued after 2021): - -[source] +asdf uninstall ada ---- -community-2021 -community-2020 -community-2019 ----- - -=== Alire Toolchains - -Managed via the Alire package manager: -[source] ----- -alire-latest # Latest available via Alire -alire-native # Native toolchain via Alire ----- - -== Configuration - -=== Plugin Configuration File - -Create `~/.config/asdf-ada/config` for persistent settings: - -[source,ini] ----- -# Default distribution preference -distribution = fsf - -# Download mirror (leave empty for official sources) -mirror = - -# Verify checksums (recommended) -verify_checksums = true - -# Install GPRbuild automatically -install_gprbuild = true - -# Concurrent downloads -parallel_downloads = 4 ----- - -=== Platform-Specific Notes - -==== macOS Apple Silicon - -Native ARM64 builds are available for GNAT 13.1.0+. For older versions, Rosetta 2 emulation is used automatically. - -==== Linux ARM64 - -ARM64 builds are provided for: -- Raspberry Pi 4/5 (64-bit OS) -- AWS Graviton instances -- Other aarch64 systems - -==== Windows (WSL2) - -[source,bash] ----- -# Install WSL2 with Ubuntu -wsl --install -d Ubuntu - -# Inside WSL, install asdf and the plugin as normal -# See the Linux installation instructions above ----- - -== Troubleshooting - -=== Common Issues - -[qanda] -Version not found when running `gnatmake`:: -Run `asdf reshim ada` after installation and ensure your shell is properly configured. - -Download fails with SSL errors:: -Ensure `ca-certificates` is installed: `sudo apt-get install ca-certificates` - -"Permission denied" during installation:: -Check write permissions for `~/.asdf/installs/ada/` - -Slow downloads:: -Set `ASDF_ADA_MIRROR` to a geographically closer mirror. - -=== Getting Help - -1. Check the link:{url-repo}/issues[GitHub Issues] for known problems -2. Join the https://gitter.im/ada-lang/Lobby[Ada community chat] -3. Open a https://github.com/hyperpolymath/asdf-ada-plugin/issues/new[new issue] with: - - Your OS and version - - asdf version (`asdf --version`) - - Plugin version - - Full error output - -== Contributing - -We welcome contributions! Please see our link:CONTRIBUTING.adoc[Contributing Guide] for details. - -=== Quick Start for Contributors - -[source,bash] ----- -# Fork and clone -git clone https://github.com/YOUR_USERNAME/asdf-ada-plugin.git -cd asdf-ada-plugin - -# Create a feature branch -git checkout -b feature/your-feature-name - -# Make changes and test -./scripts/test.sh - -# Submit a pull request ----- - -=== Code of Conduct - -This project adheres to the https://www.contributor-covenant.org/[Contributor Covenant]. Please read our link:CODE_OF_CONDUCT.adoc[Code of Conduct] before participating. - -== Roadmap - -This roadmap outlines the planned development phases for `asdf-ada`. - -=== Phase 1: Foundation (v0.1.0) icon:wrench[] - -*Status:* 🚧 In Progress - -[%interactive] -* [ ] Core plugin structure following asdf plugin template -* [ ] `bin/list-all` — Fetch available GNAT versions from upstream -* [ ] `bin/download` — Download GNAT releases -* [ ] `bin/install` — Install and configure GNAT toolchain -* [ ] `bin/latest-stable` — Resolve latest stable version -* [ ] Basic FSF GNAT support (Linux x86_64) -* [ ] README and initial documentation -* [ ] GitHub Actions CI/CD pipeline -* [ ] Basic test suite using Bats - -=== Phase 2: Multi-Platform Support (v0.2.0) icon:desktop[] - -*Status:* 📋 Planned - -[%interactive] -* [ ] macOS x86_64 support -* [ ] macOS ARM64 (Apple Silicon) support -* [ ] Linux ARM64 support -* [ ] Windows WSL2 documentation and testing -* [ ] Checksum verification for all downloads -* [ ] Progress indicators during download/install -* [ ] Improved error messages and logging - -=== Phase 3: Extended Distribution Support (v0.3.0) icon:cubes[] - -*Status:* 📋 Planned - -[%interactive] -* [ ] GNAT Community Edition support (2019-2021) -* [ ] Alire toolchain integration -* [ ] AdaCore GNAT Pro stub support (license required) -* [ ] Custom mirror configuration -* [ ] Version aliases (`lts`, `stable`, `latest`) -* [ ] `bin/help` plugin subcommands - -=== Phase 4: Developer Experience (v0.4.0) icon:star[] - -*Status:* 📋 Planned - -[%interactive] -* [ ] Automatic GPRbuild installation -* [ ] GNATcov integration -* [ ] SPARK tools inclusion -* [ ] Shell completions (bash, zsh, fish) -* [ ] Version constraint solving (semver support) -* [ ] `asdf-ada doctor` command for diagnostics - -=== Phase 5: Ecosystem Integration (v0.5.0) icon:plug[] - -*Status:* 📋 Planned - -[%interactive] -* [ ] Alire crate template generation -* [ ] VS Code Ada extension compatibility documentation -* [ ] GNAT Studio integration notes -* [ ] Docker/container image publishing -* [ ] CI/CD examples (GitHub Actions, GitLab CI, Jenkins) -* [ ] Guix flake support - -=== Phase 6: Enterprise & Polish (v1.0.0) icon:building[] - -*Status:* 🔮 Future - -[%interactive] -* [ ] Stable API with semantic versioning -* [ ] Comprehensive test coverage (90%+) -* [ ] Full documentation with tutorials -* [ ] Offline installation support -* [ ] Corporate proxy support -* [ ] Signed releases -* [ ] Official asdf plugin registry listing -* [ ] Community governance model - -=== Future Ideas icon:lightbulb[] - -These features are under consideration for post-1.0 releases: - -* **Cross-compilation toolchains** — ARM bare-metal, RISC-V targets -* **GNAT-LLVM support** — LLVM-based Ada compiler backend -* **Version diffing** — Show changelog between versions -* **Performance profiling integration** — GNATbench-like features -* **IDE project generation** — Templates for various editors -* **Dependency caching** — Speed up clean installs -* **Native Windows support** — Without WSL requirement - -== Mirrors - -This repository is mirrored to: - -* https://gitlab.com/hyperpolymath/asdf-ada-plugin[GitLab] -* https://codeberg.org/hyperpolymath/asdf-ada-plugin[Codeberg] -* https://bitbucket.org/hyperpolymath/asdf-ada-plugin[Bitbucket] - -== Related Projects - -* {url-asdf}[asdf] — The universal version manager -* {url-gnat}[GNAT Downloads] — Official AdaCore downloads -* {url-alire}[Alire] — Ada/SPARK package manager -* {url-ada-lang}[Ada Programming Language] — Official Ada resources -* https://learn.adacore.com[learn.adacore.com] — Free Ada/SPARK tutorials -* https://github.com/ohenley/awesome-ada[Awesome Ada] — Curated Ada resources - -== Hyperpolymath asdf Ecosystem - -This plugin is part of the **Hyperpolymath asdf ecosystem**, a layered architecture for managing developer tool versions. - -=== Ecosystem Architecture - -[source] ----- - ┌──────────────────────────┐ - │ asdf-control-tower │ ← Layer 3: Presentation - │ (docs + dashboard) │ - └───────────┬──────────────┘ - │ -┌──────────────────────────┐ │ ┌──────────────────────────┐ -│ asdf-ui-plugin │────┼────│ asdf-plugin-configurator │ ← Layer 2–3 -│ (visual UX; planned) │ │ │ (Rust CLI; config/policy)│ -└──────────────────────────┘ │ └──────────────────────────┘ - │ - ┌───────────┴───────────┐ - │ asdf-metaiconic-plugin│ ← Layer 1: Registry - │ (registry + schema) │ - └───────────┬───────────┘ - │ - ┌────────────────────────────────────────────────┐ - │ Individual asdf tool plugins (Layer 5) │ - │ │ - │ ★ asdf-ada-plugin ← YOU ARE HERE │ - │ asdf-neo4j-plugin │ - │ asdf-ghjk │ - │ …(68+ installable plugins) │ - └────────────────────────────────────────────────┘ ----- - -=== Layer Descriptions - -[cols="1,2,4"] -|=== -|Layer |Component |Purpose - -|**Layer 0** -|Infrastructure Spine -|Multi-forge mirroring, instant-sync, policy constraints (`.claude/CLAUDE.md`), community docs — present across all repos - -|**Layer 1** -|https://github.com/hyperpolymath/asdf-metaiconic-plugin[asdf-metaiconic-plugin] -|Canonical metadata registry: `registry/plugins.yaml`, category definitions, quality metrics, icon/branding standards - -|**Layer 2** -|https://github.com/hyperpolymath/asdf-plugin-configurator[asdf-plugin-configurator] -|Rust CLI for declarative plugin configuration — apply policy to machines/projects, consume registry for validation - -|**Layer 3** -|https://github.com/hyperpolymath/asdf-control-tower[asdf-control-tower] + https://github.com/hyperpolymath/asdf-ui-plugin[asdf-ui-plugin] -|Human-facing dashboard, documentation hub, visual discovery UI (planned) - -|**Layer 4** -|Domain Collections -|Category "umbrella" plugins (e.g., `asdf-security-plugin` for curated security toolsets) - -|**Layer 5** -|**Tool Plugins** ★ -|**Actual installable units** — implements `bin/list-all`, `bin/download`, `bin/install`, `bin/latest-stable`. This repo (`asdf-ada-plugin`) lives here. -|=== - -=== This Plugin's Role - -`asdf-ada-plugin` is a **Layer 5 tool plugin** — the actual "workhorse" that asdf uses to install and manage Ada/GNAT compiler versions. It: - -* Implements the asdf plugin contract (`bin/list-all`, `bin/download`, `bin/install`, `bin/latest-stable`) -* Fetches releases from the https://github.com/alire-project/GNAT-FSF-builds[GNAT-FSF-builds] upstream -* Provides checksum verification, multi-platform support, and robust error handling -* Is indexed by `asdf-metaiconic-plugin` for ecosystem-wide discovery -* Can be configured via `asdf-plugin-configurator` for team/project consistency - -=== Ecosystem Links - -* https://github.com/hyperpolymath/asdf-control-tower[asdf-control-tower] — Ecosystem documentation hub -* https://github.com/hyperpolymath/asdf-metaiconic-plugin[asdf-metaiconic-plugin] — Plugin registry and metadata -* https://github.com/hyperpolymath/asdf-plugin-configurator[asdf-plugin-configurator] — Policy enforcement CLI - -== License - -This project is licensed under the Palimpsest-MPL License v3.0 or later. -See the link:LICENSE[LICENSE] file for details. - -[source] ----- -SPDX-License-Identifier: CC-BY-SA-4.0 ----- +=== Contributing -== Acknowledgments +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. -* The {url-asdf}[asdf] team for creating the plugin ecosystem -* https://www.adacore.com[AdaCore] for maintaining GNAT -* The Ada community for keeping the language thriving -* All contributors who help improve this plugin +=== License ---- +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -[.text-center] -Made with ❤️ for the Ada community +''''' -[.text-center] -link:#[⬆ Back to Top] +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-ada-plugin/README.md b/asdf-ada-plugin/README.md deleted file mode 100644 index 2caccbaa..00000000 --- a/asdf-ada-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-ada - -[![Build](https://github.com/hyperpolymath/asdf-ada-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-ada-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-ada-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-ada-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [GNAT Ada Compiler](https://www.adacore.com/community). - -Ada compiler from AdaCore. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add ada https://github.com/hyperpolymath/asdf-ada-plugin.git -``` - -ada: - -```bash -# Show all installable versions -asdf list-all ada - -# Install specific version -asdf install ada latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global ada latest - -# Now ada commands are available -ada --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list ada - -# Set local version for current directory -asdf local ada - -# Uninstall a version -asdf uninstall ada -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-ada-plugin/SECURITY.adoc b/asdf-ada-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-ada-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-ada-plugin/SECURITY.md b/asdf-ada-plugin/SECURITY.md deleted file mode 100644 index 159a0b7a..00000000 --- a/asdf-ada-plugin/SECURITY.md +++ /dev/null @@ -1,25 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection - diff --git a/asdf-age-plugin/ABI-FFI-README.adoc b/asdf-age-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..e8fa780b --- /dev/null +++ b/asdf-age-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== AGE ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/age.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libage.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +age/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── age.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── age.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/age.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "age.h" + +int main() { + void* handle = age_init(); + if (!handle) return 1; + + int result = age_process(handle, 42); + if (result != 0) { + const char* err = age_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + age_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lage -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import AGE.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "age")] +extern "C" { + fn age_init() -> *mut std::ffi::c_void; + fn age_free(handle: *mut std::ffi::c_void); + fn age_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = age_init(); + assert!(!handle.is_null()); + + let result = age_process(handle, 42); + assert_eq!(result, 0); + + age_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libage = "libage" + +function init() + handle = ccall((:age_init, libage), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:age_process, libage), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:age_free, libage), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/age.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-age-plugin/ABI-FFI-README.md b/asdf-age-plugin/ABI-FFI-README.md deleted file mode 100644 index 1bcc978a..00000000 --- a/asdf-age-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# AGE ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/age.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libage.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -age/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── age.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── age.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/age.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "age.h" - -int main() { - void* handle = age_init(); - if (!handle) return 1; - - int result = age_process(handle, 42); - if (result != 0) { - const char* err = age_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - age_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lage -L./zig-out/lib -``` - -### From Idris2 - -```idris -import AGE.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "age")] -extern "C" { - fn age_init() -> *mut std::ffi::c_void; - fn age_free(handle: *mut std::ffi::c_void); - fn age_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = age_init(); - assert!(!handle.is_null()); - - let result = age_process(handle, 42); - assert_eq!(result, 0); - - age_free(handle); - } -} -``` - -### From Julia - -```julia -const libage = "libage" - -function init() - handle = ccall((:age_init, libage), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:age_process, libage), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:age_free, libage), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/age.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-age-plugin/CODE_OF_CONDUCT.adoc b/asdf-age-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-age-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-age-plugin/CODE_OF_CONDUCT.md b/asdf-age-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-age-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-age-plugin/CONTRIBUTING.adoc b/asdf-age-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-age-plugin/CONTRIBUTING.adoc +++ b/asdf-age-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-age-plugin/CONTRIBUTING.md b/asdf-age-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-age-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-age-plugin/README.adoc b/asdf-age-plugin/README.adoc index d08e1dd2..08505a04 100644 --- a/asdf-age-plugin/README.adoc +++ b/asdf-age-plugin/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-age -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-age-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-age-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-age-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-age-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://age-encryption.org[age]. -**All repos with foreign function interfaces MUST follow this standard:** +Simple, modern file encryption. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add age https://github.com/hyperpolymath/asdf-age-plugin.git +---- -=== Web Projects +age: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all age -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install age latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global age latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now age commands are available +age --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list age -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local age -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall age ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-age-plugin/README.md b/asdf-age-plugin/README.md deleted file mode 100644 index 4f2a10bd..00000000 --- a/asdf-age-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-age - -[![Build](https://github.com/hyperpolymath/asdf-age-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-age-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-age-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-age-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [age](https://age-encryption.org). - -Simple, modern file encryption. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add age https://github.com/hyperpolymath/asdf-age-plugin.git -``` - -age: - -```bash -# Show all installable versions -asdf list-all age - -# Install specific version -asdf install age latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global age latest - -# Now age commands are available -age --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list age - -# Set local version for current directory -asdf local age - -# Uninstall a version -asdf uninstall age -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-age-plugin/SECURITY.adoc b/asdf-age-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-age-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-age-plugin/SECURITY.md b/asdf-age-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-age-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-apko-plugin/ABI-FFI-README.adoc b/asdf-apko-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..cb968d83 --- /dev/null +++ b/asdf-apko-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== APKO ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/apko.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libapko.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +apko/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── apko.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── apko.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/apko.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "apko.h" + +int main() { + void* handle = apko_init(); + if (!handle) return 1; + + int result = apko_process(handle, 42); + if (result != 0) { + const char* err = apko_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + apko_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lapko -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import APKO.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "apko")] +extern "C" { + fn apko_init() -> *mut std::ffi::c_void; + fn apko_free(handle: *mut std::ffi::c_void); + fn apko_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = apko_init(); + assert!(!handle.is_null()); + + let result = apko_process(handle, 42); + assert_eq!(result, 0); + + apko_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libapko = "libapko" + +function init() + handle = ccall((:apko_init, libapko), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:apko_process, libapko), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:apko_free, libapko), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/apko.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-apko-plugin/ABI-FFI-README.md b/asdf-apko-plugin/ABI-FFI-README.md deleted file mode 100644 index b4a76026..00000000 --- a/asdf-apko-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# APKO ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/apko.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libapko.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -apko/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── apko.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── apko.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/apko.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "apko.h" - -int main() { - void* handle = apko_init(); - if (!handle) return 1; - - int result = apko_process(handle, 42); - if (result != 0) { - const char* err = apko_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - apko_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lapko -L./zig-out/lib -``` - -### From Idris2 - -```idris -import APKO.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "apko")] -extern "C" { - fn apko_init() -> *mut std::ffi::c_void; - fn apko_free(handle: *mut std::ffi::c_void); - fn apko_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = apko_init(); - assert!(!handle.is_null()); - - let result = apko_process(handle, 42); - assert_eq!(result, 0); - - apko_free(handle); - } -} -``` - -### From Julia - -```julia -const libapko = "libapko" - -function init() - handle = ccall((:apko_init, libapko), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:apko_process, libapko), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:apko_free, libapko), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/apko.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-apko-plugin/CODE_OF_CONDUCT.adoc b/asdf-apko-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-apko-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-apko-plugin/CODE_OF_CONDUCT.md b/asdf-apko-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-apko-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-apko-plugin/CONTRIBUTING.adoc b/asdf-apko-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-apko-plugin/CONTRIBUTING.adoc +++ b/asdf-apko-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-apko-plugin/CONTRIBUTING.md b/asdf-apko-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-apko-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-apko-plugin/README.adoc b/asdf-apko-plugin/README.adoc index d08e1dd2..349259da 100644 --- a/asdf-apko-plugin/README.adoc +++ b/asdf-apko-plugin/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-apko -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-apko-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-apko-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-apko-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-apko-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://github.com/chainguard-dev/apko[apko]. -**All repos with foreign function interfaces MUST follow this standard:** +OCI images from APK packages. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add apko https://github.com/hyperpolymath/asdf-apko-plugin.git +---- -=== Web Projects +apko: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all apko -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install apko latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global apko latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now apko commands are available +apko --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list apko -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local apko -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall apko ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-apko-plugin/README.md b/asdf-apko-plugin/README.md deleted file mode 100644 index c43254a5..00000000 --- a/asdf-apko-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-apko - -[![Build](https://github.com/hyperpolymath/asdf-apko-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-apko-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-apko-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-apko-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [apko](https://github.com/chainguard-dev/apko). - -OCI images from APK packages. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add apko https://github.com/hyperpolymath/asdf-apko-plugin.git -``` - -apko: - -```bash -# Show all installable versions -asdf list-all apko - -# Install specific version -asdf install apko latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global apko latest - -# Now apko commands are available -apko --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list apko - -# Set local version for current directory -asdf local apko - -# Uninstall a version -asdf uninstall apko -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-apko-plugin/SECURITY.adoc b/asdf-apko-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-apko-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-apko-plugin/SECURITY.md b/asdf-apko-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-apko-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-arangodb-plugin/ABI-FFI-README.adoc b/asdf-arangodb-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..f35cc374 --- /dev/null +++ b/asdf-arangodb-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== ARANGODB ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/arangodb.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libarangodb.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +arangodb/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── arangodb.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── arangodb.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/arangodb.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "arangodb.h" + +int main() { + void* handle = arangodb_init(); + if (!handle) return 1; + + int result = arangodb_process(handle, 42); + if (result != 0) { + const char* err = arangodb_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + arangodb_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -larangodb -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import ARANGODB.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "arangodb")] +extern "C" { + fn arangodb_init() -> *mut std::ffi::c_void; + fn arangodb_free(handle: *mut std::ffi::c_void); + fn arangodb_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = arangodb_init(); + assert!(!handle.is_null()); + + let result = arangodb_process(handle, 42); + assert_eq!(result, 0); + + arangodb_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libarangodb = "libarangodb" + +function init() + handle = ccall((:arangodb_init, libarangodb), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:arangodb_process, libarangodb), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:arangodb_free, libarangodb), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/arangodb.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-arangodb-plugin/ABI-FFI-README.md b/asdf-arangodb-plugin/ABI-FFI-README.md deleted file mode 100644 index 46999d03..00000000 --- a/asdf-arangodb-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# ARANGODB ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/arangodb.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libarangodb.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -arangodb/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── arangodb.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── arangodb.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/arangodb.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "arangodb.h" - -int main() { - void* handle = arangodb_init(); - if (!handle) return 1; - - int result = arangodb_process(handle, 42); - if (result != 0) { - const char* err = arangodb_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - arangodb_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -larangodb -L./zig-out/lib -``` - -### From Idris2 - -```idris -import ARANGODB.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "arangodb")] -extern "C" { - fn arangodb_init() -> *mut std::ffi::c_void; - fn arangodb_free(handle: *mut std::ffi::c_void); - fn arangodb_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = arangodb_init(); - assert!(!handle.is_null()); - - let result = arangodb_process(handle, 42); - assert_eq!(result, 0); - - arangodb_free(handle); - } -} -``` - -### From Julia - -```julia -const libarangodb = "libarangodb" - -function init() - handle = ccall((:arangodb_init, libarangodb), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:arangodb_process, libarangodb), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:arangodb_free, libarangodb), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/arangodb.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-arangodb-plugin/CODE_OF_CONDUCT.adoc b/asdf-arangodb-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-arangodb-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-arangodb-plugin/CODE_OF_CONDUCT.md b/asdf-arangodb-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-arangodb-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-arangodb-plugin/CONTRIBUTING.adoc b/asdf-arangodb-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-arangodb-plugin/CONTRIBUTING.adoc +++ b/asdf-arangodb-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-arangodb-plugin/CONTRIBUTING.md b/asdf-arangodb-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-arangodb-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-arangodb-plugin/README.adoc b/asdf-arangodb-plugin/README.adoc index d08e1dd2..43a7cc7a 100644 --- a/asdf-arangodb-plugin/README.adoc +++ b/asdf-arangodb-plugin/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-arangodb -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-arangodb-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-arangodb-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-arangodb-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-arangodb-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://www.arangodb.com[ArangoDB]. -**All repos with foreign function interfaces MUST follow this standard:** +Multi-model NoSQL database. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add arangodb https://github.com/hyperpolymath/asdf-arangodb-plugin.git +---- -=== Web Projects +arangodb: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all arangodb -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install arangodb latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global arangodb latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now arangodb commands are available +arangodb --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list arangodb -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local arangodb -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall arangodb ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-arangodb-plugin/README.md b/asdf-arangodb-plugin/README.md deleted file mode 100644 index 93bd52b9..00000000 --- a/asdf-arangodb-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-arangodb - -[![Build](https://github.com/hyperpolymath/asdf-arangodb-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-arangodb-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-arangodb-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-arangodb-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [ArangoDB](https://www.arangodb.com). - -Multi-model NoSQL database. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add arangodb https://github.com/hyperpolymath/asdf-arangodb-plugin.git -``` - -arangodb: - -```bash -# Show all installable versions -asdf list-all arangodb - -# Install specific version -asdf install arangodb latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global arangodb latest - -# Now arangodb commands are available -arangodb --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list arangodb - -# Set local version for current directory -asdf local arangodb - -# Uninstall a version -asdf uninstall arangodb -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-arangodb-plugin/SECURITY.adoc b/asdf-arangodb-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-arangodb-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-arangodb-plugin/SECURITY.md b/asdf-arangodb-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-arangodb-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/CODE_OF_CONDUCT.adoc b/asdf-augmenters/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..e94023c6 --- /dev/null +++ b/asdf-augmenters/CODE_OF_CONDUCT.adoc @@ -0,0 +1,339 @@ +== Code of Conduct + +=== Our Pledge + +We as members, contributors, and leaders pledge to make participation in +asdf-augmenters a harassment-free experience for everyone, regardless of +age, body size, visible or invisible disability, ethnicity, sex +characteristics, gender identity and expression, level of experience, +education, socio-economic status, nationality, personal appearance, +race, caste, colour, religion, or sexual identity and orientation. + +We pledge to act and interact in ways that contribute to an open, +welcoming, diverse, inclusive, and healthy community. + +We recognise that a thriving open source community requires +*psychological safety* — an environment where people can contribute, ask +questions, make mistakes, and learn without fear of ridicule or +retaliation. + +''''' + +=== Our Standards + +==== Expected Behaviour + +The following behaviours contribute to a positive environment: + +*Communication* - Using welcoming and inclusive language - Being +respectful of differing viewpoints and experiences - Giving and +gracefully accepting constructive feedback - Assuming good intent while +addressing impact - Communicating clearly and patiently, especially with +newcomers + +*Collaboration* - Focusing on what is best for the community - Showing +empathy and kindness toward other community members - Being +collaborative rather than competitive - Mentoring and supporting less +experienced contributors - Celebrating others’ contributions and +successes + +*Professionalism* - Accepting responsibility and apologising to those +affected by our mistakes - Learning from the experience and avoiding +repetition - Respecting others’ time and attention - Staying on topic in +project spaces - Following project guidelines and conventions + +*Accessibility* - Using plain language and avoiding unnecessary jargon - +Providing alt text for images and transcripts for audio/video - Being +patient with those using assistive technologies - Accommodating +different communication styles and needs - Recognising that not everyone +communicates the same way + +==== Unacceptable Behaviour + +The following behaviours are considered harassment and are unacceptable: + +*Harassment* - The use of sexualised language or imagery, and sexual +attention or advances of any kind - Trolling, insulting or derogatory +comments, and personal or political attacks - Public or private +harassment - Deliberate intimidation, stalking, or following (online or +in-person) - Unwelcome physical contact or simulated physical contact +(e.g., emoji) - Sustained disruption of talks, events, or online +discussions + +*Discrimination* - Discriminatory jokes and language - Posting or +threatening to post others’ personally identifying information +("`doxing`") - Advocating for, or encouraging, any of the above +behaviour - Microaggressions — subtle, often unintentional, +discriminatory comments or actions + +*Professional Misconduct* - Publishing others’ private information +without explicit permission - Misrepresenting affiliation or +contributions - Plagiarism or claiming credit for others’ work - +Retaliating against anyone who reports a Code of Conduct violation - +Other conduct which could reasonably be considered inappropriate in a +professional setting + +==== Grey Areas + +Some situations require judgement. When uncertain: + +* *Intent vs Impact*: Good intentions do not excuse harmful impact. +Focus on making things right. +* *Power Dynamics*: Those with more power (maintainers, employers, +experienced contributors) must be especially mindful of their impact. +* *Cultural Differences*: What’s acceptable varies by culture. When in +doubt, err on the side of caution and ask. +* *Humour*: Jokes at others’ expense are rarely funny to everyone. Punch +up, not down. + +''''' + +=== Scope + +This Code of Conduct applies within all community spaces, including: + +*Online Spaces* - Repository discussions, issues, and pull/merge +requests - Project chat channels (Matrix, Discord, Slack, IRC) - Mailing +lists and forums - Social media when representing the project - Video +calls and virtual meetings + +*In-Person Spaces* - Conferences, meetups, and events - Workshops and +training sessions - Any gathering where you represent the project + +*Representation* This Code of Conduct also applies when an individual is +officially representing the community in public spaces. Examples +include: + +* Using an official project email address +* Posting via an official social media account +* Acting as an appointed representative at an event +* Speaking on behalf of the project + +''''' + +=== Enforcement + +==== Reporting + +If you experience or witness unacceptable behaviour, or have any other +concerns, please report it as soon as possible. + +*How to Report* + +[width="99%",cols="30%,33%,37%",options="header",] +|=== +|Method |Details |Best For +|*Email* |j.d.a.jewell@open.ac.uk |Detailed reports, sensitive matters + +|*Private Message* |Contact any maintainer directly |Quick questions, +minor issues + +|*Anonymous Form* |[Link to form if available] |When you need anonymity +|=== + +*What to Include* + +* Your contact information (unless anonymous) +* Names/usernames of those involved +* Description of what happened +* When and where it occurred +* Any witnesses +* Any supporting evidence (screenshots, links) +* How you would like us to respond (if you have a preference) + +*What Happens Next* + +[arabic] +. You will receive acknowledgment within *\{\{RESPONSE_TIME}}* +. The \{\{CONDUCT_TEAM}} will review the report +. We may ask for additional information +. We will determine appropriate action +. We will inform you of the outcome (respecting others’ privacy) + +==== Confidentiality + +All reports will be handled with discretion: + +* Reporter identity is protected by default +* Details are shared only with those who need to know +* We will ask before naming you in any communication +* Anonymous reports are accepted and investigated + +==== Conflicts of Interest + +If a \{\{CONDUCT_TEAM}} member is involved in an incident: + +* They will recuse themselves from the process +* Another maintainer or external party will handle the report +* We will disclose any potential conflicts + +''''' + +=== Enforcement Guidelines + +The \{\{CONDUCT_TEAM}} will follow these guidelines in determining +consequences: + +==== 1. Correction + +*Community Impact*: Use of inappropriate language or other behaviour +deemed unprofessional or unwelcome. + +*Consequence*: A private, written warning providing clarity around the +nature of the violation and an explanation of why the behaviour was +inappropriate. A public apology may be requested. + +*Duration*: Immediate + +==== 2. Warning + +*Community Impact*: A violation through a single incident or series of +actions. + +*Consequence*: A warning with consequences for continued behaviour. No +interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, for a specified period. This +includes avoiding interactions in community spaces as well as external +channels like social media. Violating these terms may lead to a +temporary or permanent ban. + +*Duration*: 1-4 weeks + +==== 3. Temporary Ban + +*Community Impact*: A serious violation of community standards, +including sustained inappropriate behaviour. + +*Consequence*: A temporary ban from any sort of interaction or public +communication with the community for a specified period. No public or +private interaction with the people involved, including unsolicited +interaction with those enforcing the Code of Conduct, is allowed during +this period. Violating these terms may lead to a permanent ban. + +*Duration*: 1-6 months + +==== 4. Permanent Ban + +*Community Impact*: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behaviour, harassment of an +individual, or aggression toward or disparagement of classes of +individuals. + +*Consequence*: A permanent ban from any sort of public interaction +within the community. + +*Duration*: Permanent (with appeal rights after 12 months) + +==== Enforcement Across Perimeters + +For contributors with elevated access (Perimeter 2 or 1): + +[cols=",",options="header",] +|=== +|Level |Additional Consequence +|Correction |Noted in contributor record +|Warning |Access privileges may be temporarily reduced +|Temporary Ban |Access reduced to Perimeter 3 for ban duration +|Permanent Ban |All access revoked +|=== + +''''' + +=== Appeals + +If you believe an enforcement decision was made in error: + +[arabic] +. *Wait 7 days* after the decision (cooling-off period) +. *Email* j.d.a.jewell@open.ac.uk with subject line "`Appeal: [Original +Report ID]`" +. *Explain* why you believe the decision should be reconsidered +. *Provide* any new information not previously available + +*Appeals Process* + +* Appeals are reviewed by a different \{\{CONDUCT_TEAM}} member than the +original +* You will receive a response within 14 days +* The appeals decision is final +* You may only appeal once per incident + +*Grounds for Appeal* + +* Procedural errors in the original investigation +* New evidence not previously available +* Disproportionate response to the violation +* Misunderstanding of facts + +''''' + +=== Supporting Those Who Report + +We are committed to supporting those who report violations: + +*We Will* - Believe and take all reports seriously - Respect your +privacy and confidentiality preferences - Keep you informed of progress +(if you wish) - Take steps to protect you from retaliation - Provide +resources if you need support + +*We Will Not* - Require you to confront the person directly - Dismiss +reports without investigation - Reveal your identity without consent - +Tolerate retaliation against reporters - Rush you to make decisions + +''''' + +=== Prevention + +Beyond enforcement, we actively work to prevent issues: + +*Onboarding* - All contributors are expected to read this Code of +Conduct - Perimeter 2 applicants must confirm they’ve read and +understood it - Maintainers receive additional training on enforcement + +*Culture* - We model the behaviour we expect - We intervene early when +we see potential issues - We thank people for positive contributions - +We create opportunities for diverse voices + +*Review* - This Code of Conduct is reviewed annually - Community +feedback is welcomed - Changes are communicated clearly + +''''' + +=== Acknowledgments + +This Code of Conduct is adapted from: + +* https://www.contributor-covenant.org/[Contributor Covenant], version +2.1 +* https://www.djangoproject.com/conduct/[Django Code of Conduct] +* https://www.rust-lang.org/policies/code-of-conduct[Rust Code of +Conduct] +* https://www.python.org/psf/conduct/[Python Community Code of Conduct] + +We thank these communities for their leadership in creating welcoming +spaces. + +''''' + +=== Questions? + +If you have questions about this Code of Conduct: + +* Open a +https://github.com/hyperpolymath/asdf-augmenters/discussions[Discussion] +(for general questions) +* Email j.d.a.jewell@open.ac.uk (for private questions) +* Contact any maintainer directly + +''''' + +=== Summary + +*Be kind. Be respectful. Be collaborative.* + +We’re all here because we care about this project. Let’s make it a place +where everyone can do their best work. + +''''' + +Last updated: 2026 · Based on Contributor Covenant 2.1 diff --git a/asdf-augmenters/CODE_OF_CONDUCT.md b/asdf-augmenters/CODE_OF_CONDUCT.md deleted file mode 100644 index c7cc3495..00000000 --- a/asdf-augmenters/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,327 +0,0 @@ -# Code of Conduct - - - -## Our Pledge - -We as members, contributors, and leaders pledge to make participation in asdf-augmenters a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, colour, religion, or sexual identity and orientation. - -We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. - -We recognise that a thriving open source community requires **psychological safety** — an environment where people can contribute, ask questions, make mistakes, and learn without fear of ridicule or retaliation. - ---- - -## Our Standards - -### Expected Behaviour - -The following behaviours contribute to a positive environment: - -**Communication** -- Using welcoming and inclusive language -- Being respectful of differing viewpoints and experiences -- Giving and gracefully accepting constructive feedback -- Assuming good intent while addressing impact -- Communicating clearly and patiently, especially with newcomers - -**Collaboration** -- Focusing on what is best for the community -- Showing empathy and kindness toward other community members -- Being collaborative rather than competitive -- Mentoring and supporting less experienced contributors -- Celebrating others' contributions and successes - -**Professionalism** -- Accepting responsibility and apologising to those affected by our mistakes -- Learning from the experience and avoiding repetition -- Respecting others' time and attention -- Staying on topic in project spaces -- Following project guidelines and conventions - -**Accessibility** -- Using plain language and avoiding unnecessary jargon -- Providing alt text for images and transcripts for audio/video -- Being patient with those using assistive technologies -- Accommodating different communication styles and needs -- Recognising that not everyone communicates the same way - -### Unacceptable Behaviour - -The following behaviours are considered harassment and are unacceptable: - -**Harassment** -- The use of sexualised language or imagery, and sexual attention or advances of any kind -- Trolling, insulting or derogatory comments, and personal or political attacks -- Public or private harassment -- Deliberate intimidation, stalking, or following (online or in-person) -- Unwelcome physical contact or simulated physical contact (e.g., emoji) -- Sustained disruption of talks, events, or online discussions - -**Discrimination** -- Discriminatory jokes and language -- Posting or threatening to post others' personally identifying information ("doxing") -- Advocating for, or encouraging, any of the above behaviour -- Microaggressions — subtle, often unintentional, discriminatory comments or actions - -**Professional Misconduct** -- Publishing others' private information without explicit permission -- Misrepresenting affiliation or contributions -- Plagiarism or claiming credit for others' work -- Retaliating against anyone who reports a Code of Conduct violation -- Other conduct which could reasonably be considered inappropriate in a professional setting - -### Grey Areas - -Some situations require judgement. When uncertain: - -- **Intent vs Impact**: Good intentions do not excuse harmful impact. Focus on making things right. -- **Power Dynamics**: Those with more power (maintainers, employers, experienced contributors) must be especially mindful of their impact. -- **Cultural Differences**: What's acceptable varies by culture. When in doubt, err on the side of caution and ask. -- **Humour**: Jokes at others' expense are rarely funny to everyone. Punch up, not down. - ---- - -## Scope - -This Code of Conduct applies within all community spaces, including: - -**Online Spaces** -- Repository discussions, issues, and pull/merge requests -- Project chat channels (Matrix, Discord, Slack, IRC) -- Mailing lists and forums -- Social media when representing the project -- Video calls and virtual meetings - -**In-Person Spaces** -- Conferences, meetups, and events -- Workshops and training sessions -- Any gathering where you represent the project - -**Representation** -This Code of Conduct also applies when an individual is officially representing the community in public spaces. Examples include: - -- Using an official project email address -- Posting via an official social media account -- Acting as an appointed representative at an event -- Speaking on behalf of the project - ---- - -## Enforcement - -### Reporting - -If you experience or witness unacceptable behaviour, or have any other concerns, please report it as soon as possible. - -**How to Report** - -| Method | Details | Best For | -|--------|---------|----------| -| **Email** | j.d.a.jewell@open.ac.uk | Detailed reports, sensitive matters | -| **Private Message** | Contact any maintainer directly | Quick questions, minor issues | -| **Anonymous Form** | [Link to form if available] | When you need anonymity | - -**What to Include** - -- Your contact information (unless anonymous) -- Names/usernames of those involved -- Description of what happened -- When and where it occurred -- Any witnesses -- Any supporting evidence (screenshots, links) -- How you would like us to respond (if you have a preference) - -**What Happens Next** - -1. You will receive acknowledgment within **{{RESPONSE_TIME}}** -2. The {{CONDUCT_TEAM}} will review the report -3. We may ask for additional information -4. We will determine appropriate action -5. We will inform you of the outcome (respecting others' privacy) - -### Confidentiality - -All reports will be handled with discretion: - -- Reporter identity is protected by default -- Details are shared only with those who need to know -- We will ask before naming you in any communication -- Anonymous reports are accepted and investigated - -### Conflicts of Interest - -If a {{CONDUCT_TEAM}} member is involved in an incident: - -- They will recuse themselves from the process -- Another maintainer or external party will handle the report -- We will disclose any potential conflicts - ---- - -## Enforcement Guidelines - -The {{CONDUCT_TEAM}} will follow these guidelines in determining consequences: - -### 1. Correction - -**Community Impact**: Use of inappropriate language or other behaviour deemed unprofessional or unwelcome. - -**Consequence**: A private, written warning providing clarity around the nature of the violation and an explanation of why the behaviour was inappropriate. A public apology may be requested. - -**Duration**: Immediate - -### 2. Warning - -**Community Impact**: A violation through a single incident or series of actions. - -**Consequence**: A warning with consequences for continued behaviour. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. - -**Duration**: 1-4 weeks - -### 3. Temporary Ban - -**Community Impact**: A serious violation of community standards, including sustained inappropriate behaviour. - -**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. - -**Duration**: 1-6 months - -### 4. Permanent Ban - -**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behaviour, harassment of an individual, or aggression toward or disparagement of classes of individuals. - -**Consequence**: A permanent ban from any sort of public interaction within the community. - -**Duration**: Permanent (with appeal rights after 12 months) - -### Enforcement Across Perimeters - -For contributors with elevated access (Perimeter 2 or 1): - -| Level | Additional Consequence | -|-------|----------------------| -| Correction | Noted in contributor record | -| Warning | Access privileges may be temporarily reduced | -| Temporary Ban | Access reduced to Perimeter 3 for ban duration | -| Permanent Ban | All access revoked | - ---- - -## Appeals - -If you believe an enforcement decision was made in error: - -1. **Wait 7 days** after the decision (cooling-off period) -2. **Email** j.d.a.jewell@open.ac.uk with subject line "Appeal: [Original Report ID]" -3. **Explain** why you believe the decision should be reconsidered -4. **Provide** any new information not previously available - -**Appeals Process** - -- Appeals are reviewed by a different {{CONDUCT_TEAM}} member than the original -- You will receive a response within 14 days -- The appeals decision is final -- You may only appeal once per incident - -**Grounds for Appeal** - -- Procedural errors in the original investigation -- New evidence not previously available -- Disproportionate response to the violation -- Misunderstanding of facts - ---- - -## Supporting Those Who Report - -We are committed to supporting those who report violations: - -**We Will** -- Believe and take all reports seriously -- Respect your privacy and confidentiality preferences -- Keep you informed of progress (if you wish) -- Take steps to protect you from retaliation -- Provide resources if you need support - -**We Will Not** -- Require you to confront the person directly -- Dismiss reports without investigation -- Reveal your identity without consent -- Tolerate retaliation against reporters -- Rush you to make decisions - ---- - -## Prevention - -Beyond enforcement, we actively work to prevent issues: - -**Onboarding** -- All contributors are expected to read this Code of Conduct -- Perimeter 2 applicants must confirm they've read and understood it -- Maintainers receive additional training on enforcement - -**Culture** -- We model the behaviour we expect -- We intervene early when we see potential issues -- We thank people for positive contributions -- We create opportunities for diverse voices - -**Review** -- This Code of Conduct is reviewed annually -- Community feedback is welcomed -- Changes are communicated clearly - ---- - -## Acknowledgments - -This Code of Conduct is adapted from: - -- [Contributor Covenant](https://www.contributor-covenant.org/), version 2.1 -- [Django Code of Conduct](https://www.djangoproject.com/conduct/) -- [Rust Code of Conduct](https://www.rust-lang.org/policies/code-of-conduct) -- [Python Community Code of Conduct](https://www.python.org/psf/conduct/) - -We thank these communities for their leadership in creating welcoming spaces. - ---- - -## Questions? - -If you have questions about this Code of Conduct: - -- Open a [Discussion](https://github.com/hyperpolymath/asdf-augmenters/discussions) (for general questions) -- Email j.d.a.jewell@open.ac.uk (for private questions) -- Contact any maintainer directly - ---- - -## Summary - -**Be kind. Be respectful. Be collaborative.** - -We're all here because we care about this project. Let's make it a place where everyone can do their best work. - ---- - -Last updated: 2026 · Based on Contributor Covenant 2.1 diff --git a/asdf-augmenters/CONTRIBUTING.adoc b/asdf-augmenters/CONTRIBUTING.adoc new file mode 100644 index 00000000..32919195 --- /dev/null +++ b/asdf-augmenters/CONTRIBUTING.adoc @@ -0,0 +1,109 @@ +== Clone the repository + +git clone https://github.com/hyperpolymath/asdf-augmenters.git cd +asdf-augmenters + +== Using Guix (recommended for reproducibility) + +guix develop + +== Or using toolbox/distrobox + +toolbox create asdf-augmenters-dev toolbox enter asdf-augmenters-dev # +Install dependencies manually + +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-augmenters/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-augmenters/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-augmenters/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-augmenters/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-augmenters/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/CONTRIBUTING.md b/asdf-augmenters/CONTRIBUTING.md deleted file mode 100644 index be973470..00000000 --- a/asdf-augmenters/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-augmenters.git -cd asdf-augmenters - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-augmenters-dev -toolbox enter asdf-augmenters-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-augmenters/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-augmenters/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-augmenters/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-augmenters/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-augmenters/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/SECURITY.adoc b/asdf-augmenters/SECURITY.adoc new file mode 100644 index 00000000..22fe28ba --- /dev/null +++ b/asdf-augmenters/SECURITY.adoc @@ -0,0 +1,452 @@ +== Security Policy + +We take security seriously. We appreciate your efforts to responsibly +disclose vulnerabilities and will make every effort to acknowledge your +contributions. + +=== Table of Contents + +* link:#reporting-a-vulnerability[Reporting a Vulnerability] +* link:#what-to-include[What to Include] +* link:#response-timeline[Response Timeline] +* link:#disclosure-policy[Disclosure Policy] +* link:#scope[Scope] +* link:#safe-harbour[Safe Harbour] +* link:#recognition[Recognition] +* link:#security-updates[Security Updates] +* link:#security-best-practices[Security Best Practices] + +''''' + +=== Reporting a Vulnerability + +==== Preferred Method: GitHub Security Advisories + +The preferred method for reporting security vulnerabilities is through +GitHub’s Security Advisory feature: + +[arabic] +. Navigate to +https://github.com/hyperpolymath/asdf-augmenters/security/advisories/new[Report +a Vulnerability] +. Click *"`Report a vulnerability`"* +. Complete the form with as much detail as possible +. Submit — we’ll receive a private notification + +This method ensures: + +* End-to-end encryption of your report +* Private discussion space for collaboration +* Coordinated disclosure tooling +* Automatic credit when the advisory is published + +==== Alternative: Encrypted Email + +If you cannot use GitHub Security Advisories, you may email us directly: + +[width="100%",cols="50%,50%",] +|=== +|*Email* |j.d.a.jewell@open.ac.uk +|*PGP Key* |https://hyperpolymath.github.io/pgp.asc[Download Public Key] +|*Fingerprint* |`+TBD+` +|=== + +[source,bash] +---- +# Import our PGP key +curl -sSL https://hyperpolymath.github.io/pgp.asc | gpg --import + +# Verify fingerprint +gpg --fingerprint j.d.a.jewell@open.ac.uk + +# Encrypt your report +gpg --armor --encrypt --recipient j.d.a.jewell@open.ac.uk report.txt +---- + +____ +*⚠️ Important:* Do not report security vulnerabilities through public +GitHub issues, pull requests, discussions, or social media. +____ + +''''' + +=== What to Include + +A good vulnerability report helps us understand and reproduce the issue +quickly. + +==== Required Information + +* *Description*: Clear explanation of the vulnerability +* *Impact*: What an attacker could achieve (confidentiality, integrity, +availability) +* *Affected versions*: Which versions/commits are affected +* *Reproduction steps*: Detailed steps to reproduce the issue + +==== Helpful Additional Information + +* *Proof of concept*: Code, scripts, or screenshots demonstrating the +vulnerability +* *Attack scenario*: Realistic attack scenario showing exploitability +* *CVSS score*: Your assessment of severity (use +https://www.first.org/cvss/calculator/3.1[CVSS 3.1 Calculator]) +* *CWE ID*: Common Weakness Enumeration identifier if known +* *Suggested fix*: If you have ideas for remediation +* *References*: Links to related vulnerabilities, research, or +advisories + +==== Example Report Structure + +[source,markdown] +---- +## Summary +[One-sentence description of the vulnerability] + +## Vulnerability Type +[e.g., SQL Injection, XSS, SSRF, Path Traversal, etc.] + +## Affected Component +[File path, function name, API endpoint, etc.] + +## Affected Versions +[Version range or specific commits] + +## Severity Assessment +- CVSS 3.1 Score: [X.X] +- CVSS Vector: [CVSS:3.1/AV:X/AC:X/PR:X/UI:X/S:X/C:X/I:X/A:X] + +## Description +[Detailed technical description] + +## Steps to Reproduce +1. [First step] +2. [Second step] +3. [...] + +## Proof of Concept +[Code, curl commands, screenshots, etc.] + +## Impact +[What can an attacker achieve?] + +## Suggested Remediation +[Optional: your ideas for fixing] + +## References +[Links to related issues, CVEs, research] +---- + +''''' + +=== Response Timeline + +We commit to the following response times: + +[width="100%",cols="24%,35%,41%",options="header",] +|=== +|Stage |Timeframe |Description +|*Initial Response* |48 hours |We acknowledge receipt and confirm we’re +investigating + +|*Triage* |7 days |We assess severity, confirm the vulnerability, and +estimate timeline + +|*Status Update* |Every 7 days |Regular updates on remediation progress + +|*Resolution* |90 days |Target for fix development and release (complex +issues may take longer) + +|*Disclosure* |90 days |Public disclosure after fix is available +(coordinated with you) +|=== + +____ +*Note:* These are targets, not guarantees. Complex vulnerabilities may +require more time. We’ll communicate openly about any delays. +____ + +''''' + +=== Disclosure Policy + +We follow *coordinated disclosure* (also known as responsible +disclosure): + +[arabic] +. *You report* the vulnerability privately +. *We acknowledge* and begin investigation +. *We develop* a fix and prepare a release +. *We coordinate* disclosure timing with you +. *We publish* security advisory and fix simultaneously +. *You may publish* your research after disclosure + +==== Our Commitments + +* We will not take legal action against researchers who follow this +policy +* We will work with you to understand and resolve the issue +* We will credit you in the security advisory (unless you prefer +anonymity) +* We will notify you before public disclosure +* We will publish advisories with sufficient detail for users to assess +risk + +==== Your Commitments + +* Report vulnerabilities promptly after discovery +* Give us reasonable time to address the issue before disclosure +* Do not access, modify, or delete data beyond what’s necessary to +demonstrate the vulnerability +* Do not degrade service availability (no DoS testing on production) +* Do not share vulnerability details with others until coordinated +disclosure + +==== Disclosure Timeline + +.... +Day 0 You report vulnerability +Day 1-2 We acknowledge receipt +Day 7 We confirm vulnerability and share initial assessment +Day 7-90 We develop and test fix +Day 90 Coordinated public disclosure + (earlier if fix is ready; later by mutual agreement) +.... + +If we cannot reach agreement on disclosure timing, we default to 90 days +from your initial report. + +''''' + +=== Scope + +==== In Scope ✅ + +The following are within scope for security research: + +* This repository (`+hyperpolymath/asdf-augmenters+`) and all its code +* Official releases and packages published from this repository +* Documentation that could lead to security issues +* Build and deployment configurations in this repository +* Dependencies (report here, we’ll coordinate with upstream) + +==== Out of Scope ❌ + +The following are *not* in scope: + +* Third-party services we integrate with (report directly to them) +* Social engineering attacks against maintainers +* Physical security +* Denial of service attacks against production infrastructure +* Spam, phishing, or other non-technical attacks +* Issues already reported or publicly known +* Theoretical vulnerabilities without proof of concept + +==== Qualifying Vulnerabilities + +We’re particularly interested in: + +* Remote code execution +* SQL injection, command injection, code injection +* Authentication/authorisation bypass +* Cross-site scripting (XSS) and cross-site request forgery (CSRF) +* Server-side request forgery (SSRF) +* Path traversal / local file inclusion +* Information disclosure (credentials, PII, secrets) +* Cryptographic weaknesses +* Deserialisation vulnerabilities +* Memory safety issues (buffer overflows, use-after-free, etc.) +* Supply chain vulnerabilities (dependency confusion, etc.) +* Significant logic flaws + +==== Non-Qualifying Issues + +The following generally do not qualify as security vulnerabilities: + +* Missing security headers on non-sensitive pages +* Clickjacking on pages without sensitive actions +* Self-XSS (requires victim to paste code) +* Missing rate limiting (unless it enables a specific attack) +* Username/email enumeration (unless high-risk context) +* Missing cookie flags on non-sensitive cookies +* Software version disclosure +* Verbose error messages (unless exposing secrets) +* Best practice deviations without demonstrable impact + +''''' + +=== Safe Harbour + +We support security research conducted in good faith. + +==== Our Promise + +If you conduct security research in accordance with this policy: + +* ✅ We will not initiate legal action against you +* ✅ We will not report your activity to law enforcement +* ✅ We will work with you in good faith to resolve issues +* ✅ We consider your research authorised under the Computer Fraud and +Abuse Act (CFAA), UK Computer Misuse Act, and similar laws +* ✅ We waive any potential claim against you for circumvention of +security controls + +==== Good Faith Requirements + +To qualify for safe harbour, you must: + +* Comply with this security policy +* Report vulnerabilities promptly +* Avoid privacy violations (do not access others’ data) +* Avoid service degradation (no destructive testing) +* Not exploit vulnerabilities beyond proof-of-concept +* Not use vulnerabilities for profit (beyond bug bounties where offered) + +____ +*⚠️ Important:* This safe harbour does not extend to third-party +systems. Always check their policies before testing. +____ + +''''' + +=== Recognition + +We believe in recognising security researchers who help us improve. + +==== Hall of Fame + +Researchers who report valid vulnerabilities will be acknowledged in our +link:SECURITY-ACKNOWLEDGMENTS.md[Security Acknowledgments] (unless they +prefer anonymity). + +Recognition includes: + +* Your name (or chosen alias) +* Link to your website/profile (optional) +* Brief description of the vulnerability class +* Date of report + +==== What We Offer + +* ✅ Public credit in security advisories +* ✅ Acknowledgment in release notes +* ✅ Entry in our Hall of Fame +* ✅ Reference/recommendation letter upon request (for significant +findings) + +==== What We Don’t Currently Offer + +* ❌ Monetary bug bounties +* ❌ Hardware or swag +* ❌ Paid security research contracts + +____ +*Note:* We’re a community project with limited resources. Your +contributions help everyone who uses this software. +____ + +''''' + +=== Security Updates + +==== Receiving Updates + +To stay informed about security updates: + +* *Watch this repository*: Click "`Watch`" → "`Custom`" → Select +"`Security alerts`" +* *GitHub Security Advisories*: Published at +https://github.com/hyperpolymath/asdf-augmenters/security/advisories[Security +Advisories] +* *Release notes*: Security fixes noted in link:CHANGELOG.md[CHANGELOG] + +==== Update Policy + +[cols=",",options="header",] +|=== +|Severity |Response +|*Critical/High* |Patch release as soon as fix is ready +|*Medium* |Included in next scheduled release (or earlier) +|*Low* |Included in next scheduled release +|=== + +==== Supported Versions + +[cols=",,",options="header",] +|=== +|Version |Supported |Notes +|`+main+` branch |✅ Yes |Latest development +|Latest release |✅ Yes |Current stable +|Previous minor release |✅ Yes |Security fixes backported +|Older versions |❌ No |Please upgrade +|=== + +''''' + +=== Security Best Practices + +When using asdf-augmenters, we recommend: + +==== General + +* Keep dependencies up to date +* Use the latest stable release +* Subscribe to security notifications +* Review configuration against security documentation +* Follow principle of least privilege + +==== For Contributors + +* Never commit secrets, credentials, or API keys +* Use signed commits (`+git config commit.gpgsign true+`) +* Review dependencies before adding them +* Run security linters locally before pushing +* Report any concerns about existing code + +''''' + +=== Additional Resources + +* https://hyperpolymath.github.io/pgp.asc[Our PGP Public Key] +* https://github.com/hyperpolymath/asdf-augmenters/security/advisories[Security +Advisories] +* link:CHANGELOG.md[Changelog] +* link:CONTRIBUTING.md[Contributing Guidelines] +* https://cve.mitre.org/[CVE Database] +* https://www.first.org/cvss/calculator/3.1[CVSS Calculator] + +''''' + +=== Contact + +[width="100%",cols="50%,50%",options="header",] +|=== +|Purpose |Contact +|*Security issues* +|https://github.com/hyperpolymath/asdf-augmenters/security/advisories/new[Report +via GitHub] or j.d.a.jewell@open.ac.uk + +|*General questions* +|https://github.com/hyperpolymath/asdf-augmenters/discussions[GitHub +Discussions] + +|*Other enquiries* |See link:README.md[README] for contact information +|=== + +''''' + +=== Policy Changes + +This security policy may be updated from time to time. Significant +changes will be: + +* Committed to this repository with a clear commit message +* Noted in the changelog +* Announced via GitHub Discussions (for major changes) + +''''' + +_Thank you for helping keep asdf-augmenters and its users safe._ 🛡️ + +''''' + +Last updated: 2026 · Policy version: 1.0.0 diff --git a/asdf-augmenters/SECURITY.md b/asdf-augmenters/SECURITY.md deleted file mode 100644 index c9a4c16e..00000000 --- a/asdf-augmenters/SECURITY.md +++ /dev/null @@ -1,406 +0,0 @@ -# Security Policy - - - -We take security seriously. We appreciate your efforts to responsibly disclose vulnerabilities and will make every effort to acknowledge your contributions. - -## Table of Contents - -- [Reporting a Vulnerability](#reporting-a-vulnerability) -- [What to Include](#what-to-include) -- [Response Timeline](#response-timeline) -- [Disclosure Policy](#disclosure-policy) -- [Scope](#scope) -- [Safe Harbour](#safe-harbour) -- [Recognition](#recognition) -- [Security Updates](#security-updates) -- [Security Best Practices](#security-best-practices) - ---- - -## Reporting a Vulnerability - -### Preferred Method: GitHub Security Advisories - -The preferred method for reporting security vulnerabilities is through GitHub's Security Advisory feature: - -1. Navigate to [Report a Vulnerability](https://github.com/hyperpolymath/asdf-augmenters/security/advisories/new) -2. Click **"Report a vulnerability"** -3. Complete the form with as much detail as possible -4. Submit — we'll receive a private notification - -This method ensures: - -- End-to-end encryption of your report -- Private discussion space for collaboration -- Coordinated disclosure tooling -- Automatic credit when the advisory is published - -### Alternative: Encrypted Email - -If you cannot use GitHub Security Advisories, you may email us directly: - -| | | -|---|---| -| **Email** | j.d.a.jewell@open.ac.uk | -| **PGP Key** | [Download Public Key](https://hyperpolymath.github.io/pgp.asc) | -| **Fingerprint** | `TBD` | - -```bash -# Import our PGP key -curl -sSL https://hyperpolymath.github.io/pgp.asc | gpg --import - -# Verify fingerprint -gpg --fingerprint j.d.a.jewell@open.ac.uk - -# Encrypt your report -gpg --armor --encrypt --recipient j.d.a.jewell@open.ac.uk report.txt -``` - -> **⚠️ Important:** Do not report security vulnerabilities through public GitHub issues, pull requests, discussions, or social media. - ---- - -## What to Include - -A good vulnerability report helps us understand and reproduce the issue quickly. - -### Required Information - -- **Description**: Clear explanation of the vulnerability -- **Impact**: What an attacker could achieve (confidentiality, integrity, availability) -- **Affected versions**: Which versions/commits are affected -- **Reproduction steps**: Detailed steps to reproduce the issue - -### Helpful Additional Information - -- **Proof of concept**: Code, scripts, or screenshots demonstrating the vulnerability -- **Attack scenario**: Realistic attack scenario showing exploitability -- **CVSS score**: Your assessment of severity (use [CVSS 3.1 Calculator](https://www.first.org/cvss/calculator/3.1)) -- **CWE ID**: Common Weakness Enumeration identifier if known -- **Suggested fix**: If you have ideas for remediation -- **References**: Links to related vulnerabilities, research, or advisories - -### Example Report Structure - -```markdown -## Summary -[One-sentence description of the vulnerability] - -## Vulnerability Type -[e.g., SQL Injection, XSS, SSRF, Path Traversal, etc.] - -## Affected Component -[File path, function name, API endpoint, etc.] - -## Affected Versions -[Version range or specific commits] - -## Severity Assessment -- CVSS 3.1 Score: [X.X] -- CVSS Vector: [CVSS:3.1/AV:X/AC:X/PR:X/UI:X/S:X/C:X/I:X/A:X] - -## Description -[Detailed technical description] - -## Steps to Reproduce -1. [First step] -2. [Second step] -3. [...] - -## Proof of Concept -[Code, curl commands, screenshots, etc.] - -## Impact -[What can an attacker achieve?] - -## Suggested Remediation -[Optional: your ideas for fixing] - -## References -[Links to related issues, CVEs, research] -``` - ---- - -## Response Timeline - -We commit to the following response times: - -| Stage | Timeframe | Description | -|-------|-----------|-------------| -| **Initial Response** | 48 hours | We acknowledge receipt and confirm we're investigating | -| **Triage** | 7 days | We assess severity, confirm the vulnerability, and estimate timeline | -| **Status Update** | Every 7 days | Regular updates on remediation progress | -| **Resolution** | 90 days | Target for fix development and release (complex issues may take longer) | -| **Disclosure** | 90 days | Public disclosure after fix is available (coordinated with you) | - -> **Note:** These are targets, not guarantees. Complex vulnerabilities may require more time. We'll communicate openly about any delays. - ---- - -## Disclosure Policy - -We follow **coordinated disclosure** (also known as responsible disclosure): - -1. **You report** the vulnerability privately -2. **We acknowledge** and begin investigation -3. **We develop** a fix and prepare a release -4. **We coordinate** disclosure timing with you -5. **We publish** security advisory and fix simultaneously -6. **You may publish** your research after disclosure - -### Our Commitments - -- We will not take legal action against researchers who follow this policy -- We will work with you to understand and resolve the issue -- We will credit you in the security advisory (unless you prefer anonymity) -- We will notify you before public disclosure -- We will publish advisories with sufficient detail for users to assess risk - -### Your Commitments - -- Report vulnerabilities promptly after discovery -- Give us reasonable time to address the issue before disclosure -- Do not access, modify, or delete data beyond what's necessary to demonstrate the vulnerability -- Do not degrade service availability (no DoS testing on production) -- Do not share vulnerability details with others until coordinated disclosure - -### Disclosure Timeline - -``` -Day 0 You report vulnerability -Day 1-2 We acknowledge receipt -Day 7 We confirm vulnerability and share initial assessment -Day 7-90 We develop and test fix -Day 90 Coordinated public disclosure - (earlier if fix is ready; later by mutual agreement) -``` - -If we cannot reach agreement on disclosure timing, we default to 90 days from your initial report. - ---- - -## Scope - -### In Scope ✅ - -The following are within scope for security research: - -- This repository (`hyperpolymath/asdf-augmenters`) and all its code -- Official releases and packages published from this repository -- Documentation that could lead to security issues -- Build and deployment configurations in this repository -- Dependencies (report here, we'll coordinate with upstream) - -### Out of Scope ❌ - -The following are **not** in scope: - -- Third-party services we integrate with (report directly to them) -- Social engineering attacks against maintainers -- Physical security -- Denial of service attacks against production infrastructure -- Spam, phishing, or other non-technical attacks -- Issues already reported or publicly known -- Theoretical vulnerabilities without proof of concept - -### Qualifying Vulnerabilities - -We're particularly interested in: - -- Remote code execution -- SQL injection, command injection, code injection -- Authentication/authorisation bypass -- Cross-site scripting (XSS) and cross-site request forgery (CSRF) -- Server-side request forgery (SSRF) -- Path traversal / local file inclusion -- Information disclosure (credentials, PII, secrets) -- Cryptographic weaknesses -- Deserialisation vulnerabilities -- Memory safety issues (buffer overflows, use-after-free, etc.) -- Supply chain vulnerabilities (dependency confusion, etc.) -- Significant logic flaws - -### Non-Qualifying Issues - -The following generally do not qualify as security vulnerabilities: - -- Missing security headers on non-sensitive pages -- Clickjacking on pages without sensitive actions -- Self-XSS (requires victim to paste code) -- Missing rate limiting (unless it enables a specific attack) -- Username/email enumeration (unless high-risk context) -- Missing cookie flags on non-sensitive cookies -- Software version disclosure -- Verbose error messages (unless exposing secrets) -- Best practice deviations without demonstrable impact - ---- - -## Safe Harbour - -We support security research conducted in good faith. - -### Our Promise - -If you conduct security research in accordance with this policy: - -- ✅ We will not initiate legal action against you -- ✅ We will not report your activity to law enforcement -- ✅ We will work with you in good faith to resolve issues -- ✅ We consider your research authorised under the Computer Fraud and Abuse Act (CFAA), UK Computer Misuse Act, and similar laws -- ✅ We waive any potential claim against you for circumvention of security controls - -### Good Faith Requirements - -To qualify for safe harbour, you must: - -- Comply with this security policy -- Report vulnerabilities promptly -- Avoid privacy violations (do not access others' data) -- Avoid service degradation (no destructive testing) -- Not exploit vulnerabilities beyond proof-of-concept -- Not use vulnerabilities for profit (beyond bug bounties where offered) - -> **⚠️ Important:** This safe harbour does not extend to third-party systems. Always check their policies before testing. - ---- - -## Recognition - -We believe in recognising security researchers who help us improve. - -### Hall of Fame - -Researchers who report valid vulnerabilities will be acknowledged in our [Security Acknowledgments](SECURITY-ACKNOWLEDGMENTS.md) (unless they prefer anonymity). - -Recognition includes: - -- Your name (or chosen alias) -- Link to your website/profile (optional) -- Brief description of the vulnerability class -- Date of report - -### What We Offer - -- ✅ Public credit in security advisories -- ✅ Acknowledgment in release notes -- ✅ Entry in our Hall of Fame -- ✅ Reference/recommendation letter upon request (for significant findings) - -### What We Don't Currently Offer - -- ❌ Monetary bug bounties -- ❌ Hardware or swag -- ❌ Paid security research contracts - -> **Note:** We're a community project with limited resources. Your contributions help everyone who uses this software. - ---- - -## Security Updates - -### Receiving Updates - -To stay informed about security updates: - -- **Watch this repository**: Click "Watch" → "Custom" → Select "Security alerts" -- **GitHub Security Advisories**: Published at [Security Advisories](https://github.com/hyperpolymath/asdf-augmenters/security/advisories) -- **Release notes**: Security fixes noted in [CHANGELOG](CHANGELOG.md) - -### Update Policy - -| Severity | Response | -|----------|----------| -| **Critical/High** | Patch release as soon as fix is ready | -| **Medium** | Included in next scheduled release (or earlier) | -| **Low** | Included in next scheduled release | - -### Supported Versions - - - -| Version | Supported | Notes | -|---------|-----------|-------| -| `main` branch | ✅ Yes | Latest development | -| Latest release | ✅ Yes | Current stable | -| Previous minor release | ✅ Yes | Security fixes backported | -| Older versions | ❌ No | Please upgrade | - ---- - -## Security Best Practices - -When using asdf-augmenters, we recommend: - -### General - -- Keep dependencies up to date -- Use the latest stable release -- Subscribe to security notifications -- Review configuration against security documentation -- Follow principle of least privilege - -### For Contributors - -- Never commit secrets, credentials, or API keys -- Use signed commits (`git config commit.gpgsign true`) -- Review dependencies before adding them -- Run security linters locally before pushing -- Report any concerns about existing code - ---- - -## Additional Resources - -- [Our PGP Public Key](https://hyperpolymath.github.io/pgp.asc) -- [Security Advisories](https://github.com/hyperpolymath/asdf-augmenters/security/advisories) -- [Changelog](CHANGELOG.md) -- [Contributing Guidelines](CONTRIBUTING.md) -- [CVE Database](https://cve.mitre.org/) -- [CVSS Calculator](https://www.first.org/cvss/calculator/3.1) - ---- - -## Contact - -| Purpose | Contact | -|---------|---------| -| **Security issues** | [Report via GitHub](https://github.com/hyperpolymath/asdf-augmenters/security/advisories/new) or j.d.a.jewell@open.ac.uk | -| **General questions** | [GitHub Discussions](https://github.com/hyperpolymath/asdf-augmenters/discussions) | -| **Other enquiries** | See [README](README.md) for contact information | - ---- - -## Policy Changes - -This security policy may be updated from time to time. Significant changes will be: - -- Committed to this repository with a clear commit message -- Noted in the changelog -- Announced via GitHub Discussions (for major changes) - ---- - -*Thank you for helping keep asdf-augmenters and its users safe.* 🛡️ - ---- - -Last updated: 2026 · Policy version: 1.0.0 diff --git a/asdf-augmenters/TOPOLOGY.adoc b/asdf-augmenters/TOPOLOGY.adoc new file mode 100644 index 00000000..543eb3a5 --- /dev/null +++ b/asdf-augmenters/TOPOLOGY.adoc @@ -0,0 +1,36 @@ +== TOPOLOGY – asdf-augmenters + +=== System Architecture + +.... +asdf-augmenters/ +├── .machine_readable/ # RSR state files +├── .github/workflows/ # CI/CD +├── contractiles/ # RSR contractile agreements +├── asdf-acceleration-middleware/ # Performance acceleration layer for asdf +├── asdf-control-tower/ # Centralized management and orchestration +├── asdf-ghjk/ # GitHub-based plugin management +├── asdf-metaiconic-plugin/ # Metaiconic integration for asdf +├── asdf-plugin-collection/ # Plugin collection management +├── asdf-plugin-configurator/ # Plugin configuration tooling +├── asdf-security-plugin/ # Security scanning and verification +├── asdf-ui-plugin/ # UI for asdf plugin management +├── README.adoc # Overview +└── Justfile # Task runner +.... + +=== Completion Dashboard + +[cols=",,",options="header",] +|=== +|Component |Status |Progress +|RSR Structure |Active |`+████████░░+` 80% +|Augmenter Components (8) |Active |`+██████████+` 100% +|Documentation |Active |`+██████░░░░+` 60% +|=== + +=== Key Dependencies + +* RSR Template: `+rsr-template-repo+` +* Runtime: `+asdf+` version manager +* Sibling: `+asdf-tool-plugins+` diff --git a/asdf-augmenters/TOPOLOGY.md b/asdf-augmenters/TOPOLOGY.md deleted file mode 100644 index 5b778188..00000000 --- a/asdf-augmenters/TOPOLOGY.md +++ /dev/null @@ -1,38 +0,0 @@ - - - - -# TOPOLOGY -- asdf-augmenters - -## System Architecture - -``` -asdf-augmenters/ -├── .machine_readable/ # RSR state files -├── .github/workflows/ # CI/CD -├── contractiles/ # RSR contractile agreements -├── asdf-acceleration-middleware/ # Performance acceleration layer for asdf -├── asdf-control-tower/ # Centralized management and orchestration -├── asdf-ghjk/ # GitHub-based plugin management -├── asdf-metaiconic-plugin/ # Metaiconic integration for asdf -├── asdf-plugin-collection/ # Plugin collection management -├── asdf-plugin-configurator/ # Plugin configuration tooling -├── asdf-security-plugin/ # Security scanning and verification -├── asdf-ui-plugin/ # UI for asdf plugin management -├── README.adoc # Overview -└── Justfile # Task runner -``` - -## Completion Dashboard - -| Component | Status | Progress | -|-----------|--------|----------| -| RSR Structure | Active | `████████░░` 80% | -| Augmenter Components (8) | Active | `██████████` 100% | -| Documentation | Active | `██████░░░░` 60% | - -## Key Dependencies - -- RSR Template: `rsr-template-repo` -- Runtime: `asdf` version manager -- Sibling: `asdf-tool-plugins` diff --git a/asdf-augmenters/asdf-acceleration-middleware/ABI-FFI-README.adoc b/asdf-augmenters/asdf-acceleration-middleware/ABI-FFI-README.adoc new file mode 100644 index 00000000..c75b6978 --- /dev/null +++ b/asdf-augmenters/asdf-acceleration-middleware/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== ACCELERATION_MIDDLEWARE ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/acceleration-middleware.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libacceleration-middleware.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +acceleration-middleware/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── acceleration-middleware.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── acceleration-middleware.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/acceleration-middleware.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "acceleration-middleware.h" + +int main() { + void* handle = acceleration-middleware_init(); + if (!handle) return 1; + + int result = acceleration-middleware_process(handle, 42); + if (result != 0) { + const char* err = acceleration-middleware_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + acceleration-middleware_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lacceleration-middleware -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import ACCELERATION_MIDDLEWARE.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "acceleration-middleware")] +extern "C" { + fn acceleration-middleware_init() -> *mut std::ffi::c_void; + fn acceleration-middleware_free(handle: *mut std::ffi::c_void); + fn acceleration-middleware_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = acceleration-middleware_init(); + assert!(!handle.is_null()); + + let result = acceleration-middleware_process(handle, 42); + assert_eq!(result, 0); + + acceleration-middleware_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libacceleration-middleware = "libacceleration-middleware" + +function init() + handle = ccall((:acceleration-middleware_init, libacceleration-middleware), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:acceleration-middleware_process, libacceleration-middleware), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:acceleration-middleware_free, libacceleration-middleware), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/acceleration-middleware.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-acceleration-middleware/ABI-FFI-README.md b/asdf-augmenters/asdf-acceleration-middleware/ABI-FFI-README.md deleted file mode 100644 index 4ea6bbd7..00000000 --- a/asdf-augmenters/asdf-acceleration-middleware/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# ACCELERATION_MIDDLEWARE ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/acceleration-middleware.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libacceleration-middleware.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -acceleration-middleware/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── acceleration-middleware.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── acceleration-middleware.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/acceleration-middleware.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "acceleration-middleware.h" - -int main() { - void* handle = acceleration-middleware_init(); - if (!handle) return 1; - - int result = acceleration-middleware_process(handle, 42); - if (result != 0) { - const char* err = acceleration-middleware_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - acceleration-middleware_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lacceleration-middleware -L./zig-out/lib -``` - -### From Idris2 - -```idris -import ACCELERATION_MIDDLEWARE.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "acceleration-middleware")] -extern "C" { - fn acceleration-middleware_init() -> *mut std::ffi::c_void; - fn acceleration-middleware_free(handle: *mut std::ffi::c_void); - fn acceleration-middleware_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = acceleration-middleware_init(); - assert!(!handle.is_null()); - - let result = acceleration-middleware_process(handle, 42); - assert_eq!(result, 0); - - acceleration-middleware_free(handle); - } -} -``` - -### From Julia - -```julia -const libacceleration-middleware = "libacceleration-middleware" - -function init() - handle = ccall((:acceleration-middleware_init, libacceleration-middleware), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:acceleration-middleware_process, libacceleration-middleware), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:acceleration-middleware_free, libacceleration-middleware), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/acceleration-middleware.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-acceleration-middleware/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-acceleration-middleware/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..3895211c --- /dev/null +++ b/asdf-augmenters/asdf-acceleration-middleware/CODE_OF_CONDUCT.adoc @@ -0,0 +1,176 @@ +== Code of Conduct + +=== Our Pledge + +We as members, contributors, and leaders pledge to make participation in +our community a harassment-free experience for everyone, regardless of +age, body size, visible or invisible disability, ethnicity, sex +characteristics, gender identity and expression, level of experience, +education, socio-economic status, nationality, personal appearance, +race, caste, color, religion, or sexual identity and orientation. + +We pledge to act and interact in ways that contribute to an open, +welcoming, diverse, inclusive, and healthy community. + +=== Our Standards + +==== Examples of behavior that contributes to a positive environment: + +* ✅ Demonstrating empathy and kindness toward other people +* ✅ Being respectful of differing opinions, viewpoints, and experiences +* ✅ Giving and gracefully accepting constructive feedback +* ✅ Accepting responsibility and apologizing to those affected by our +mistakes, and learning from the experience +* ✅ Focusing on what is best not just for us as individuals, but for +the overall community +* ✅ Using welcoming and inclusive language +* ✅ Respecting people’s boundaries and privacy +* ✅ Assuming good intent + +==== Examples of unacceptable behavior: + +* ❌ The use of sexualized language or imagery, and sexual attention or +advances of any kind +* ❌ Trolling, insulting or derogatory comments, and personal or +political attacks +* ❌ Public or private harassment +* ❌ Publishing others’ private information, such as a physical or email +address, without their explicit permission +* ❌ Other conduct which could reasonably be considered inappropriate in +a professional setting +* ❌ Dismissing or attacking minority viewpoints +* ❌ Pattern of boundary violations + +=== Emotional Safety (Palimpsest License Principles) + +In alignment with the Palimpsest License emotional safety clause: + +==== Attribution and Recognition + +* Contributors maintain the right to have their work acknowledged +* No erasure of historical contributions +* Maintain visible chain of authorship +* Credit original ideas and implementations + +==== Reversibility and Autonomy + +* Respect people’s right to fork and maintain alternatives +* No lock-in or coercive practices +* Support migration and portability +* Welcome healthy competition + +==== Psychological Safety + +* Create space for learning and mistakes +* Reduce anxiety through clear processes +* Support experimentation +* Celebrate incremental progress + +=== Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our +standards of acceptable behavior and will take appropriate and fair +corrective action in response to any behavior that they deem +inappropriate, threatening, offensive, or harmful. + +Community leaders have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other +contributions that are not aligned to this Code of Conduct, and will +communicate reasons for moderation decisions when appropriate. + +=== Scope + +This Code of Conduct applies within all community spaces, and also +applies when an individual is officially representing the community in +public spaces. Examples of representing our community include using an +official e-mail address, posting via an official social media account, +or acting as an appointed representative at an online or offline event. + +=== Enforcement + +==== Reporting + +Instances of abusive, harassing, or otherwise unacceptable behavior may +be reported to the community leaders responsible for enforcement at the +contact information listed in MAINTAINERS.md. + +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security +of the reporter of any incident. + +==== Process + +[arabic] +. *Report*: Submit to maintainers (see MAINTAINERS.md) +. *Acknowledgment*: Within 48 hours +. *Investigation*: Gather facts from all parties +. *Decision*: Within 7 days +. *Appeal*: Available within 14 days + +=== Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in +determining the consequences for any action they deem in violation of +this Code of Conduct: + +==== 1. Correction + +*Community Impact*: Use of inappropriate language or other behavior +deemed unprofessional or unwelcome in the community. + +*Consequence*: A private, written warning from community leaders, +providing clarity around the nature of the violation and an explanation +of why the behavior was inappropriate. A public apology may be +requested. + +==== 2. Warning + +*Community Impact*: A violation through a single incident or series of +actions. + +*Consequence*: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, for a specified period of +time. This includes avoiding interactions in community spaces as well as +external channels like social media. Violating these terms may lead to a +temporary or permanent ban. + +==== 3. Temporary Ban + +*Community Impact*: A serious violation of community standards, +including sustained inappropriate behavior. + +*Consequence*: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No +public or private interaction with the people involved, including +unsolicited interaction with those enforcing the Code of Conduct, is +allowed during this period. Violating these terms may lead to a +permanent ban. + +==== 4. Permanent Ban + +*Community Impact*: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of +individuals. + +*Consequence*: A permanent ban from any sort of public interaction +within the community. + +=== Attribution + +This Code of Conduct is adapted from: - +https://www.contributor-covenant.org[Contributor Covenant], version 2.1 +- Palimpsest License emotional safety principles - +https://www.rust-lang.org/policies/code-of-conduct[Rust Code of Conduct] + +=== Questions + +For questions about this Code of Conduct, contact maintainers listed in +MAINTAINERS.md. + +''''' + +*Remember*: Be kind, be respectful, and assume good intent. We’re all +here to build great software together. diff --git a/asdf-augmenters/asdf-acceleration-middleware/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-acceleration-middleware/CODE_OF_CONDUCT.md deleted file mode 100644 index a942c383..00000000 --- a/asdf-augmenters/asdf-acceleration-middleware/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,126 +0,0 @@ -# Code of Conduct - -## Our Pledge - -We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation. - -We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. - -## Our Standards - -### Examples of behavior that contributes to a positive environment: - -- ✅ Demonstrating empathy and kindness toward other people -- ✅ Being respectful of differing opinions, viewpoints, and experiences -- ✅ Giving and gracefully accepting constructive feedback -- ✅ Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience -- ✅ Focusing on what is best not just for us as individuals, but for the overall community -- ✅ Using welcoming and inclusive language -- ✅ Respecting people's boundaries and privacy -- ✅ Assuming good intent - -### Examples of unacceptable behavior: - -- ❌ The use of sexualized language or imagery, and sexual attention or advances of any kind -- ❌ Trolling, insulting or derogatory comments, and personal or political attacks -- ❌ Public or private harassment -- ❌ Publishing others' private information, such as a physical or email address, without their explicit permission -- ❌ Other conduct which could reasonably be considered inappropriate in a professional setting -- ❌ Dismissing or attacking minority viewpoints -- ❌ Pattern of boundary violations - -## Emotional Safety (Palimpsest License Principles) - -In alignment with the Palimpsest License emotional safety clause: - -### Attribution and Recognition - -- Contributors maintain the right to have their work acknowledged -- No erasure of historical contributions -- Maintain visible chain of authorship -- Credit original ideas and implementations - -### Reversibility and Autonomy - -- Respect people's right to fork and maintain alternatives -- No lock-in or coercive practices -- Support migration and portability -- Welcome healthy competition - -### Psychological Safety - -- Create space for learning and mistakes -- Reduce anxiety through clear processes -- Support experimentation -- Celebrate incremental progress - -## Enforcement Responsibilities - -Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. - -Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. - -## Scope - -This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. - -## Enforcement - -### Reporting - -Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at the contact information listed in MAINTAINERS.md. - -All complaints will be reviewed and investigated promptly and fairly. - -All community leaders are obligated to respect the privacy and security of the reporter of any incident. - -### Process - -1. **Report**: Submit to maintainers (see MAINTAINERS.md) -2. **Acknowledgment**: Within 48 hours -3. **Investigation**: Gather facts from all parties -4. **Decision**: Within 7 days -5. **Appeal**: Available within 14 days - -## Enforcement Guidelines - -Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: - -### 1. Correction - -**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. - -**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. - -### 2. Warning - -**Community Impact**: A violation through a single incident or series of actions. - -**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. - -### 3. Temporary Ban - -**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior. - -**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. - -### 4. Permanent Ban - -**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. - -**Consequence**: A permanent ban from any sort of public interaction within the community. - -## Attribution - -This Code of Conduct is adapted from: -- [Contributor Covenant](https://www.contributor-covenant.org), version 2.1 -- Palimpsest License emotional safety principles -- [Rust Code of Conduct](https://www.rust-lang.org/policies/code-of-conduct) - -## Questions - -For questions about this Code of Conduct, contact maintainers listed in MAINTAINERS.md. - ---- - -**Remember**: Be kind, be respectful, and assume good intent. We're all here to build great software together. diff --git a/asdf-augmenters/asdf-acceleration-middleware/CONTRIBUTING.adoc b/asdf-augmenters/asdf-acceleration-middleware/CONTRIBUTING.adoc index eb045d61..084ee525 100644 --- a/asdf-augmenters/asdf-acceleration-middleware/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-acceleration-middleware/CONTRIBUTING.adoc @@ -1,20 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-acceleration-middleware/CONTRIBUTING.md b/asdf-augmenters/asdf-acceleration-middleware/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-acceleration-middleware/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-acceleration-middleware/MAINTAINERS.adoc b/asdf-augmenters/asdf-acceleration-middleware/MAINTAINERS.adoc index 48d97817..35e1f390 100644 --- a/asdf-augmenters/asdf-acceleration-middleware/MAINTAINERS.adoc +++ b/asdf-augmenters/asdf-acceleration-middleware/MAINTAINERS.adoc @@ -1,47 +1,151 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Maintainers -:toc: preamble +== Maintainers -This document lists the maintainers of this project and their responsibilities. +This document lists the maintainers of the asdf-acceleration-middleware +project. -== Current Maintainers +=== Current Maintainers -[cols="2,3,2",options="header"] -|=== -| Name | Role | Contact +==== Core Team -| Jonathan D.A. Jewell -| Lead Maintainer -| https://github.com/hyperpolymath[@hyperpolymath] -|=== +*Lead Maintainer* - Role: Project leadership, architecture decisions, +release management - Responsibilities: Strategic direction, final +approval on major changes - Contact: See `+.well-known/security.txt+` -== Responsibilities +==== Responsibilities -Maintainers are responsible for: +===== All Maintainers -* Reviewing and merging pull requests -* Triaging issues and feature requests -* Ensuring code quality and security standards -* Managing releases and versioning -* Upholding the project's code of conduct +* Review and merge pull requests +* Triage issues +* Maintain code quality standards +* Ensure RSR compliance +* Respond to security reports +* Foster community growth +* Uphold Code of Conduct -== Becoming a Maintainer +===== Release Process -Contributors who demonstrate: +Maintainers coordinate releases following semantic versioning: -* Consistent, high-quality contributions -* Understanding of the project's goals and standards -* Constructive participation in discussions -* Commitment to the project's long-term health +[arabic] +. Version bump in `+Cargo.toml+` +. Update `+CHANGELOG.md+` +. Tag release: `+git tag -a v0.1.0 -m "Release v0.1.0"+` +. Push tag: `+git push origin v0.1.0+` +. Publish to crates.io: `+cargo publish+` +. Create GitHub release with notes -May be invited to become maintainers at the discretion of existing maintainers. +=== Becoming a Maintainer -== Decision Making +==== Path to Maintainership -* Routine decisions (bug fixes, minor improvements) can be made by any maintainer -* Significant changes require discussion and consensus among maintainers -* Breaking changes or major features should be discussed in issues before implementation +The project follows the TPCF (Tri-Perimeter Contribution Framework): -== Contact +*Perimeter 3 → Perimeter 2 → Perimeter 1* -For questions about project governance, open an issue or contact the maintainers listed above. +===== Perimeter 3: Community Sandbox (Current for new contributors) + +* Public contributions +* Code review required +* Fork/PR workflow + +===== Perimeter 2: Trusted Contributors + +* Consistent high-quality contributions +* Deep understanding of codebase +* Demonstrated adherence to Code of Conduct +* Nominated by existing maintainers +* Rights: Direct commit access to feature branches + +===== Perimeter 1: Core Maintainers + +* Extensive contribution history +* Architecture expertise +* Community leadership +* Nominated by Perimeter 1 maintainers +* Rights: Release authority, main branch access + +==== Criteria for Promotion + +*To Perimeter 2 (Trusted Contributor)*: - ✅ 10+ merged PRs - ✅ 6+ +months of consistent contributions - ✅ Code review participation - ✅ +Zero Code of Conduct violations - ✅ Demonstrated technical expertise + +*To Perimeter 1 (Core Maintainer)*: - ✅ 50+ merged PRs - ✅ 1+ year in +Perimeter 2 - ✅ Architecture contributions - ✅ Mentoring other +contributors - ✅ Community building + +==== Nomination Process + +[arabic] +. Self-nomination or nomination by existing maintainer +. Discussion among current Perimeter 1 maintainers +. Vote (requires 2/3 majority) +. Onboarding and access provisioning + +=== Emeritus Maintainers + +Maintainers who have stepped down are recognized here for their +contributions: + +(None yet) + +=== Contact + +* *GitHub*: https://github.com/Hyperpolymath[@Hyperpolymath] +* *Email*: See `+.well-known/security.txt+` +* *Discussions*: +https://github.com/Hyperpolymath/asdf-acceleration-middleware/discussions[GitHub +Discussions] + +=== Decision Making + +==== Consensus Model + +* *Small changes*: Any maintainer can approve +* *Moderate changes*: 2 maintainer approvals +* *Major changes*: Discussion + consensus of Perimeter 1 +* *Breaking changes*: RFC process + community input + +==== RFC Process + +For major architectural changes: + +[arabic] +. Create RFC document in `+docs/rfcs/+` +. Open discussion issue +. Gather feedback (minimum 2 weeks) +. Revise based on feedback +. Final decision by Perimeter 1 maintainers +. Implementation + +=== Conflict Resolution + +If conflicts arise: + +[arabic] +. *First*: Direct discussion between parties +. *Second*: Involve neutral maintainer as mediator +. *Third*: Escalate to full Perimeter 1 team +. *Last resort*: Code of Conduct enforcement + +=== Time Commitment + +Maintainers are expected to: - Review PRs within 3 days - Respond to +security issues within 48 hours - Participate in monthly maintainer +meetings - Be active in the community + +==== Stepping Down + +Maintainers may step down at any time: - Notify other maintainers - +Complete transition of responsibilities - Move to Emeritus status with +recognition + +=== Acknowledgments + +Thank you to all maintainers, past and present, for your dedication to +this project! + +''''' + +*Last Updated*: 2024-11-22 diff --git a/asdf-augmenters/asdf-acceleration-middleware/MAINTAINERS.md b/asdf-augmenters/asdf-acceleration-middleware/MAINTAINERS.md deleted file mode 100644 index b758c461..00000000 --- a/asdf-augmenters/asdf-acceleration-middleware/MAINTAINERS.md +++ /dev/null @@ -1,149 +0,0 @@ -# Maintainers - -This document lists the maintainers of the asdf-acceleration-middleware project. - -## Current Maintainers - -### Core Team - -**Lead Maintainer** -- Role: Project leadership, architecture decisions, release management -- Responsibilities: Strategic direction, final approval on major changes -- Contact: See `.well-known/security.txt` - -### Responsibilities - -#### All Maintainers - -- Review and merge pull requests -- Triage issues -- Maintain code quality standards -- Ensure RSR compliance -- Respond to security reports -- Foster community growth -- Uphold Code of Conduct - -#### Release Process - -Maintainers coordinate releases following semantic versioning: - -1. Version bump in `Cargo.toml` -2. Update `CHANGELOG.md` -3. Tag release: `git tag -a v0.1.0 -m "Release v0.1.0"` -4. Push tag: `git push origin v0.1.0` -5. Publish to crates.io: `cargo publish` -6. Create GitHub release with notes - -## Becoming a Maintainer - -### Path to Maintainership - -The project follows the TPCF (Tri-Perimeter Contribution Framework): - -**Perimeter 3 → Perimeter 2 → Perimeter 1** - -#### Perimeter 3: Community Sandbox (Current for new contributors) -- Public contributions -- Code review required -- Fork/PR workflow - -#### Perimeter 2: Trusted Contributors -- Consistent high-quality contributions -- Deep understanding of codebase -- Demonstrated adherence to Code of Conduct -- Nominated by existing maintainers -- Rights: Direct commit access to feature branches - -#### Perimeter 1: Core Maintainers -- Extensive contribution history -- Architecture expertise -- Community leadership -- Nominated by Perimeter 1 maintainers -- Rights: Release authority, main branch access - -### Criteria for Promotion - -**To Perimeter 2 (Trusted Contributor)**: -- ✅ 10+ merged PRs -- ✅ 6+ months of consistent contributions -- ✅ Code review participation -- ✅ Zero Code of Conduct violations -- ✅ Demonstrated technical expertise - -**To Perimeter 1 (Core Maintainer)**: -- ✅ 50+ merged PRs -- ✅ 1+ year in Perimeter 2 -- ✅ Architecture contributions -- ✅ Mentoring other contributors -- ✅ Community building - -### Nomination Process - -1. Self-nomination or nomination by existing maintainer -2. Discussion among current Perimeter 1 maintainers -3. Vote (requires 2/3 majority) -4. Onboarding and access provisioning - -## Emeritus Maintainers - -Maintainers who have stepped down are recognized here for their contributions: - -(None yet) - -## Contact - -- **GitHub**: [@Hyperpolymath](https://github.com/Hyperpolymath) -- **Email**: See `.well-known/security.txt` -- **Discussions**: [GitHub Discussions](https://github.com/Hyperpolymath/asdf-acceleration-middleware/discussions) - -## Decision Making - -### Consensus Model - -- **Small changes**: Any maintainer can approve -- **Moderate changes**: 2 maintainer approvals -- **Major changes**: Discussion + consensus of Perimeter 1 -- **Breaking changes**: RFC process + community input - -### RFC Process - -For major architectural changes: - -1. Create RFC document in `docs/rfcs/` -2. Open discussion issue -3. Gather feedback (minimum 2 weeks) -4. Revise based on feedback -5. Final decision by Perimeter 1 maintainers -6. Implementation - -## Conflict Resolution - -If conflicts arise: - -1. **First**: Direct discussion between parties -2. **Second**: Involve neutral maintainer as mediator -3. **Third**: Escalate to full Perimeter 1 team -4. **Last resort**: Code of Conduct enforcement - -## Time Commitment - -Maintainers are expected to: -- Review PRs within 3 days -- Respond to security issues within 48 hours -- Participate in monthly maintainer meetings -- Be active in the community - -### Stepping Down - -Maintainers may step down at any time: -- Notify other maintainers -- Complete transition of responsibilities -- Move to Emeritus status with recognition - -## Acknowledgments - -Thank you to all maintainers, past and present, for your dedication to this project! - ---- - -**Last Updated**: 2024-11-22 diff --git a/asdf-augmenters/asdf-acceleration-middleware/SECURITY.adoc b/asdf-augmenters/asdf-acceleration-middleware/SECURITY.adoc new file mode 100644 index 00000000..ecaed205 --- /dev/null +++ b/asdf-augmenters/asdf-acceleration-middleware/SECURITY.adoc @@ -0,0 +1,177 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|0.1.x |:white_check_mark: +|=== + +=== Reporting a Vulnerability + +*Please DO NOT report security vulnerabilities through public GitHub +issues.* + +==== Reporting Process + +[arabic] +. *Email*: Send details to security contact listed in +`+.well-known/security.txt+` +. *Encryption*: Use PGP key if available (see +`+.well-known/security.txt+`) +. *Information*: Include: +* Description of the vulnerability +* Steps to reproduce +* Potential impact +* Suggested fix (if any) + +==== Response Timeline + +* *Initial Response*: Within 48 hours +* *Status Update*: Within 7 days +* *Fix Timeline*: Depends on severity +** Critical: 7 days +** High: 14 days +** Medium: 30 days +** Low: 90 days + +==== Disclosure Policy + +* We follow *responsible disclosure* practices +* Security advisories will be published after: +** Fix is available +** Users have had time to update (typically 7-14 days) +** Coordination with affected parties + +==== Security Best Practices + +===== For Users + +[arabic] +. *Keep Updated*: Always use the latest version +. *Verify Downloads*: Check signatures and checksums +. *Review Permissions*: Understand what access the tool requires +. *Audit Configurations*: Review generated configs before use +. *Report Issues*: Help us identify vulnerabilities + +===== For Contributors + +[arabic] +. *Input Validation*: Always validate external input +. *Avoid Shell Injection*: Use safe subprocess APIs (duct) +. *No Unsafe Rust*: Avoid `+unsafe+` blocks unless absolutely necessary +. *Dependency Audits*: Run `+cargo audit+` regularly +. *Secrets Management*: Never commit secrets or credentials +. *Code Review*: All changes require review + +==== Security Features + +===== Built-In Security + +* ✅ *Type Safety*: Rust compile-time guarantees +* ✅ *Memory Safety*: No buffer overflows, use-after-free +* ✅ *Safe Subprocess*: `+duct+` for shell command execution +* ✅ *Input Validation*: Strict parsing and validation +* ✅ *Audit Logging*: Track all operations +* ✅ *SELinux Support*: Context-aware security + +===== Security Checks + +[source,bash] +---- +# Run security audit +cargo audit + +# Check for unsafe code +cargo geiger + +# Dependency tree +cargo tree + +# License compliance +cargo license +---- + +==== Known Security Considerations + +===== 1. Shell Command Execution + +The tool executes `+asdf+` commands via subprocess. Mitigations: - Input +sanitization - No shell interpolation - Allowlist of valid commands - +Audit logging + +===== 2. Filesystem Access + +Requires read/write to: - `+~/.asdf/+` directory - Cache directory - +Configuration files + +Mitigations: - Path validation - No symbolic link following - Permission +checks + +===== 3. Cache Poisoning + +Cache could be manipulated. Mitigations: - Integrity verification - TTL +enforcement - Cache validation - Secure permissions (0600) + +===== 4. Dependency Chain + +Rust dependencies could introduce vulnerabilities. Mitigations: - +`+cargo audit+` in CI - Minimal dependency footprint - Regular updates - +Review of dependency changes + +==== Security Tooling + +[source,bash] +---- +# Audit dependencies +just audit + +# Check for unsafe code +just security-check + +# Verify RSR compliance +just rsr-verify + +# Run all security checks +just security-full +---- + +==== Threat Model + +===== In Scope + +* Command injection via asdf arguments +* Path traversal attacks +* Cache poisoning +* Dependency vulnerabilities +* Denial of service (resource exhaustion) + +===== Out of Scope + +* Vulnerabilities in asdf itself +* OS-level exploits +* Social engineering +* Physical access attacks + +==== Security Contacts + +See `+.well-known/security.txt+` for current contact information. + +==== Security Hall of Fame + +We acknowledge security researchers who responsibly disclose +vulnerabilities: + +(None yet - be the first!) + +==== References + +* https://owasp.org/www-project-top-ten/[OWASP Top 10] +* https://anssi-fr.github.io/rust-guide/[Rust Security Guidelines] +* https://www.rfc-editor.org/rfc/rfc9116.html[RFC 9116: security.txt] +* https://cwe.mitre.org/top25/[CWE Top 25] + +''''' + +*Last Updated*: 2024-11-22 diff --git a/asdf-augmenters/asdf-acceleration-middleware/SECURITY.md b/asdf-augmenters/asdf-acceleration-middleware/SECURITY.md deleted file mode 100644 index 4742a6dc..00000000 --- a/asdf-augmenters/asdf-acceleration-middleware/SECURITY.md +++ /dev/null @@ -1,177 +0,0 @@ -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| 0.1.x | :white_check_mark: | - -## Reporting a Vulnerability - -**Please DO NOT report security vulnerabilities through public GitHub issues.** - -### Reporting Process - -1. **Email**: Send details to security contact listed in `.well-known/security.txt` -2. **Encryption**: Use PGP key if available (see `.well-known/security.txt`) -3. **Information**: Include: - - Description of the vulnerability - - Steps to reproduce - - Potential impact - - Suggested fix (if any) - -### Response Timeline - -- **Initial Response**: Within 48 hours -- **Status Update**: Within 7 days -- **Fix Timeline**: Depends on severity - - Critical: 7 days - - High: 14 days - - Medium: 30 days - - Low: 90 days - -### Disclosure Policy - -- We follow **responsible disclosure** practices -- Security advisories will be published after: - - Fix is available - - Users have had time to update (typically 7-14 days) - - Coordination with affected parties - -### Security Best Practices - -#### For Users - -1. **Keep Updated**: Always use the latest version -2. **Verify Downloads**: Check signatures and checksums -3. **Review Permissions**: Understand what access the tool requires -4. **Audit Configurations**: Review generated configs before use -5. **Report Issues**: Help us identify vulnerabilities - -#### For Contributors - -1. **Input Validation**: Always validate external input -2. **Avoid Shell Injection**: Use safe subprocess APIs (duct) -3. **No Unsafe Rust**: Avoid `unsafe` blocks unless absolutely necessary -4. **Dependency Audits**: Run `cargo audit` regularly -5. **Secrets Management**: Never commit secrets or credentials -6. **Code Review**: All changes require review - -### Security Features - -#### Built-In Security - -- ✅ **Type Safety**: Rust compile-time guarantees -- ✅ **Memory Safety**: No buffer overflows, use-after-free -- ✅ **Safe Subprocess**: `duct` for shell command execution -- ✅ **Input Validation**: Strict parsing and validation -- ✅ **Audit Logging**: Track all operations -- ✅ **SELinux Support**: Context-aware security - -#### Security Checks - -```bash -# Run security audit -cargo audit - -# Check for unsafe code -cargo geiger - -# Dependency tree -cargo tree - -# License compliance -cargo license -``` - -### Known Security Considerations - -#### 1. Shell Command Execution - -The tool executes `asdf` commands via subprocess. Mitigations: -- Input sanitization -- No shell interpolation -- Allowlist of valid commands -- Audit logging - -#### 2. Filesystem Access - -Requires read/write to: -- `~/.asdf/` directory -- Cache directory -- Configuration files - -Mitigations: -- Path validation -- No symbolic link following -- Permission checks - -#### 3. Cache Poisoning - -Cache could be manipulated. Mitigations: -- Integrity verification -- TTL enforcement -- Cache validation -- Secure permissions (0600) - -#### 4. Dependency Chain - -Rust dependencies could introduce vulnerabilities. Mitigations: -- `cargo audit` in CI -- Minimal dependency footprint -- Regular updates -- Review of dependency changes - -### Security Tooling - -```bash -# Audit dependencies -just audit - -# Check for unsafe code -just security-check - -# Verify RSR compliance -just rsr-verify - -# Run all security checks -just security-full -``` - -### Threat Model - -#### In Scope - -- Command injection via asdf arguments -- Path traversal attacks -- Cache poisoning -- Dependency vulnerabilities -- Denial of service (resource exhaustion) - -#### Out of Scope - -- Vulnerabilities in asdf itself -- OS-level exploits -- Social engineering -- Physical access attacks - -### Security Contacts - -See `.well-known/security.txt` for current contact information. - -### Security Hall of Fame - -We acknowledge security researchers who responsibly disclose vulnerabilities: - -(None yet - be the first!) - -### References - -- [OWASP Top 10](https://owasp.org/www-project-top-ten/) -- [Rust Security Guidelines](https://anssi-fr.github.io/rust-guide/) -- [RFC 9116: security.txt](https://www.rfc-editor.org/rfc/rfc9116.html) -- [CWE Top 25](https://cwe.mitre.org/top25/) - ---- - -**Last Updated**: 2024-11-22 diff --git a/asdf-augmenters/asdf-acceleration-middleware/docs/ARCHITECTURE.adoc b/asdf-augmenters/asdf-acceleration-middleware/docs/ARCHITECTURE.adoc new file mode 100644 index 00000000..9f9a14bb --- /dev/null +++ b/asdf-augmenters/asdf-acceleration-middleware/docs/ARCHITECTURE.adoc @@ -0,0 +1,299 @@ +== Architecture + +=== Overview + +asdf-acceleration-middleware is built as a modular Rust workspace with +separation of concerns across multiple crates. + +=== Crate Structure + +==== Library Crates + +===== asdf-core + +*Purpose*: Core abstractions for asdf integration + +*Responsibilities*: - Type-safe wrappers around asdf operations - Plugin +management - Runtime version management - Semantic version parsing + +*Key Types*: - `+Plugin+`: Represents an asdf plugin - `+Runtime+`: +Represents an installed runtime version - `+Version+`: Semantic version +with parsing and comparison + +===== asdf-cache + +*Purpose*: Multi-level caching system + +*Architecture*: + +.... +L1 (Memory) → L2 (Disk) → Source + LRU Cache Sled DB asdf +.... + +*Components*: - `+MemoryCache+`: In-memory LRU cache for hot data - +`+DiskCache+`: Sled embedded database for persistence - +`+CacheManager+`: Coordinator managing both levels + +*Performance*: O(1) average for L1 hits, O(log n) for L2 + +===== asdf-parallel + +*Purpose*: Parallel execution engine using Rayon + +*Features*: - Multiple execution strategies (sequential, auto, fixed, +max) - Fail-fast or collect-all error handling - Retry logic with +configurable attempts - Progress tracking integration + +*Key Types*: - `+Executor+`: Main parallel execution coordinator - +`+Strategy+`: Execution strategy enumeration - `+ExecutorConfig+`: +Configuration for execution behavior + +===== asdf-config + +*Purpose*: Configuration management + +*Features*: - Multiple format support (TOML, JSON, Nickel) - Environment +variable overrides - Hierarchical configuration loading - Type-safe +schema with validation + +*Loading Priority*: 1. Environment variables (highest) 2. Config file 3. +Defaults (lowest) + +===== asdf-metrics + +*Purpose*: Metrics collection and reporting + +*Features*: - Operation timing and counting - Success/failure rate +tracking - System resource monitoring - Multiple export formats (text, +JSON, Prometheus) + +==== CLI Crates + +===== asdf-accelerate + +*Purpose*: Main CLI tool for accelerating asdf operations + +*Commands*: - `+update+`: Update plugins in parallel - `+install+`: +Install runtimes with acceleration - `+sync+`: Sync plugin repositories +- `+list+`: List plugins with formatting options - `+cache+`: Manage +cache (clear, stats) + +*Architecture*: + +.... +CLI → Commands → Libraries + ↓ + Executor → asdf-core + ↓ + Progress Bar + ↓ + Metrics +.... + +===== asdf-bench + +*Purpose*: Benchmarking tool + +*Features*: - Operation timing - Baseline comparisons - Multiple output +formats - Performance profiling + +===== asdf-discover + +*Purpose*: Auto-discovery of runtimes + +*Features*: - System scanning for installed runtimes - Configuration +generation (Nickel, JSON, TOML) - Setup validation + +*Use Cases*: - Onboarding new systems - Generating `+.tool-versions+` +equivalents - Auditing installed runtimes + +===== asdf-monitor + +*Purpose*: Monitoring and health checking + +*Features*: - Real-time metrics dashboard (planned TUI) - Health checks +- Prometheus metrics export - System resource monitoring + +=== Data Flow + +==== Plugin Update Flow + +.... +User Command + ↓ +asdf-accelerate + ↓ +Load Config + ↓ +Query Plugins (asdf-core) + ↓ +Check Cache (asdf-cache) + ├─ Hit → Return cached + └─ Miss → Fetch from asdf + ↓ + Update Plugins (asdf-parallel) + ├─ Executor spawns threads + ├─ Each thread updates plugin + └─ Collect results + ↓ +Update Cache + ↓ +Report Metrics +.... + +==== Caching Strategy + +.... +Get Plugin Info + ↓ +Check L1 (Memory LRU) + ├─ Hit → Return (fast path) + └─ Miss + ↓ + Check L2 (Disk Sled) + ├─ Hit → Promote to L1 → Return + └─ Miss + ↓ + Fetch from asdf + ↓ + Store in L2 and L1 + ↓ + Return +.... + +=== Performance Targets + +==== Benchmarks + +[width="100%",cols="20%,23%,17%,20%,20%",options="header",] +|=== +|Operation |Baseline (bash) |Sequential |Parallel (4) |Parallel (8) +|Plugin Update |100s |40s (2.5x) |13s (7.7x) |9s (11x) +|Plugin List |5s |2s (2.5x) |0.8s (6.2x) |0.5s (10x) +|=== + +==== Memory Usage + +* L1 Cache: ~10MB (1000 entries) +* L2 Cache: ~100MB (typical) +* Total: <150MB resident + +==== Scalability + +* *Plugins*: Tested with 50+ plugins +* *Parallel Jobs*: Scales to CPU count +* *Cache Size*: Handles 10k+ entries + +=== Security Considerations + +==== Input Validation + +* All external input sanitized +* No shell interpolation +* Path traversal prevention + +==== Cache Security + +* Cache files: 0600 permissions +* Integrity verification on load +* TTL enforcement + +==== Subprocess Execution + +* Uses `+duct+` for safe subprocess management +* No shell=true +* Argument array passing (no string interpolation) + +=== Error Handling + +==== Strategy + +* Type-safe errors with `+thiserror+` +* Context preservation with `+anyhow+` +* Graceful degradation when possible + +==== Error Types + +[arabic] +. *Recoverable*: Retry with backoff +. *User Errors*: Clear messages and suggestions +. *System Errors*: Detailed context for debugging + +=== Testing Strategy + +==== Unit Tests + +* Each crate has `+#[cfg(test)]+` modules +* Test coverage target: >80% +* Property-based testing for parsers + +==== Integration Tests + +* Cross-crate integration +* End-to-end CLI testing with `+assert_cmd+` +* Fixture-based testing + +==== Benchmarks + +* Criterion-based performance tests +* Regression detection +* Profiling integration + +=== Future Architecture + +==== Planned Enhancements + +[arabic] +. *Async I/O*: Tokio integration for I/O-bound operations +. *Plugin System*: Dynamic plugin loading +. *Distributed Caching*: Redis backend option +. *Web Dashboard*: Browser-based monitoring +. *gRPC API*: Programmatic access + +==== Nickel Integration (Phase 2) + +* Type-safe configuration generation +* Contract-based validation +* Smart defaults with overrides + +=== RSR Compliance + +==== Type Safety + +* Zero `+unsafe+` blocks in core libraries +* Compile-time guarantees via Rust type system +* Newtype pattern for semantic clarity + +==== Memory Safety + +* Ownership model prevents use-after-free +* No buffer overflows +* RAII for resource management + +==== Offline-First + +* No mandatory network calls +* All data cached locally +* Graceful handling of offline mode + +=== Dependencies + +==== Philosophy + +* Minimal but powerful +* Well-maintained crates only +* Regular `+cargo audit+` checks +* Security-first selection + +==== Key Dependencies + +* *rayon*: Data parallelism +* *sled*: Embedded database +* *clap*: CLI parsing +* *serde*: Serialization +* *duct*: Subprocess management + +''''' + +*Last Updated*: 2024-11-22 diff --git a/asdf-augmenters/asdf-acceleration-middleware/docs/ARCHITECTURE.md b/asdf-augmenters/asdf-acceleration-middleware/docs/ARCHITECTURE.md deleted file mode 100644 index 3a61a7fe..00000000 --- a/asdf-augmenters/asdf-acceleration-middleware/docs/ARCHITECTURE.md +++ /dev/null @@ -1,309 +0,0 @@ -# Architecture - -## Overview - -asdf-acceleration-middleware is built as a modular Rust workspace with separation of concerns across multiple crates. - -## Crate Structure - -### Library Crates - -#### asdf-core -**Purpose**: Core abstractions for asdf integration - -**Responsibilities**: -- Type-safe wrappers around asdf operations -- Plugin management -- Runtime version management -- Semantic version parsing - -**Key Types**: -- `Plugin`: Represents an asdf plugin -- `Runtime`: Represents an installed runtime version -- `Version`: Semantic version with parsing and comparison - -#### asdf-cache -**Purpose**: Multi-level caching system - -**Architecture**: -``` -L1 (Memory) → L2 (Disk) → Source - LRU Cache Sled DB asdf -``` - -**Components**: -- `MemoryCache`: In-memory LRU cache for hot data -- `DiskCache`: Sled embedded database for persistence -- `CacheManager`: Coordinator managing both levels - -**Performance**: O(1) average for L1 hits, O(log n) for L2 - -#### asdf-parallel -**Purpose**: Parallel execution engine using Rayon - -**Features**: -- Multiple execution strategies (sequential, auto, fixed, max) -- Fail-fast or collect-all error handling -- Retry logic with configurable attempts -- Progress tracking integration - -**Key Types**: -- `Executor`: Main parallel execution coordinator -- `Strategy`: Execution strategy enumeration -- `ExecutorConfig`: Configuration for execution behavior - -#### asdf-config -**Purpose**: Configuration management - -**Features**: -- Multiple format support (TOML, JSON, Nickel) -- Environment variable overrides -- Hierarchical configuration loading -- Type-safe schema with validation - -**Loading Priority**: -1. Environment variables (highest) -2. Config file -3. Defaults (lowest) - -#### asdf-metrics -**Purpose**: Metrics collection and reporting - -**Features**: -- Operation timing and counting -- Success/failure rate tracking -- System resource monitoring -- Multiple export formats (text, JSON, Prometheus) - -### CLI Crates - -#### asdf-accelerate -**Purpose**: Main CLI tool for accelerating asdf operations - -**Commands**: -- `update`: Update plugins in parallel -- `install`: Install runtimes with acceleration -- `sync`: Sync plugin repositories -- `list`: List plugins with formatting options -- `cache`: Manage cache (clear, stats) - -**Architecture**: -``` -CLI → Commands → Libraries - ↓ - Executor → asdf-core - ↓ - Progress Bar - ↓ - Metrics -``` - -#### asdf-bench -**Purpose**: Benchmarking tool - -**Features**: -- Operation timing -- Baseline comparisons -- Multiple output formats -- Performance profiling - -#### asdf-discover -**Purpose**: Auto-discovery of runtimes - -**Features**: -- System scanning for installed runtimes -- Configuration generation (Nickel, JSON, TOML) -- Setup validation - -**Use Cases**: -- Onboarding new systems -- Generating `.tool-versions` equivalents -- Auditing installed runtimes - -#### asdf-monitor -**Purpose**: Monitoring and health checking - -**Features**: -- Real-time metrics dashboard (planned TUI) -- Health checks -- Prometheus metrics export -- System resource monitoring - -## Data Flow - -### Plugin Update Flow - -``` -User Command - ↓ -asdf-accelerate - ↓ -Load Config - ↓ -Query Plugins (asdf-core) - ↓ -Check Cache (asdf-cache) - ├─ Hit → Return cached - └─ Miss → Fetch from asdf - ↓ - Update Plugins (asdf-parallel) - ├─ Executor spawns threads - ├─ Each thread updates plugin - └─ Collect results - ↓ -Update Cache - ↓ -Report Metrics -``` - -### Caching Strategy - -``` -Get Plugin Info - ↓ -Check L1 (Memory LRU) - ├─ Hit → Return (fast path) - └─ Miss - ↓ - Check L2 (Disk Sled) - ├─ Hit → Promote to L1 → Return - └─ Miss - ↓ - Fetch from asdf - ↓ - Store in L2 and L1 - ↓ - Return -``` - -## Performance Targets - -### Benchmarks - -| Operation | Baseline (bash) | Sequential | Parallel (4) | Parallel (8) | -|-----------|----------------|------------|--------------|--------------| -| Plugin Update | 100s | 40s (2.5x) | 13s (7.7x) | 9s (11x) | -| Plugin List | 5s | 2s (2.5x) | 0.8s (6.2x) | 0.5s (10x) | - -### Memory Usage - -- L1 Cache: ~10MB (1000 entries) -- L2 Cache: ~100MB (typical) -- Total: <150MB resident - -### Scalability - -- **Plugins**: Tested with 50+ plugins -- **Parallel Jobs**: Scales to CPU count -- **Cache Size**: Handles 10k+ entries - -## Security Considerations - -### Input Validation - -- All external input sanitized -- No shell interpolation -- Path traversal prevention - -### Cache Security - -- Cache files: 0600 permissions -- Integrity verification on load -- TTL enforcement - -### Subprocess Execution - -- Uses `duct` for safe subprocess management -- No shell=true -- Argument array passing (no string interpolation) - -## Error Handling - -### Strategy - -- Type-safe errors with `thiserror` -- Context preservation with `anyhow` -- Graceful degradation when possible - -### Error Types - -1. **Recoverable**: Retry with backoff -2. **User Errors**: Clear messages and suggestions -3. **System Errors**: Detailed context for debugging - -## Testing Strategy - -### Unit Tests - -- Each crate has `#[cfg(test)]` modules -- Test coverage target: >80% -- Property-based testing for parsers - -### Integration Tests - -- Cross-crate integration -- End-to-end CLI testing with `assert_cmd` -- Fixture-based testing - -### Benchmarks - -- Criterion-based performance tests -- Regression detection -- Profiling integration - -## Future Architecture - -### Planned Enhancements - -1. **Async I/O**: Tokio integration for I/O-bound operations -2. **Plugin System**: Dynamic plugin loading -3. **Distributed Caching**: Redis backend option -4. **Web Dashboard**: Browser-based monitoring -5. **gRPC API**: Programmatic access - -### Nickel Integration (Phase 2) - -- Type-safe configuration generation -- Contract-based validation -- Smart defaults with overrides - -## RSR Compliance - -### Type Safety - -- Zero `unsafe` blocks in core libraries -- Compile-time guarantees via Rust type system -- Newtype pattern for semantic clarity - -### Memory Safety - -- Ownership model prevents use-after-free -- No buffer overflows -- RAII for resource management - -### Offline-First - -- No mandatory network calls -- All data cached locally -- Graceful handling of offline mode - -## Dependencies - -### Philosophy - -- Minimal but powerful -- Well-maintained crates only -- Regular `cargo audit` checks -- Security-first selection - -### Key Dependencies - -- **rayon**: Data parallelism -- **sled**: Embedded database -- **clap**: CLI parsing -- **serde**: Serialization -- **duct**: Subprocess management - ---- - -**Last Updated**: 2024-11-22 diff --git a/asdf-augmenters/asdf-acceleration-middleware/docs/QUICKSTART.adoc b/asdf-augmenters/asdf-acceleration-middleware/docs/QUICKSTART.adoc new file mode 100644 index 00000000..dff8f252 --- /dev/null +++ b/asdf-augmenters/asdf-acceleration-middleware/docs/QUICKSTART.adoc @@ -0,0 +1,287 @@ +== Quick Start Guide + +Get started with asdf-acceleration-middleware in 5 minutes. + +=== Prerequisites + +* Rust 1.70.0 or later +* asdf version manager installed +* Git + +=== Installation + +==== From Source + +[source,bash] +---- +# Clone the repository +git clone https://github.com/Hyperpolymath/asdf-acceleration-middleware +cd asdf-acceleration-middleware + +# Build and install +cargo install --path crates/asdf-accelerate +cargo install --path crates/asdf-bench +cargo install --path crates/asdf-discover +cargo install --path crates/asdf-monitor + +# Or use just +just install +---- + +==== Using Cargo + +[source,bash] +---- +cargo install asdf-accelerate +cargo install asdf-bench +cargo install asdf-discover +cargo install asdf-monitor +---- + +=== Basic Usage + +==== Update Plugins + +[source,bash] +---- +# Update all plugins in parallel +asdf-accelerate update --all --jobs 8 + +# Update specific plugins +asdf-accelerate update nodejs ruby python + +# Exclude certain plugins +asdf-accelerate update --all --exclude rust golang +---- + +==== Install Runtimes + +[source,bash] +---- +# Install single runtime +asdf-accelerate install nodejs@20.0.0 + +# Install multiple runtimes in parallel +asdf-accelerate install nodejs@20.0.0 ruby@3.2.0 --parallel +---- + +==== List Plugins + +[source,bash] +---- +# List all plugins +asdf-accelerate list + +# List with URLs +asdf-accelerate list --urls + +# JSON output +asdf-accelerate list --format json +---- + +==== Cache Management + +[source,bash] +---- +# Show cache statistics +asdf-accelerate cache --stats + +# Clear cache +asdf-accelerate cache --clear +---- + +==== Benchmarking + +[source,bash] +---- +# Run benchmarks +asdf-bench --all + +# Generate HTML report +asdf-bench --all --format html --output benchmark.html +---- + +==== Discovery + +[source,bash] +---- +# Scan system for runtimes +asdf-discover scan + +# Generate Nickel configuration +asdf-discover generate --format nickel --output asdf-config.ncl + +# Validate setup +asdf-discover validate +---- + +==== Monitoring + +[source,bash] +---- +# Health check +asdf-monitor health + +# Export metrics +asdf-monitor metrics --format json + +# Launch dashboard +asdf-monitor dashboard +---- + +=== Configuration + +==== Create Configuration File + +[source,bash] +---- +# Copy example configuration +cp examples/config.toml ~/.config/asdf-acceleration/config.toml + +# Edit as needed +$EDITOR ~/.config/asdf-acceleration/config.toml +---- + +==== Example Configuration + +[source,toml] +---- +[cache] +enabled = true +ttl_secs = 3600 +max_size_mb = 500 + +[parallel] +strategy = "auto" +fail_fast = false + +[notifications] +enabled = true +level = "errors_only" + +[plugins] +exclude = [] +auto_update = true +---- + +==== Environment Variables + +Override configuration with environment variables: + +[source,bash] +---- +# Set cache TTL +export ASDF_ACCEL__CACHE__TTL_SECS=7200 + +# Set parallel jobs +export ASDF_ACCEL__PARALLEL__MAX_JOBS=4 + +# Disable notifications +export ASDF_ACCEL__NOTIFICATIONS__ENABLED=false +---- + +=== Common Workflows + +==== Daily Update Routine + +[source,bash] +---- +# Morning routine: update all plugins +asdf-accelerate update --all --jobs 8 + +# Check for new versions +asdf-discover scan +---- + +==== Setting Up New Machine + +[source,bash] +---- +# Validate asdf installation +asdf-discover validate + +# Scan existing runtimes +asdf-discover scan --deep + +# Generate configuration +asdf-discover generate --format nickel > asdf-config.ncl +---- + +==== Performance Optimization + +[source,bash] +---- +# Benchmark current performance +asdf-bench --all + +# Clear cache to free space +asdf-accelerate cache --clear + +# Monitor system resources +asdf-monitor health +---- + +=== Performance Tips + +[arabic] +. *Use parallel jobs*: `+--jobs 8+` can speed up operations 7-11x +. *Enable caching*: Reduces redundant asdf calls +. *Background mode*: Run long operations in background +. *Exclude inactive plugins*: Faster updates + +=== Troubleshooting + +==== asdf not found + +[source,bash] +---- +# Ensure asdf is in PATH +which asdf + +# Or set ASDF_DIR +export ASDF_DIR=$HOME/.asdf +---- + +==== Cache issues + +[source,bash] +---- +# Clear cache +asdf-accelerate cache --clear + +# Check cache location +asdf-accelerate cache --stats +---- + +==== Permission errors + +[source,bash] +---- +# Check cache directory permissions +ls -la ~/.cache/asdf-acceleration + +# Fix if needed +chmod 700 ~/.cache/asdf-acceleration +---- + +=== Next Steps + +* Read link:ARCHITECTURE.md[Architecture Documentation] +* Review link:../CONTRIBUTING.md[Contributing Guidelines] +* Explore link:../examples/[Example Configurations] +* Join +https://github.com/Hyperpolymath/asdf-acceleration-middleware/discussions[Discussions] + +=== Getting Help + +* 📖 link:README.md[Full Documentation] +* 🐛 +https://github.com/Hyperpolymath/asdf-acceleration-middleware/issues[Report +Issues] +* 💬 +https://github.com/Hyperpolymath/asdf-acceleration-middleware/discussions[Ask +Questions] + +''''' + +*Happy accelerating!* 🚀 diff --git a/asdf-augmenters/asdf-acceleration-middleware/docs/QUICKSTART.md b/asdf-augmenters/asdf-acceleration-middleware/docs/QUICKSTART.md deleted file mode 100644 index 801208b4..00000000 --- a/asdf-augmenters/asdf-acceleration-middleware/docs/QUICKSTART.md +++ /dev/null @@ -1,263 +0,0 @@ -# Quick Start Guide - -Get started with asdf-acceleration-middleware in 5 minutes. - -## Prerequisites - -- Rust 1.70.0 or later -- asdf version manager installed -- Git - -## Installation - -### From Source - -```bash -# Clone the repository -git clone https://github.com/Hyperpolymath/asdf-acceleration-middleware -cd asdf-acceleration-middleware - -# Build and install -cargo install --path crates/asdf-accelerate -cargo install --path crates/asdf-bench -cargo install --path crates/asdf-discover -cargo install --path crates/asdf-monitor - -# Or use just -just install -``` - -### Using Cargo - -```bash -cargo install asdf-accelerate -cargo install asdf-bench -cargo install asdf-discover -cargo install asdf-monitor -``` - -## Basic Usage - -### Update Plugins - -```bash -# Update all plugins in parallel -asdf-accelerate update --all --jobs 8 - -# Update specific plugins -asdf-accelerate update nodejs ruby python - -# Exclude certain plugins -asdf-accelerate update --all --exclude rust golang -``` - -### Install Runtimes - -```bash -# Install single runtime -asdf-accelerate install nodejs@20.0.0 - -# Install multiple runtimes in parallel -asdf-accelerate install nodejs@20.0.0 ruby@3.2.0 --parallel -``` - -### List Plugins - -```bash -# List all plugins -asdf-accelerate list - -# List with URLs -asdf-accelerate list --urls - -# JSON output -asdf-accelerate list --format json -``` - -### Cache Management - -```bash -# Show cache statistics -asdf-accelerate cache --stats - -# Clear cache -asdf-accelerate cache --clear -``` - -### Benchmarking - -```bash -# Run benchmarks -asdf-bench --all - -# Generate HTML report -asdf-bench --all --format html --output benchmark.html -``` - -### Discovery - -```bash -# Scan system for runtimes -asdf-discover scan - -# Generate Nickel configuration -asdf-discover generate --format nickel --output asdf-config.ncl - -# Validate setup -asdf-discover validate -``` - -### Monitoring - -```bash -# Health check -asdf-monitor health - -# Export metrics -asdf-monitor metrics --format json - -# Launch dashboard -asdf-monitor dashboard -``` - -## Configuration - -### Create Configuration File - -```bash -# Copy example configuration -cp examples/config.toml ~/.config/asdf-acceleration/config.toml - -# Edit as needed -$EDITOR ~/.config/asdf-acceleration/config.toml -``` - -### Example Configuration - -```toml -[cache] -enabled = true -ttl_secs = 3600 -max_size_mb = 500 - -[parallel] -strategy = "auto" -fail_fast = false - -[notifications] -enabled = true -level = "errors_only" - -[plugins] -exclude = [] -auto_update = true -``` - -### Environment Variables - -Override configuration with environment variables: - -```bash -# Set cache TTL -export ASDF_ACCEL__CACHE__TTL_SECS=7200 - -# Set parallel jobs -export ASDF_ACCEL__PARALLEL__MAX_JOBS=4 - -# Disable notifications -export ASDF_ACCEL__NOTIFICATIONS__ENABLED=false -``` - -## Common Workflows - -### Daily Update Routine - -```bash -# Morning routine: update all plugins -asdf-accelerate update --all --jobs 8 - -# Check for new versions -asdf-discover scan -``` - -### Setting Up New Machine - -```bash -# Validate asdf installation -asdf-discover validate - -# Scan existing runtimes -asdf-discover scan --deep - -# Generate configuration -asdf-discover generate --format nickel > asdf-config.ncl -``` - -### Performance Optimization - -```bash -# Benchmark current performance -asdf-bench --all - -# Clear cache to free space -asdf-accelerate cache --clear - -# Monitor system resources -asdf-monitor health -``` - -## Performance Tips - -1. **Use parallel jobs**: `--jobs 8` can speed up operations 7-11x -2. **Enable caching**: Reduces redundant asdf calls -3. **Background mode**: Run long operations in background -4. **Exclude inactive plugins**: Faster updates - -## Troubleshooting - -### asdf not found - -```bash -# Ensure asdf is in PATH -which asdf - -# Or set ASDF_DIR -export ASDF_DIR=$HOME/.asdf -``` - -### Cache issues - -```bash -# Clear cache -asdf-accelerate cache --clear - -# Check cache location -asdf-accelerate cache --stats -``` - -### Permission errors - -```bash -# Check cache directory permissions -ls -la ~/.cache/asdf-acceleration - -# Fix if needed -chmod 700 ~/.cache/asdf-acceleration -``` - -## Next Steps - -- Read [Architecture Documentation](ARCHITECTURE.md) -- Review [Contributing Guidelines](../CONTRIBUTING.md) -- Explore [Example Configurations](../examples/) -- Join [Discussions](https://github.com/Hyperpolymath/asdf-acceleration-middleware/discussions) - -## Getting Help - -- 📖 [Full Documentation](README.md) -- 🐛 [Report Issues](https://github.com/Hyperpolymath/asdf-acceleration-middleware/issues) -- 💬 [Ask Questions](https://github.com/Hyperpolymath/asdf-acceleration-middleware/discussions) - ---- - -**Happy accelerating!** 🚀 diff --git a/asdf-augmenters/asdf-acceleration-middleware/docs/TPCF.adoc b/asdf-augmenters/asdf-acceleration-middleware/docs/TPCF.adoc new file mode 100644 index 00000000..4751277f --- /dev/null +++ b/asdf-augmenters/asdf-acceleration-middleware/docs/TPCF.adoc @@ -0,0 +1,215 @@ +== Tri-Perimeter Contribution Framework (TPCF) + +This project implements the *Tri-Perimeter Contribution Framework* +(TPCF), a graduated trust model for open source contributions. + +=== Overview + +TPCF organizes contributors into three concentric perimeters based on +trust level and contribution history, providing a clear path for +community members to increase their involvement. + +=== Perimeters + +==== Perimeter 3: Community Sandbox + +*Current Status*: ✅ Active + +*Access Level*: Public contributions welcomed + +*Who*: All external contributors + +*Privileges*: - Fork repository - Submit pull requests - Participate in +discussions - Report issues + +*Requirements*: - Follow Code of Conduct - Pass all CI checks - Obtain +code review approval from Perimeter 1 or 2 maintainers + +*Workflow*: 1. Fork the repository 2. Create feature branch 3. Make +changes 4. Submit pull request 5. Address review feedback 6. Await +approval and merge + +*Graduation Criteria* to Perimeter 2: - ✅ 10+ merged pull requests - ✅ +6+ months of consistent contributions - ✅ Active code review +participation - ✅ Zero Code of Conduct violations - ✅ Demonstrated +technical expertise in project domain + +==== Perimeter 2: Trusted Contributors + +*Current Status*: 🔜 Planned + +*Access Level*: Direct repository access + +*Who*: Experienced contributors with proven track record + +*Privileges*: - Direct commit access to feature branches - Review and +approve pull requests - Participate in architectural discussions - +Mentor new contributors + +*Requirements*: - All Perimeter 3 requirements met - Nominated by +existing Perimeter 1 maintainer - Approval vote by Perimeter 1 (2/3 +majority) + +*Responsibilities*: - Maintain code quality standards - Review +contributions promptly - Uphold Code of Conduct - Support community +growth + +*Graduation Criteria* to Perimeter 1: - ✅ 50+ merged pull requests - ✅ +1+ year in Perimeter 2 - ✅ Significant architectural contributions - ✅ +Active mentoring of other contributors - ✅ Demonstrated project +leadership + +==== Perimeter 1: Core Maintainers + +*Current Status*: 🔜 To be established + +*Access Level*: Full repository control + +*Who*: Project leaders and primary maintainers + +*Privileges*: - Release authority - Main branch access - Security issue +triage - Governance decisions - Perimeter promotions + +*Requirements*: - All Perimeter 2 requirements met - Extensive +contribution history - Community leadership demonstrated - Approval vote +by existing Perimeter 1 (2/3 majority) + +*Responsibilities*: - Strategic direction - Release management - +Security response - Governance and policy - Community health + +=== Benefits of TPCF + +==== For Contributors + +[arabic] +. *Clear Path*: Transparent progression from contributor to maintainer +. *Recognition*: Formal acknowledgment of contributions +. *Meritocratic*: Advancement based on actual contributions +. *Safety*: Reduced anxiety through clear expectations + +==== For the Project + +[arabic] +. *Security*: Graduated trust reduces risk +. *Sustainability*: Distributed maintenance burden +. *Quality*: Multiple review layers +. *Growth*: Structured onboarding for new contributors + +==== For Users + +[arabic] +. *Stability*: Experienced maintainers with skin in the game +. *Accountability*: Clear ownership and responsibility +. *Continuity*: Multiple maintainers prevent single points of failure + +=== Comparison with Traditional Models + +[width="100%",cols="27%,53%,20%",options="header",] +|=== +|Aspect |Traditional OSS |TPCF +|Contribution |Binary (contributor/maintainer) |Graduated (3 levels) +|Trust |All or nothing |Incremental +|Onboarding |Informal |Structured +|Recognition |Often implicit |Explicit perimeters +|Security |Single barrier |Defense in depth +|=== + +=== Emotional Safety (Palimpsest Alignment) + +TPCF aligns with Palimpsest License emotional safety principles: + +==== Attribution Persistence + +* Git history preserved permanently +* CHANGELOG.md credits contributors +* humans.txt recognition +* Perimeter promotions publicly acknowledged + +==== Reversibility + +* Contributors can fork at any time +* No lock-in mechanisms +* Clear migration paths documented +* Perimeter demotion possible (with due process) + +==== Psychological Safety + +* Clear expectations reduce anxiety +* Structured feedback through reviews +* Mentorship opportunities +* Experimentation encouraged in feature branches + +==== Autonomy + +* Contributors control their involvement level +* No pressure to advance perimeters +* Fork-friendly governance +* Diverse contribution types valued + +=== Perimeter Transitions + +==== Nomination Process + +[arabic] +. *Self-nomination* or nomination by existing member +. *Discussion* among current perimeter members +. *Vote* (2/3 majority required) +. *Onboarding* and access provisioning +. *Announcement* in CHANGELOG and discussions + +==== Demotion Process + +Rare but possible for: - Extended inactivity (voluntary step-down) - +Repeated Code of Conduct violations - Security policy breaches + +*Process*: 1. Private discussion with maintainers 2. Opportunity to +respond 3. Vote if necessary (2/3 majority) 4. Transition support + +==== Emeritus Status + +Contributors who step down gracefully receive *Emeritus* recognition: - +Listed in MAINTAINERS.md - Contribution history preserved - Welcome to +return - Consulting/advisory role available + +=== Current State + +As of 2024-11-22: + +* *Perimeter 3*: ✅ Active and accepting contributions +* *Perimeter 2*: 🔜 No members yet (project in initial phase) +* *Perimeter 1*: 🔜 Founding maintainer(s) to be established + +=== Metrics and Transparency + +==== Public Dashboards + +(Planned): - Contribution statistics per perimeter - Time to review for +each level - Graduation timeline tracking + +==== Regular Reports + +Quarterly reports will include: - New perimeter promotions - +Contribution highlights - Community growth metrics - Governance +decisions + +=== Integration with RSR + +TPCF is a component of RSR (Rhodium Standard Repository) compliance: + +* ✅ Community governance structure +* ✅ Clear contribution pathways +* ✅ Security through graduated trust +* ✅ Emotional safety preservation + +=== References + +* link:../CODE_OF_CONDUCT.md[Code of Conduct] +* link:../CONTRIBUTING.md[Contributing Guidelines] +* link:../MAINTAINERS.md[Maintainers] +* link:../SECURITY.md[Security Policy] +* Palimpsest License: link:../LICENSE.txt[LICENSE.txt] + +''''' + +*Questions?* Open a discussion or contact maintainers (see +MAINTAINERS.md) diff --git a/asdf-augmenters/asdf-acceleration-middleware/docs/TPCF.md b/asdf-augmenters/asdf-acceleration-middleware/docs/TPCF.md deleted file mode 100644 index 8d896726..00000000 --- a/asdf-augmenters/asdf-acceleration-middleware/docs/TPCF.md +++ /dev/null @@ -1,244 +0,0 @@ -# Tri-Perimeter Contribution Framework (TPCF) - -This project implements the **Tri-Perimeter Contribution Framework** (TPCF), a graduated trust model for open source contributions. - -## Overview - -TPCF organizes contributors into three concentric perimeters based on trust level and contribution history, providing a clear path for community members to increase their involvement. - -## Perimeters - -### Perimeter 3: Community Sandbox - -**Current Status**: ✅ Active - -**Access Level**: Public contributions welcomed - -**Who**: All external contributors - -**Privileges**: -- Fork repository -- Submit pull requests -- Participate in discussions -- Report issues - -**Requirements**: -- Follow Code of Conduct -- Pass all CI checks -- Obtain code review approval from Perimeter 1 or 2 maintainers - -**Workflow**: -1. Fork the repository -2. Create feature branch -3. Make changes -4. Submit pull request -5. Address review feedback -6. Await approval and merge - -**Graduation Criteria** to Perimeter 2: -- ✅ 10+ merged pull requests -- ✅ 6+ months of consistent contributions -- ✅ Active code review participation -- ✅ Zero Code of Conduct violations -- ✅ Demonstrated technical expertise in project domain - -### Perimeter 2: Trusted Contributors - -**Current Status**: 🔜 Planned - -**Access Level**: Direct repository access - -**Who**: Experienced contributors with proven track record - -**Privileges**: -- Direct commit access to feature branches -- Review and approve pull requests -- Participate in architectural discussions -- Mentor new contributors - -**Requirements**: -- All Perimeter 3 requirements met -- Nominated by existing Perimeter 1 maintainer -- Approval vote by Perimeter 1 (2/3 majority) - -**Responsibilities**: -- Maintain code quality standards -- Review contributions promptly -- Uphold Code of Conduct -- Support community growth - -**Graduation Criteria** to Perimeter 1: -- ✅ 50+ merged pull requests -- ✅ 1+ year in Perimeter 2 -- ✅ Significant architectural contributions -- ✅ Active mentoring of other contributors -- ✅ Demonstrated project leadership - -### Perimeter 1: Core Maintainers - -**Current Status**: 🔜 To be established - -**Access Level**: Full repository control - -**Who**: Project leaders and primary maintainers - -**Privileges**: -- Release authority -- Main branch access -- Security issue triage -- Governance decisions -- Perimeter promotions - -**Requirements**: -- All Perimeter 2 requirements met -- Extensive contribution history -- Community leadership demonstrated -- Approval vote by existing Perimeter 1 (2/3 majority) - -**Responsibilities**: -- Strategic direction -- Release management -- Security response -- Governance and policy -- Community health - -## Benefits of TPCF - -### For Contributors - -1. **Clear Path**: Transparent progression from contributor to maintainer -2. **Recognition**: Formal acknowledgment of contributions -3. **Meritocratic**: Advancement based on actual contributions -4. **Safety**: Reduced anxiety through clear expectations - -### For the Project - -1. **Security**: Graduated trust reduces risk -2. **Sustainability**: Distributed maintenance burden -3. **Quality**: Multiple review layers -4. **Growth**: Structured onboarding for new contributors - -### For Users - -1. **Stability**: Experienced maintainers with skin in the game -2. **Accountability**: Clear ownership and responsibility -3. **Continuity**: Multiple maintainers prevent single points of failure - -## Comparison with Traditional Models - -| Aspect | Traditional OSS | TPCF | -|--------|----------------|------| -| Contribution | Binary (contributor/maintainer) | Graduated (3 levels) | -| Trust | All or nothing | Incremental | -| Onboarding | Informal | Structured | -| Recognition | Often implicit | Explicit perimeters | -| Security | Single barrier | Defense in depth | - -## Emotional Safety (Palimpsest Alignment) - -TPCF aligns with Palimpsest License emotional safety principles: - -### Attribution Persistence - -- Git history preserved permanently -- CHANGELOG.md credits contributors -- humans.txt recognition -- Perimeter promotions publicly acknowledged - -### Reversibility - -- Contributors can fork at any time -- No lock-in mechanisms -- Clear migration paths documented -- Perimeter demotion possible (with due process) - -### Psychological Safety - -- Clear expectations reduce anxiety -- Structured feedback through reviews -- Mentorship opportunities -- Experimentation encouraged in feature branches - -### Autonomy - -- Contributors control their involvement level -- No pressure to advance perimeters -- Fork-friendly governance -- Diverse contribution types valued - -## Perimeter Transitions - -### Nomination Process - -1. **Self-nomination** or nomination by existing member -2. **Discussion** among current perimeter members -3. **Vote** (2/3 majority required) -4. **Onboarding** and access provisioning -5. **Announcement** in CHANGELOG and discussions - -### Demotion Process - -Rare but possible for: -- Extended inactivity (voluntary step-down) -- Repeated Code of Conduct violations -- Security policy breaches - -**Process**: -1. Private discussion with maintainers -2. Opportunity to respond -3. Vote if necessary (2/3 majority) -4. Transition support - -### Emeritus Status - -Contributors who step down gracefully receive **Emeritus** recognition: -- Listed in MAINTAINERS.md -- Contribution history preserved -- Welcome to return -- Consulting/advisory role available - -## Current State - -As of 2024-11-22: - -- **Perimeter 3**: ✅ Active and accepting contributions -- **Perimeter 2**: 🔜 No members yet (project in initial phase) -- **Perimeter 1**: 🔜 Founding maintainer(s) to be established - -## Metrics and Transparency - -### Public Dashboards - -(Planned): -- Contribution statistics per perimeter -- Time to review for each level -- Graduation timeline tracking - -### Regular Reports - -Quarterly reports will include: -- New perimeter promotions -- Contribution highlights -- Community growth metrics -- Governance decisions - -## Integration with RSR - -TPCF is a component of RSR (Rhodium Standard Repository) compliance: - -- ✅ Community governance structure -- ✅ Clear contribution pathways -- ✅ Security through graduated trust -- ✅ Emotional safety preservation - -## References - -- [Code of Conduct](../CODE_OF_CONDUCT.md) -- [Contributing Guidelines](../CONTRIBUTING.md) -- [Maintainers](../MAINTAINERS.md) -- [Security Policy](../SECURITY.md) -- Palimpsest License: [LICENSE.txt](../LICENSE.txt) - ---- - -**Questions?** Open a discussion or contact maintainers (see MAINTAINERS.md) diff --git a/asdf-augmenters/asdf-control-tower/ABI-FFI-README.adoc b/asdf-augmenters/asdf-control-tower/ABI-FFI-README.adoc new file mode 100644 index 00000000..5ca994c1 --- /dev/null +++ b/asdf-augmenters/asdf-control-tower/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== CONTROL_TOWER ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/control-tower.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libcontrol-tower.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +control-tower/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── control-tower.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── control-tower.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/control-tower.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "control-tower.h" + +int main() { + void* handle = control-tower_init(); + if (!handle) return 1; + + int result = control-tower_process(handle, 42); + if (result != 0) { + const char* err = control-tower_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + control-tower_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lcontrol-tower -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import CONTROL_TOWER.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "control-tower")] +extern "C" { + fn control-tower_init() -> *mut std::ffi::c_void; + fn control-tower_free(handle: *mut std::ffi::c_void); + fn control-tower_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = control-tower_init(); + assert!(!handle.is_null()); + + let result = control-tower_process(handle, 42); + assert_eq!(result, 0); + + control-tower_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libcontrol-tower = "libcontrol-tower" + +function init() + handle = ccall((:control-tower_init, libcontrol-tower), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:control-tower_process, libcontrol-tower), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:control-tower_free, libcontrol-tower), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/control-tower.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-control-tower/ABI-FFI-README.md b/asdf-augmenters/asdf-control-tower/ABI-FFI-README.md deleted file mode 100644 index 36c7a5d0..00000000 --- a/asdf-augmenters/asdf-control-tower/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# CONTROL_TOWER ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/control-tower.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libcontrol-tower.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -control-tower/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── control-tower.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── control-tower.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/control-tower.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "control-tower.h" - -int main() { - void* handle = control-tower_init(); - if (!handle) return 1; - - int result = control-tower_process(handle, 42); - if (result != 0) { - const char* err = control-tower_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - control-tower_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lcontrol-tower -L./zig-out/lib -``` - -### From Idris2 - -```idris -import CONTROL_TOWER.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "control-tower")] -extern "C" { - fn control-tower_init() -> *mut std::ffi::c_void; - fn control-tower_free(handle: *mut std::ffi::c_void); - fn control-tower_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = control-tower_init(); - assert!(!handle.is_null()); - - let result = control-tower_process(handle, 42); - assert_eq!(result, 0); - - control-tower_free(handle); - } -} -``` - -### From Julia - -```julia -const libcontrol-tower = "libcontrol-tower" - -function init() - handle = ccall((:control-tower_init, libcontrol-tower), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:control-tower_process, libcontrol-tower), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:control-tower_free, libcontrol-tower), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/control-tower.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-control-tower/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-control-tower/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-control-tower/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-control-tower/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-control-tower/CODE_OF_CONDUCT.md deleted file mode 100644 index caeda1c6..00000000 --- a/asdf-augmenters/asdf-control-tower/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,27 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. - diff --git a/asdf-augmenters/asdf-control-tower/CONTRIBUTING.adoc b/asdf-augmenters/asdf-control-tower/CONTRIBUTING.adoc index eb045d61..084ee525 100644 --- a/asdf-augmenters/asdf-control-tower/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-control-tower/CONTRIBUTING.adoc @@ -1,20 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-control-tower/CONTRIBUTING.md b/asdf-augmenters/asdf-control-tower/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-control-tower/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-control-tower/SECURITY.adoc b/asdf-augmenters/asdf-control-tower/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-control-tower/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-control-tower/SECURITY.md b/asdf-augmenters/asdf-control-tower/SECURITY.md deleted file mode 100644 index 159a0b7a..00000000 --- a/asdf-augmenters/asdf-control-tower/SECURITY.md +++ /dev/null @@ -1,25 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection - diff --git a/asdf-augmenters/asdf-ghjk/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-ghjk/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..b885ab02 --- /dev/null +++ b/asdf-augmenters/asdf-ghjk/CODE_OF_CONDUCT.adoc @@ -0,0 +1,134 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We as members, contributors, and leaders pledge to make participation in +our community a harassment-free experience for everyone, regardless of +age, body size, visible or invisible disability, ethnicity, sex +characteristics, gender identity and expression, level of experience, +education, socio-economic status, nationality, personal appearance, +race, caste, color, religion, or sexual identity and orientation. + +We pledge to act and interact in ways that contribute to an open, +welcoming, diverse, inclusive, and healthy community. + +=== Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our +mistakes, and learning from the experience +* Focusing on what is best not just for us as individuals, but for the +overall community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or +advances of any kind +* Trolling, insulting or derogatory comments, and personal or political +attacks +* Public or private harassment +* Publishing others’ private information, such as a physical or email +address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a +professional setting + +=== Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our +standards of acceptable behavior and will take appropriate and fair +corrective action in response to any behavior that they deem +inappropriate, threatening, offensive, or harmful. + +Community leaders have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other +contributions that are not aligned to this Code of Conduct, and will +communicate reasons for moderation decisions when appropriate. + +=== Scope + +This Code of Conduct applies within all community spaces, and also +applies when an individual is officially representing the community in +public spaces. Examples of representing our community include using an +official e-mail address, posting via an official social media account, +or acting as an appointed representative at an online or offline event. + +=== Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may +be reported to the community leaders responsible for enforcement via +GitHub issues or by contacting the project maintainers directly. + +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security +of the reporter of any incident. + +=== Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in +determining the consequences for any action they deem in violation of +this Code of Conduct: + +==== 1. Correction + +*Community Impact*: Use of inappropriate language or other behavior +deemed unprofessional or unwelcome in the community. + +*Consequence*: A private, written warning from community leaders, +providing clarity around the nature of the violation and an explanation +of why the behavior was inappropriate. A public apology may be +requested. + +==== 2. Warning + +*Community Impact*: A violation through a single incident or series of +actions. + +*Consequence*: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, for a specified period of +time. This includes avoiding interactions in community spaces as well as +external channels like social media. Violating these terms may lead to a +temporary or permanent ban. + +==== 3. Temporary Ban + +*Community Impact*: A serious violation of community standards, +including sustained inappropriate behavior. + +*Consequence*: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No +public or private interaction with the people involved, including +unsolicited interaction with those enforcing the Code of Conduct, is +allowed during this period. Violating these terms may lead to a +permanent ban. + +==== 4. Permanent Ban + +*Community Impact*: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of +individuals. + +*Consequence*: A permanent ban from any sort of public interaction +within the community. + +=== Attribution + +This Code of Conduct is adapted from the +https://www.contributor-covenant.org[Contributor Covenant], version 2.1, +available at +https://www.contributor-covenant.org/version/2/1/code_of_conduct.html. + +Community Impact Guidelines were inspired by +https://github.com/mozilla/diversity[Mozilla’s code of conduct +enforcement ladder]. + +For answers to common questions about this code of conduct, see the FAQ +at https://www.contributor-covenant.org/faq. Translations are available +at https://www.contributor-covenant.org/translations. diff --git a/asdf-augmenters/asdf-ghjk/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-ghjk/CODE_OF_CONDUCT.md deleted file mode 100644 index 8ad2505b..00000000 --- a/asdf-augmenters/asdf-ghjk/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,133 +0,0 @@ -# Contributor Covenant Code of Conduct - -## Our Pledge - -We as members, contributors, and leaders pledge to make participation in our -community a harassment-free experience for everyone, regardless of age, body -size, visible or invisible disability, ethnicity, sex characteristics, gender -identity and expression, level of experience, education, socio-economic status, -nationality, personal appearance, race, caste, color, religion, or sexual -identity and orientation. - -We pledge to act and interact in ways that contribute to an open, welcoming, -diverse, inclusive, and healthy community. - -## Our Standards - -Examples of behavior that contributes to a positive environment for our -community include: - -* Demonstrating empathy and kindness toward other people -* Being respectful of differing opinions, viewpoints, and experiences -* Giving and gracefully accepting constructive feedback -* Accepting responsibility and apologizing to those affected by our mistakes, - and learning from the experience -* Focusing on what is best not just for us as individuals, but for the overall - community - -Examples of unacceptable behavior include: - -* The use of sexualized language or imagery, and sexual attention or advances of - any kind -* Trolling, insulting or derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or email address, - without their explicit permission -* Other conduct which could reasonably be considered inappropriate in a - professional setting - -## Enforcement Responsibilities - -Community leaders are responsible for clarifying and enforcing our standards of -acceptable behavior and will take appropriate and fair corrective action in -response to any behavior that they deem inappropriate, threatening, offensive, -or harmful. - -Community leaders have the right and responsibility to remove, edit, or reject -comments, commits, code, wiki edits, issues, and other contributions that are -not aligned to this Code of Conduct, and will communicate reasons for moderation -decisions when appropriate. - -## Scope - -This Code of Conduct applies within all community spaces, and also applies when -an individual is officially representing the community in public spaces. -Examples of representing our community include using an official e-mail address, -posting via an official social media account, or acting as an appointed -representative at an online or offline event. - -## Enforcement - -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported to the community leaders responsible for enforcement via GitHub issues -or by contacting the project maintainers directly. - -All complaints will be reviewed and investigated promptly and fairly. - -All community leaders are obligated to respect the privacy and security of the -reporter of any incident. - -## Enforcement Guidelines - -Community leaders will follow these Community Impact Guidelines in determining -the consequences for any action they deem in violation of this Code of Conduct: - -### 1. Correction - -**Community Impact**: Use of inappropriate language or other behavior deemed -unprofessional or unwelcome in the community. - -**Consequence**: A private, written warning from community leaders, providing -clarity around the nature of the violation and an explanation of why the -behavior was inappropriate. A public apology may be requested. - -### 2. Warning - -**Community Impact**: A violation through a single incident or series of -actions. - -**Consequence**: A warning with consequences for continued behavior. No -interaction with the people involved, including unsolicited interaction with -those enforcing the Code of Conduct, for a specified period of time. This -includes avoiding interactions in community spaces as well as external channels -like social media. Violating these terms may lead to a temporary or permanent -ban. - -### 3. Temporary Ban - -**Community Impact**: A serious violation of community standards, including -sustained inappropriate behavior. - -**Consequence**: A temporary ban from any sort of interaction or public -communication with the community for a specified period of time. No public or -private interaction with the people involved, including unsolicited interaction -with those enforcing the Code of Conduct, is allowed during this period. -Violating these terms may lead to a permanent ban. - -### 4. Permanent Ban - -**Community Impact**: Demonstrating a pattern of violation of community -standards, including sustained inappropriate behavior, harassment of an -individual, or aggression toward or disparagement of classes of individuals. - -**Consequence**: A permanent ban from any sort of public interaction within the -community. - -## Attribution - -This Code of Conduct is adapted from the [Contributor Covenant][homepage], -version 2.1, available at -[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. - -Community Impact Guidelines were inspired by -[Mozilla's code of conduct enforcement ladder][Mozilla CoC]. - -For answers to common questions about this code of conduct, see the FAQ at -[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at -[https://www.contributor-covenant.org/translations][translations]. - -[homepage]: https://www.contributor-covenant.org -[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html -[Mozilla CoC]: https://github.com/mozilla/diversity -[FAQ]: https://www.contributor-covenant.org/faq -[translations]: https://www.contributor-covenant.org/translations diff --git a/asdf-augmenters/asdf-ghjk/CONTRIBUTING.adoc b/asdf-augmenters/asdf-ghjk/CONTRIBUTING.adoc index eb045d61..780e2775 100644 --- a/asdf-augmenters/asdf-ghjk/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-ghjk/CONTRIBUTING.adoc @@ -1,20 +1,108 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-ghjk.git cd asdf-ghjk -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-ghjk-dev toolbox enter asdf-ghjk-dev # Install +dependencies manually -Contributions licensed under project license. +== Verify setup +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-ghjk/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # Library +code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) ├── +plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) ├── +docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, specs +(Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ # +Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ # +Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files (Perimeter +1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── ISSUE_TEMPLATE/ │ +└── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── +CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-ghjk/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-ghjk/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-ghjk/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-ghjk/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-ghjk/CONTRIBUTING.md b/asdf-augmenters/asdf-ghjk/CONTRIBUTING.md deleted file mode 100644 index 4f7fb5b7..00000000 --- a/asdf-augmenters/asdf-ghjk/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-ghjk.git -cd asdf-ghjk - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-ghjk-dev -toolbox enter asdf-ghjk-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-ghjk/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-ghjk/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-ghjk/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-ghjk/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-ghjk/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-ghjk/MAINTAINERS.adoc b/asdf-augmenters/asdf-ghjk/MAINTAINERS.adoc index 48d97817..c57da9d0 100644 --- a/asdf-augmenters/asdf-ghjk/MAINTAINERS.adoc +++ b/asdf-augmenters/asdf-ghjk/MAINTAINERS.adoc @@ -1,47 +1,108 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Maintainers -:toc: preamble +== Maintainers -This document lists the maintainers of this project and their responsibilities. +This document lists the maintainers of the asdf-ghjk project. -== Current Maintainers +=== Active Maintainers -[cols="2,3,2",options="header"] -|=== -| Name | Role | Contact +==== Core Maintainers -| Jonathan D.A. Jewell -| Lead Maintainer -| https://github.com/hyperpolymath[@hyperpolymath] +[width="100%",cols="17%,21%,15%,47%",options="header",] +|=== +|Name |GitHub |Role |Responsibilities +|Hyperpolymath |@Hyperpolymath |Lead Maintainer |Overall project +direction, releases, core features |=== -== Responsibilities +=== Maintainer Responsibilities Maintainers are responsible for: -* Reviewing and merging pull requests -* Triaging issues and feature requests -* Ensuring code quality and security standards -* Managing releases and versioning -* Upholding the project's code of conduct +[arabic] +. *Code Review*: Reviewing and merging pull requests +. *Issue Triage*: Labeling, prioritizing, and closing issues +. *Releases*: Creating and publishing releases +. *Security*: Responding to security issues and coordinating fixes +. *Community*: Fostering a welcoming and inclusive community +. *Documentation*: Maintaining and improving documentation +. *CI/CD*: Maintaining build and test infrastructure + +=== Becoming a Maintainer + +We welcome new maintainers! To become a maintainer: + +[arabic] +. *Contribute Consistently*: Make regular, high-quality contributions +. *Demonstrate Expertise*: Show deep understanding of the project +. *Help Others*: Actively participate in code reviews and discussions +. *Follow Guidelines*: Adhere to project standards and Code of Conduct +. *Nomination*: Existing maintainers will nominate and vote on new +maintainers + +==== Criteria + +* 10+ merged pull requests +* 3+ months of active participation +* Demonstrated technical expertise +* Strong communication skills +* Commitment to project values + +=== Emeritus Maintainers + +Maintainers who are no longer active but have made significant +contributions: + +[cols=",,,",options="header",] +|=== +|Name |GitHub |Period |Contributions +|_None yet_ |- |- |- +|=== + +=== Decision Making + +==== Consensus-Based + +We use consensus-based decision making: + +[arabic] +. *Proposal*: Anyone can propose changes via issues or discussions +. *Discussion*: Community discusses the proposal +. *Consensus*: Maintainers reach consensus (not unanimous vote) +. *Implementation*: Approved proposals are implemented + +==== Voting + +For significant decisions where consensus cannot be reached: + +* Simple majority of active maintainers +* Lead maintainer has tie-breaking vote +* All maintainers must be notified + +==== Significant Decisions + +These require explicit maintainer consensus: -== Becoming a Maintainer +* Breaking changes to public APIs +* Major architectural changes +* Addition/removal of dependencies +* Changes to contribution guidelines +* Addition/removal of maintainers +* License changes -Contributors who demonstrate: +=== Contact -* Consistent, high-quality contributions -* Understanding of the project's goals and standards -* Constructive participation in discussions -* Commitment to the project's long-term health +* *General Questions*: Open an issue +* *Security Issues*: See SECURITY.md +* *Private Matters*: Contact maintainers via GitHub -May be invited to become maintainers at the discretion of existing maintainers. +=== Acknowledgments -== Decision Making +Thank you to all our contributors! See the +https://github.com/Hyperpolymath/asdf-ghjk/graphs/contributors[contributors +page] for a full list. -* Routine decisions (bug fixes, minor improvements) can be made by any maintainer -* Significant changes require discussion and consensus among maintainers -* Breaking changes or major features should be discussed in issues before implementation +''''' -== Contact +*Note*: This document follows the RSR (Rhodium Standard Repository) +Framework’s MAINTAINERS.md specification. -For questions about project governance, open an issue or contact the maintainers listed above. +*Last Updated*: 2024-11-22 diff --git a/asdf-augmenters/asdf-ghjk/MAINTAINERS.md b/asdf-augmenters/asdf-ghjk/MAINTAINERS.md deleted file mode 100644 index 4e768daf..00000000 --- a/asdf-augmenters/asdf-ghjk/MAINTAINERS.md +++ /dev/null @@ -1,95 +0,0 @@ -# Maintainers - -This document lists the maintainers of the asdf-ghjk project. - -## Active Maintainers - -### Core Maintainers - -| Name | GitHub | Role | Responsibilities | -|------|--------|------|------------------| -| Hyperpolymath | @Hyperpolymath | Lead Maintainer | Overall project direction, releases, core features | - -## Maintainer Responsibilities - -Maintainers are responsible for: - -1. **Code Review**: Reviewing and merging pull requests -2. **Issue Triage**: Labeling, prioritizing, and closing issues -3. **Releases**: Creating and publishing releases -4. **Security**: Responding to security issues and coordinating fixes -5. **Community**: Fostering a welcoming and inclusive community -6. **Documentation**: Maintaining and improving documentation -7. **CI/CD**: Maintaining build and test infrastructure - -## Becoming a Maintainer - -We welcome new maintainers! To become a maintainer: - -1. **Contribute Consistently**: Make regular, high-quality contributions -2. **Demonstrate Expertise**: Show deep understanding of the project -3. **Help Others**: Actively participate in code reviews and discussions -4. **Follow Guidelines**: Adhere to project standards and Code of Conduct -5. **Nomination**: Existing maintainers will nominate and vote on new maintainers - -### Criteria - -- 10+ merged pull requests -- 3+ months of active participation -- Demonstrated technical expertise -- Strong communication skills -- Commitment to project values - -## Emeritus Maintainers - -Maintainers who are no longer active but have made significant contributions: - -| Name | GitHub | Period | Contributions | -|------|--------|--------|---------------| -| _None yet_ | - | - | - | - -## Decision Making - -### Consensus-Based - -We use consensus-based decision making: - -1. **Proposal**: Anyone can propose changes via issues or discussions -2. **Discussion**: Community discusses the proposal -3. **Consensus**: Maintainers reach consensus (not unanimous vote) -4. **Implementation**: Approved proposals are implemented - -### Voting - -For significant decisions where consensus cannot be reached: - -- Simple majority of active maintainers -- Lead maintainer has tie-breaking vote -- All maintainers must be notified - -### Significant Decisions - -These require explicit maintainer consensus: - -- Breaking changes to public APIs -- Major architectural changes -- Addition/removal of dependencies -- Changes to contribution guidelines -- Addition/removal of maintainers -- License changes - -## Contact - -- **General Questions**: Open an issue -- **Security Issues**: See SECURITY.md -- **Private Matters**: Contact maintainers via GitHub - -## Acknowledgments - -Thank you to all our contributors! See the [contributors page](https://github.com/Hyperpolymath/asdf-ghjk/graphs/contributors) for a full list. - ---- - -**Note**: This document follows the RSR (Rhodium Standard Repository) Framework's MAINTAINERS.md specification. - -**Last Updated**: 2024-11-22 diff --git a/asdf-augmenters/asdf-ghjk/PROJECT_SUMMARY.adoc b/asdf-augmenters/asdf-ghjk/PROJECT_SUMMARY.adoc new file mode 100644 index 00000000..f32bec69 --- /dev/null +++ b/asdf-augmenters/asdf-ghjk/PROJECT_SUMMARY.adoc @@ -0,0 +1,499 @@ +== asdf-ghjk: Complete Project Summary + +*Branch*: `+claude/create-claude-md-0185REoNFa5vvHxsmFjiaNKc+` +*Completion Date*: 2024-11-22 *Total Files*: 60+ *Total Lines*: 7,200+ +*RSR Level*: *Platinum* (100% compliance) *Development Time*: ~1 session +with maximum credit utilization + +''''' + +=== 🎉 Achievement: RSR Platinum Level + +*RSR Score: 100% (73/73 checks passed)* + +This project has achieved the highest possible RSR (Rhodium Standard +Repository) Framework compliance level, making it suitable for: - +Enterprise production use - Open source community collaboration - +Academic research reference - Professional portfolio showcase + +''''' + +=== 📊 What Was Built + +==== Core Functionality (Production-Ready) + +* ✅ Full asdf plugin implementation (list-all, download, install) +* ✅ Multi-platform support (Linux x86_64/ARM64, macOS Intel/Apple +Silicon) +* ✅ SHA256 checksum verification for security +* ✅ GitHub API caching with configurable TTL +* ✅ Retry logic with exponential backoff +* ✅ Comprehensive error handling and logging + +==== Documentation (14 Comprehensive Guides) + +[arabic] +. *README.md* - Complete user guide with examples +. *CONTRIBUTING.md* - Developer contribution guide +. *CODE_OF_CONDUCT.md* - Contributor Covenant 2.1 +. *MAINTAINERS.md* - Governance and maintainer info +. *SECURITY.md* - Security policy and vulnerability disclosure +. *CHANGELOG.md* - Version history (Keep a Changelog format) +. *ARCHITECTURE.md* - Internal architecture and design +. *API_REFERENCE.md* - Complete function/script reference +. *FAQ.md* - 30+ frequently asked questions +. *QUICKSTART.md* - 5-minute setup guide +. *TROUBLESHOOTING.md* - Solutions to common issues +. *EXAMPLES.md* - Real-world usage scenarios +. *MIGRATION.md* - Migration from standalone ghjk +. *COMPATIBILITY.md* - Platform/version compatibility matrix +. *RSR.md* - RSR Framework compliance documentation + +*Total Documentation*: 10,000+ words + +==== Testing (Comprehensive Coverage) + +* ✅ BATS test suite (unit + integration) +* ✅ 5 test files covering all core functionality +* ✅ Test helpers and fixtures +* ✅ GitHub Actions CI/CD +* ✅ Multi-platform testing (Ubuntu, macOS) +* ✅ ShellCheck linting for all scripts +* ✅ 100% test pass rate + +==== Build Systems (Triple Support) + +[arabic] +. *Makefile* - Traditional GNU Make automation +. *justfile* - Modern task runner with 50+ recipes +. *flake.guix* - Guix reproducible builds + +==== Developer Tools + +* ✅ `+scripts/setup-dev.sh+` - Development environment setup +* ✅ `+scripts/test.sh+` - Test runner +* ✅ `+scripts/benchmark.sh+` - Performance benchmarking +* ✅ `+scripts/doctor.sh+` - Diagnostic troubleshooting +* ✅ `+scripts/cleanup.sh+` - Disk usage management +* ✅ `+scripts/rsr-verify.sh+` - RSR compliance verification + +==== Advanced Features + +* ✅ Shell completions (Bash & Zsh) +* ✅ Docker integration (3 examples) +* ✅ Latest-stable version detection +* ✅ API response caching (configurable TTL) +* ✅ Pre-commit hooks configuration + +==== .well-known Directory (RFC Standards) + +* ✅ `+security.txt+` - RFC 9116 compliant security contact +* ✅ `+ai.txt+` - AI training and usage policy +* ✅ `+humans.txt+` - Human-readable attribution + +==== Licensing + +* ✅ Dual licensing: MIT + Palimpsest v0.8 +* ✅ User choice of license +* ✅ SPDX identifiers +* ✅ OSI-approved permissive terms + +==== Quality Assurance + +* ✅ GitHub issue templates (bug, feature request) +* ✅ Pull request template +* ✅ CODEOWNERS for automated reviews +* ✅ EditorConfig for consistency +* ✅ Comprehensive .gitignore + +''''' + +=== 📈 RSR Compliance Breakdown + +==== Category Scores (All 100%) + +[cols=",,,",options="header",] +|=== +|Category |Checks |Passed |Score +|1. Documentation |14 |14 |✅ 100% +|2. Licensing |5 |5 |✅ 100% +|3. Security |6 |6 |✅ 100% +|4. Contributing |6 |6 |✅ 100% +|5. Governance |6 |6 |✅ 100% +|6. Testing |6 |6 |✅ 100% +|7. Build System |7 |7 |✅ 100% +|8. Versioning |3 |3 |✅ 100% +|9. .well-known |6 |6 |✅ 100% +|10. Community |4 |4 |✅ 100% +|11. Automation |5 |5 |✅ 100% +|*Bonus Markers* |5 |5 |✅ 100% +|*TOTAL* |*73* |*73* |*✅ 100%* +|=== + +==== TPCF Declaration + +*Perimeter*: *3 - Community Sandbox* + +*Characteristics*: - Open to all contributors - Maintainer review +required - Community-driven governance - Consensus-based decision making +- Pull request workflow - Public trust model + +''''' + +=== 🗂️ File Structure + +.... +asdf-ghjk/ (60 files) +├── bin/ (6 scripts) +│ ├── download - Download ghjk releases +│ ├── install - Install downloaded releases +│ ├── list-all - List available versions +│ ├── list-bin-paths - Binary paths for asdf +│ ├── help-overview - User help text +│ └── latest-stable - Latest stable version +├── lib/ (2 libraries) +│ ├── utils.sh - Core utilities (~800 LOC) +│ └── cache.sh - API caching (~150 LOC) +├── test/ (5 test files) +│ ├── utils.bats - Unit tests +│ ├── list-all.bats - Version listing tests +│ ├── download.bats - Download tests +│ ├── install.bats - Installation tests +│ └── test_helpers.bash - Test helpers +├── scripts/ (6 tools) +│ ├── setup-dev.sh - Dev environment setup +│ ├── test.sh - Test runner +│ ├── benchmark.sh - Performance benchmarks +│ ├── doctor.sh - Diagnostics +│ ├── cleanup.sh - Maintenance +│ └── rsr-verify.sh - RSR compliance check +├── docs/ (11 guides) +│ ├── ARCHITECTURE.md +│ ├── API_REFERENCE.md +│ ├── FAQ.md +│ ├── QUICKSTART.md +│ ├── TROUBLESHOOTING.md +│ ├── EXAMPLES.md +│ ├── MIGRATION.md +│ └── COMPATIBILITY.md +├── examples/ (3 files) +│ ├── Dockerfile +│ ├── Dockerfile.multi-stage +│ └── docker-compose.yml +├── completions/ (2 files) +│ ├── ghjk.bash +│ └── ghjk.zsh +├── .well-known/ (3 files) +│ ├── security.txt +│ ├── ai.txt +│ └── humans.txt +├── .github/ (9 files) +│ ├── workflows/ +│ │ ├── ci.yml +│ │ └── release.yml +│ ├── ISSUE_TEMPLATE/ +│ │ ├── bug_report.md +│ │ └── feature_request.md +│ ├── pull_request_template.md +│ ├── CODEOWNERS +│ └── FUNDING.yml +└── Root files (14 files) + ├── README.md + ├── CONTRIBUTING.md + ├── CODE_OF_CONDUCT.md + ├── MAINTAINERS.md + ├── SECURITY.md + ├── CHANGELOG.md + ├── LICENSE.txt (dual MIT + Palimpsest) + ├── RSR.md + ├── Makefile + ├── Justfile + ├── flake.guix + ├── .editorconfig + ├── .shellcheckrc + ├── .pre-commit-config.yaml + └── .gitignore +.... + +''''' + +=== 🚀 Quick Start (for Users) + +==== Installation + +[source,bash] +---- +# Add the plugin +asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git + +# Install latest version +asdf install ghjk latest + +# Set as default +asdf global ghjk latest + +# Verify +ghjk --version +---- + +==== Development + +[source,bash] +---- +# Clone the repository +git clone https://github.com/Hyperpolymath/asdf-ghjk.git +cd asdf-ghjk + +# Set up development environment +just setup +# or: make dev-setup +# or: ./scripts/setup-dev.sh + +# Run tests +just test +# or: make test +# or: ./scripts/test.sh + +# Run linting +just lint +# or: make lint + +# Verify RSR compliance +just rsr-check +# or: ./scripts/rsr-verify.sh +---- + +''''' + +=== 🔍 Verification Commands + +==== RSR Compliance + +[source,bash] +---- +./scripts/rsr-verify.sh +# Expected: Platinum level, 100% score +---- + +==== Tests + +[source,bash] +---- +just test +# Expected: All tests pass +---- + +==== Linting + +[source,bash] +---- +just lint +# Expected: No ShellCheck warnings +---- + +==== Diagnostics + +[source,bash] +---- +./scripts/doctor.sh +# Expected: All checks pass +---- + +''''' + +=== 📚 Key Documentation Links + +* *User Guide*: README.md +* *Quick Start*: docs/QUICKSTART.md (5 minutes) +* *Troubleshooting*: docs/TROUBLESHOOTING.md +* *Examples*: docs/EXAMPLES.md +* *API Reference*: docs/API_REFERENCE.md +* *Contributing*: CONTRIBUTING.md +* *Security*: SECURITY.md +* *RSR Compliance*: RSR.md + +''''' + +=== 🎯 Comparison to RSR rhodium-minimal Example + +[width="100%",cols="22%,37%,25%,16%",options="header",] +|=== +|Feature |rhodium-minimal |asdf-ghjk |Notes +|RSR Level |Bronze |*Platinum* |Exceeds reference +|Documentation |Basic |Comprehensive |14 vs 7 docs +|Testing |Unit only |Unit + Integration |BATS suite +|Build Systems |2 (just, Guix) |*3* (Make, just, Guix) |Triple support +|.well-known |3 files |*3 files* |RFC compliant +|TPCF |Perimeter 3 |*Perimeter 3* |Community Sandbox +|Language |Rust (100 LOC) |Bash (~7,200 LOC) |Production-scale +|Lines of Code |100 |*7,200* |72x larger +|Files |~20 |*60* |3x more +|CI/CD |GitLab |*GitHub Actions* |Multi-platform +|=== + +''''' + +=== 💡 Innovation Highlights + +==== Beyond RSR Requirements + +[arabic] +. *Triple Build System Support* +* Traditional Make for compatibility +* Modern just for developer experience +* Guix for reproducibility +. *Comprehensive Tooling* +* Performance benchmarking +* System diagnostics (doctor.sh) +* Automated cleanup +* Cache management +. *Multi-Platform CI/CD* +* Ubuntu 20.04, 22.04 +* macOS Intel and Apple Silicon +* Automated compatibility testing +. *Developer Experience* +* Shell completions (Bash, Zsh) +* Pre-commit hooks +* EditorConfig support +* 50+ just recipes +. *Security-First* +* SHA256 checksum verification +* HTTPS-only downloads +* RFC 9116 security.txt +* Input validation throughout + +''''' + +=== 🏆 Achievement Metrics + +==== Code Quality + +* *ShellCheck*: 100% compliant (no warnings) +* *Test Coverage*: 100% of core functions +* *CI/CD*: Multi-platform automated testing +* *Documentation*: 10,000+ words + +==== Project Management + +* *RSR Level*: Platinum (100%) +* *TPCF*: Perimeter 3 declared +* *Licensing*: Dual permissive (MIT + Palimpsest) +* *Governance*: Documented and transparent + +==== Developer Experience + +* *Setup Time*: < 5 minutes +* *Build Systems*: 3 (Make, just, Guix) +* *Automation*: 50+ recipes +* *Diagnostics*: Automated troubleshooting + +''''' + +=== 🎓 Suitable For + +This project is suitable as: + +==== Reference Implementation + +* ✅ RSR Framework Platinum example +* ✅ asdf plugin best practices +* ✅ Shell scripting standards +* ✅ Open source project template + +==== Production Use + +* ✅ Enterprise-grade quality +* ✅ Comprehensive security +* ✅ Multi-platform support +* ✅ Well-documented and maintained + +==== Educational Purpose + +* ✅ Shell scripting examples +* ✅ Testing with BATS +* ✅ CI/CD patterns +* ✅ Documentation standards + +==== Portfolio/Resume + +* ✅ Platinum-level RSR compliance +* ✅ Professional quality +* ✅ Comprehensive documentation +* ✅ Production-ready code + +''''' + +=== 🔮 Future Enhancements + +While the project is feature-complete, potential additions: + +[arabic] +. *Community Growth* +* Submission to asdf plugin registry +* Community contributions +* User adoption metrics +. *Advanced Features* +* Parallel version installations +* Plugin marketplace integration +* Advanced caching strategies +. *Ecosystem Integration* +* Homebrew formula +* Package repository submissions +* Integration with other tools + +''''' + +=== 📞 Getting Help + +* *Issues*: https://github.com/Hyperpolymath/asdf-ghjk/issues +* *Discussions*: https://github.com/Hyperpolymath/asdf-ghjk/discussions +* *Security*: See SECURITY.md +* *Contributing*: See CONTRIBUTING.md + +''''' + +=== ✅ Verification Checklist + +Use this to verify the project state: + +* [ ] Clone repository +* [ ] Run `+./scripts/rsr-verify.sh+` → Should show Platinum +* [ ] Run `+just test+` or `+make test+` → All tests pass +* [ ] Run `+just lint+` → No warnings +* [ ] Run `+./scripts/doctor.sh+` → All checks pass +* [ ] Review RSR.md → All categories 100% +* [ ] Check `+.well-known/+` files → All present +* [ ] Verify dual licensing → LICENSE.txt has both +* [ ] Count files → Should be 60+ +* [ ] Count lines → Should be 7,200+ + +''''' + +=== 🙏 Credits + +* *asdf-vm Team*: For creating asdf framework +* *ghjk Team (Metatype)*: For ghjk tool +* *Claude (Anthropic)*: AI development assistance +* *Open Source Community*: For tools and inspiration +* *RSR Framework*: For comprehensive standards + +''''' + +=== 📜 License + +Dual licensed under: - MIT License (OSI-approved, permissive) - +Palimpsest License v0.8 (philosophical, permissive) + +Users may choose either license. + +SPDX-License-Identifier: CC-BY-SA-4.0 + +''''' + +*Status*: ✅ Complete and Ready *Quality*: 🏆 Platinum Level RSR +Compliance *Next Steps*: Review, test, and deploy + +''''' + +_This project represents the maximum utilization of development credits +with comprehensive, production-ready code and documentation._ diff --git a/asdf-augmenters/asdf-ghjk/PROJECT_SUMMARY.md b/asdf-augmenters/asdf-ghjk/PROJECT_SUMMARY.md deleted file mode 100644 index 08548b21..00000000 --- a/asdf-augmenters/asdf-ghjk/PROJECT_SUMMARY.md +++ /dev/null @@ -1,478 +0,0 @@ -# asdf-ghjk: Complete Project Summary - -**Branch**: `claude/create-claude-md-0185REoNFa5vvHxsmFjiaNKc` -**Completion Date**: 2024-11-22 -**Total Files**: 60+ -**Total Lines**: 7,200+ -**RSR Level**: **Platinum** (100% compliance) -**Development Time**: ~1 session with maximum credit utilization - ---- - -## 🎉 Achievement: RSR Platinum Level - -**RSR Score: 100% (73/73 checks passed)** - -This project has achieved the highest possible RSR (Rhodium Standard Repository) Framework compliance level, making it suitable for: -- Enterprise production use -- Open source community collaboration -- Academic research reference -- Professional portfolio showcase - ---- - -## 📊 What Was Built - -### Core Functionality (Production-Ready) -- ✅ Full asdf plugin implementation (list-all, download, install) -- ✅ Multi-platform support (Linux x86_64/ARM64, macOS Intel/Apple Silicon) -- ✅ SHA256 checksum verification for security -- ✅ GitHub API caching with configurable TTL -- ✅ Retry logic with exponential backoff -- ✅ Comprehensive error handling and logging - -### Documentation (14 Comprehensive Guides) -1. **README.md** - Complete user guide with examples -2. **CONTRIBUTING.md** - Developer contribution guide -3. **CODE_OF_CONDUCT.md** - Contributor Covenant 2.1 -4. **MAINTAINERS.md** - Governance and maintainer info -5. **SECURITY.md** - Security policy and vulnerability disclosure -6. **CHANGELOG.md** - Version history (Keep a Changelog format) -7. **ARCHITECTURE.md** - Internal architecture and design -8. **API_REFERENCE.md** - Complete function/script reference -9. **FAQ.md** - 30+ frequently asked questions -10. **QUICKSTART.md** - 5-minute setup guide -11. **TROUBLESHOOTING.md** - Solutions to common issues -12. **EXAMPLES.md** - Real-world usage scenarios -13. **MIGRATION.md** - Migration from standalone ghjk -14. **COMPATIBILITY.md** - Platform/version compatibility matrix -15. **RSR.md** - RSR Framework compliance documentation - -**Total Documentation**: 10,000+ words - -### Testing (Comprehensive Coverage) -- ✅ BATS test suite (unit + integration) -- ✅ 5 test files covering all core functionality -- ✅ Test helpers and fixtures -- ✅ GitHub Actions CI/CD -- ✅ Multi-platform testing (Ubuntu, macOS) -- ✅ ShellCheck linting for all scripts -- ✅ 100% test pass rate - -### Build Systems (Triple Support) -1. **Makefile** - Traditional GNU Make automation -2. **justfile** - Modern task runner with 50+ recipes -3. **flake.guix** - Guix reproducible builds - -### Developer Tools -- ✅ `scripts/setup-dev.sh` - Development environment setup -- ✅ `scripts/test.sh` - Test runner -- ✅ `scripts/benchmark.sh` - Performance benchmarking -- ✅ `scripts/doctor.sh` - Diagnostic troubleshooting -- ✅ `scripts/cleanup.sh` - Disk usage management -- ✅ `scripts/rsr-verify.sh` - RSR compliance verification - -### Advanced Features -- ✅ Shell completions (Bash & Zsh) -- ✅ Docker integration (3 examples) -- ✅ Latest-stable version detection -- ✅ API response caching (configurable TTL) -- ✅ Pre-commit hooks configuration - -### .well-known Directory (RFC Standards) -- ✅ `security.txt` - RFC 9116 compliant security contact -- ✅ `ai.txt` - AI training and usage policy -- ✅ `humans.txt` - Human-readable attribution - -### Licensing -- ✅ Dual licensing: MIT + Palimpsest v0.8 -- ✅ User choice of license -- ✅ SPDX identifiers -- ✅ OSI-approved permissive terms - -### Quality Assurance -- ✅ GitHub issue templates (bug, feature request) -- ✅ Pull request template -- ✅ CODEOWNERS for automated reviews -- ✅ EditorConfig for consistency -- ✅ Comprehensive .gitignore - ---- - -## 📈 RSR Compliance Breakdown - -### Category Scores (All 100%) - -| Category | Checks | Passed | Score | -|----------|--------|--------|-------| -| 1. Documentation | 14 | 14 | ✅ 100% | -| 2. Licensing | 5 | 5 | ✅ 100% | -| 3. Security | 6 | 6 | ✅ 100% | -| 4. Contributing | 6 | 6 | ✅ 100% | -| 5. Governance | 6 | 6 | ✅ 100% | -| 6. Testing | 6 | 6 | ✅ 100% | -| 7. Build System | 7 | 7 | ✅ 100% | -| 8. Versioning | 3 | 3 | ✅ 100% | -| 9. .well-known | 6 | 6 | ✅ 100% | -| 10. Community | 4 | 4 | ✅ 100% | -| 11. Automation | 5 | 5 | ✅ 100% | -| **Bonus Markers** | 5 | 5 | ✅ 100% | -| **TOTAL** | **73** | **73** | **✅ 100%** | - -### TPCF Declaration - -**Perimeter**: **3 - Community Sandbox** - -**Characteristics**: -- Open to all contributors -- Maintainer review required -- Community-driven governance -- Consensus-based decision making -- Pull request workflow -- Public trust model - ---- - -## 🗂️ File Structure - -``` -asdf-ghjk/ (60 files) -├── bin/ (6 scripts) -│ ├── download - Download ghjk releases -│ ├── install - Install downloaded releases -│ ├── list-all - List available versions -│ ├── list-bin-paths - Binary paths for asdf -│ ├── help-overview - User help text -│ └── latest-stable - Latest stable version -├── lib/ (2 libraries) -│ ├── utils.sh - Core utilities (~800 LOC) -│ └── cache.sh - API caching (~150 LOC) -├── test/ (5 test files) -│ ├── utils.bats - Unit tests -│ ├── list-all.bats - Version listing tests -│ ├── download.bats - Download tests -│ ├── install.bats - Installation tests -│ └── test_helpers.bash - Test helpers -├── scripts/ (6 tools) -│ ├── setup-dev.sh - Dev environment setup -│ ├── test.sh - Test runner -│ ├── benchmark.sh - Performance benchmarks -│ ├── doctor.sh - Diagnostics -│ ├── cleanup.sh - Maintenance -│ └── rsr-verify.sh - RSR compliance check -├── docs/ (11 guides) -│ ├── ARCHITECTURE.md -│ ├── API_REFERENCE.md -│ ├── FAQ.md -│ ├── QUICKSTART.md -│ ├── TROUBLESHOOTING.md -│ ├── EXAMPLES.md -│ ├── MIGRATION.md -│ └── COMPATIBILITY.md -├── examples/ (3 files) -│ ├── Dockerfile -│ ├── Dockerfile.multi-stage -│ └── docker-compose.yml -├── completions/ (2 files) -│ ├── ghjk.bash -│ └── ghjk.zsh -├── .well-known/ (3 files) -│ ├── security.txt -│ ├── ai.txt -│ └── humans.txt -├── .github/ (9 files) -│ ├── workflows/ -│ │ ├── ci.yml -│ │ └── release.yml -│ ├── ISSUE_TEMPLATE/ -│ │ ├── bug_report.md -│ │ └── feature_request.md -│ ├── pull_request_template.md -│ ├── CODEOWNERS -│ └── FUNDING.yml -└── Root files (14 files) - ├── README.md - ├── CONTRIBUTING.md - ├── CODE_OF_CONDUCT.md - ├── MAINTAINERS.md - ├── SECURITY.md - ├── CHANGELOG.md - ├── LICENSE.txt (dual MIT + Palimpsest) - ├── RSR.md - ├── Makefile - ├── Justfile - ├── flake.guix - ├── .editorconfig - ├── .shellcheckrc - ├── .pre-commit-config.yaml - └── .gitignore -``` - ---- - -## 🚀 Quick Start (for Users) - -### Installation - -```bash -# Add the plugin -asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git - -# Install latest version -asdf install ghjk latest - -# Set as default -asdf global ghjk latest - -# Verify -ghjk --version -``` - -### Development - -```bash -# Clone the repository -git clone https://github.com/Hyperpolymath/asdf-ghjk.git -cd asdf-ghjk - -# Set up development environment -just setup -# or: make dev-setup -# or: ./scripts/setup-dev.sh - -# Run tests -just test -# or: make test -# or: ./scripts/test.sh - -# Run linting -just lint -# or: make lint - -# Verify RSR compliance -just rsr-check -# or: ./scripts/rsr-verify.sh -``` - ---- - -## 🔍 Verification Commands - -### RSR Compliance -```bash -./scripts/rsr-verify.sh -# Expected: Platinum level, 100% score -``` - -### Tests -```bash -just test -# Expected: All tests pass -``` - -### Linting -```bash -just lint -# Expected: No ShellCheck warnings -``` - -### Diagnostics -```bash -./scripts/doctor.sh -# Expected: All checks pass -``` - ---- - -## 📚 Key Documentation Links - -- **User Guide**: README.md -- **Quick Start**: docs/QUICKSTART.md (5 minutes) -- **Troubleshooting**: docs/TROUBLESHOOTING.md -- **Examples**: docs/EXAMPLES.md -- **API Reference**: docs/API_REFERENCE.md -- **Contributing**: CONTRIBUTING.md -- **Security**: SECURITY.md -- **RSR Compliance**: RSR.md - ---- - -## 🎯 Comparison to RSR rhodium-minimal Example - -| Feature | rhodium-minimal | asdf-ghjk | Notes | -|---------|----------------|-----------|-------| -| RSR Level | Bronze | **Platinum** | Exceeds reference | -| Documentation | Basic | Comprehensive | 14 vs 7 docs | -| Testing | Unit only | Unit + Integration | BATS suite | -| Build Systems | 2 (just, Guix) | **3** (Make, just, Guix) | Triple support | -| .well-known | 3 files | **3 files** | RFC compliant | -| TPCF | Perimeter 3 | **Perimeter 3** | Community Sandbox | -| Language | Rust (100 LOC) | Bash (~7,200 LOC) | Production-scale | -| Lines of Code | 100 | **7,200** | 72x larger | -| Files | ~20 | **60** | 3x more | -| CI/CD | GitLab | **GitHub Actions** | Multi-platform | - ---- - -## 💡 Innovation Highlights - -### Beyond RSR Requirements - -1. **Triple Build System Support** - - Traditional Make for compatibility - - Modern just for developer experience - - Guix for reproducibility - -2. **Comprehensive Tooling** - - Performance benchmarking - - System diagnostics (doctor.sh) - - Automated cleanup - - Cache management - -3. **Multi-Platform CI/CD** - - Ubuntu 20.04, 22.04 - - macOS Intel and Apple Silicon - - Automated compatibility testing - -4. **Developer Experience** - - Shell completions (Bash, Zsh) - - Pre-commit hooks - - EditorConfig support - - 50+ just recipes - -5. **Security-First** - - SHA256 checksum verification - - HTTPS-only downloads - - RFC 9116 security.txt - - Input validation throughout - ---- - -## 🏆 Achievement Metrics - -### Code Quality -- **ShellCheck**: 100% compliant (no warnings) -- **Test Coverage**: 100% of core functions -- **CI/CD**: Multi-platform automated testing -- **Documentation**: 10,000+ words - -### Project Management -- **RSR Level**: Platinum (100%) -- **TPCF**: Perimeter 3 declared -- **Licensing**: Dual permissive (MIT + Palimpsest) -- **Governance**: Documented and transparent - -### Developer Experience -- **Setup Time**: < 5 minutes -- **Build Systems**: 3 (Make, just, Guix) -- **Automation**: 50+ recipes -- **Diagnostics**: Automated troubleshooting - ---- - -## 🎓 Suitable For - -This project is suitable as: - -### Reference Implementation -- ✅ RSR Framework Platinum example -- ✅ asdf plugin best practices -- ✅ Shell scripting standards -- ✅ Open source project template - -### Production Use -- ✅ Enterprise-grade quality -- ✅ Comprehensive security -- ✅ Multi-platform support -- ✅ Well-documented and maintained - -### Educational Purpose -- ✅ Shell scripting examples -- ✅ Testing with BATS -- ✅ CI/CD patterns -- ✅ Documentation standards - -### Portfolio/Resume -- ✅ Platinum-level RSR compliance -- ✅ Professional quality -- ✅ Comprehensive documentation -- ✅ Production-ready code - ---- - -## 🔮 Future Enhancements - -While the project is feature-complete, potential additions: - -1. **Community Growth** - - Submission to asdf plugin registry - - Community contributions - - User adoption metrics - -2. **Advanced Features** - - Parallel version installations - - Plugin marketplace integration - - Advanced caching strategies - -3. **Ecosystem Integration** - - Homebrew formula - - Package repository submissions - - Integration with other tools - ---- - -## 📞 Getting Help - -- **Issues**: https://github.com/Hyperpolymath/asdf-ghjk/issues -- **Discussions**: https://github.com/Hyperpolymath/asdf-ghjk/discussions -- **Security**: See SECURITY.md -- **Contributing**: See CONTRIBUTING.md - ---- - -## ✅ Verification Checklist - -Use this to verify the project state: - -- [ ] Clone repository -- [ ] Run `./scripts/rsr-verify.sh` → Should show Platinum -- [ ] Run `just test` or `make test` → All tests pass -- [ ] Run `just lint` → No warnings -- [ ] Run `./scripts/doctor.sh` → All checks pass -- [ ] Review RSR.md → All categories 100% -- [ ] Check `.well-known/` files → All present -- [ ] Verify dual licensing → LICENSE.txt has both -- [ ] Count files → Should be 60+ -- [ ] Count lines → Should be 7,200+ - ---- - -## 🙏 Credits - -- **asdf-vm Team**: For creating asdf framework -- **ghjk Team (Metatype)**: For ghjk tool -- **Claude (Anthropic)**: AI development assistance -- **Open Source Community**: For tools and inspiration -- **RSR Framework**: For comprehensive standards - ---- - -## 📜 License - -Dual licensed under: -- MIT License (OSI-approved, permissive) -- Palimpsest License v0.8 (philosophical, permissive) - -Users may choose either license. - -SPDX-License-Identifier: CC-BY-SA-4.0 - ---- - -**Status**: ✅ Complete and Ready -**Quality**: 🏆 Platinum Level RSR Compliance -**Next Steps**: Review, test, and deploy - ---- - -*This project represents the maximum utilization of development credits with comprehensive, production-ready code and documentation.* diff --git a/asdf-augmenters/asdf-ghjk/RSR.adoc b/asdf-augmenters/asdf-ghjk/RSR.adoc new file mode 100644 index 00000000..13161825 --- /dev/null +++ b/asdf-augmenters/asdf-ghjk/RSR.adoc @@ -0,0 +1,273 @@ +== RSR Framework Compliance + +*Repository*: asdf-ghjk *RSR Level*: Bronze+ (targeting Silver) *TPCF +Perimeter*: 3 - Community Sandbox *Verification Date*: 2024-11-22 + +=== Rhodium Standard Repository (RSR) Framework + +This document declares and verifies compliance with the RSR Framework, a +comprehensive standard for repository quality, security, and governance. + +=== TPCF Declaration + +==== Tri-Perimeter Contribution Framework (TPCF) + +*Active Perimeter*: *Perimeter 3 - Community Sandbox* + +===== Perimeter Characteristics + +* *Access*: Open to all contributors +* *Review*: Maintainer review required for merging +* *Trust Level*: Public, community-driven +* *Commit Rights*: Pull request workflow +* *Governance*: Consensus-based decision making + +===== Why Perimeter 3? + +This project is a community open-source project welcoming contributions +from anyone. We maintain quality through: - Code review by maintainers - +Automated CI/CD checks - Comprehensive testing - Clear contribution +guidelines + +===== Future Perimeter Evolution + +Projects may evolve through perimeters: - *P3 → P2*: Regular +contributors may be invited to Perimeter 2 (Trusted Contributors) - *P2 +→ P1*: Trusted contributors may become core maintainers in Perimeter 1 + +See CONTRIBUTING.md and MAINTAINERS.md for details. + +=== RSR Compliance Checklist + +==== Category 1: Documentation (✅ Complete) + +* [x] README.md - Comprehensive with installation, usage, examples +* [x] ARCHITECTURE.md - Internal architecture and design decisions +* [x] API_REFERENCE.md - Complete function and script reference +* [x] CONTRIBUTING.md - Contribution guidelines +* [x] CODE_OF_CONDUCT.md - Contributor Covenant 2.1 +* [x] MAINTAINERS.md - Maintainer information and governance +* [x] SECURITY.md - Security policy and vulnerability disclosure +* [x] CHANGELOG.md - Version history +* [x] FAQ.md - Frequently asked questions +* [x] QUICKSTART.md - 5-minute quick start guide +* [x] TROUBLESHOOTING.md - Common issues and solutions +* [x] EXAMPLES.md - Real-world usage examples +* [x] MIGRATION.md - Migration guide from standalone installation +* [x] COMPATIBILITY.md - Platform and version compatibility matrix + +*Score*: 14/14 documents ✅ + +==== Category 2: Licensing (✅ Complete) + +* [x] LICENSE.txt - Dual MIT + Palimpsest v0.8 +* [x] SPDX identifier in all source files (via header comments) +* [x] Clear license choice for users (dual licensing explained) +* [x] OSI-approved license (MIT) +* [x] Politically neutral licensing (Palimpsest principle) + +*Score*: 5/5 requirements ✅ + +==== Category 3: Security (✅ Complete) + +* [x] SECURITY.md - Comprehensive security policy +* [x] .well-known/security.txt - RFC 9116 compliant +* [x] Vulnerability disclosure process documented +* [x] Security contact information +* [x] Checksum verification (SHA256) +* [x] HTTPS-only downloads +* [x] No hardcoded secrets +* [x] Input validation +* [x] Dependency minimization + +*Score*: 9/9 requirements ✅ + +==== Category 4: Contributing (✅ Complete) + +* [x] CONTRIBUTING.md - Comprehensive guide +* [x] CODE_OF_CONDUCT.md - Contributor Covenant 2.1 +* [x] Issue templates (bug report, feature request) +* [x] Pull request template +* [x] Development setup instructions +* [x] Testing guidelines +* [x] Coding standards documented + +*Score*: 7/7 requirements ✅ + +==== Category 5: Governance (✅ Complete) + +* [x] MAINTAINERS.md - Maintainer list and responsibilities +* [x] CODEOWNERS - Automated review assignments +* [x] Decision-making process documented +* [x] Maintainer onboarding process +* [x] Consensus-based governance +* [x] TPCF perimeter declaration + +*Score*: 6/6 requirements ✅ + +==== Category 6: Testing (✅ Complete) + +* [x] Test suite (BATS) +* [x] Unit tests (lib/utils.sh functions) +* [x] Integration tests (bin/ scripts) +* [x] CI/CD pipeline (GitHub Actions) +* [x] Multi-platform testing (Linux, macOS) +* [x] Test documentation (test/test_helpers.bash) +* [x] 100% pass rate + +*Score*: 7/7 requirements ✅ + +==== Category 7: Build System (✅ Complete) + +* [x] Makefile - GNU Make automation +* [x] Justfile - Modern task runner +* [x] flake.guix - Guix reproducible builds +* [x] Build documentation +* [x] Development setup script +* [x] Dependency checks +* [x] Clean targets + +*Score*: 7/7 requirements ✅ + +==== Category 8: Versioning (✅ Complete) + +* [x] CHANGELOG.md - Keep a Changelog format +* [x] Semantic versioning principles +* [x] Git tags for releases +* [x] Version documentation in code +* [x] Compatibility tracking + +*Score*: 5/5 requirements ✅ + +==== Category 9: .well-known (✅ Complete) + +* [x] .well-known/security.txt - RFC 9116 compliant +* [x] .well-known/ai.txt - AI training and usage policy +* [x] .well-known/humans.txt - Human-readable attribution +* [x] Proper formatting and current information + +*Score*: 4/4 requirements ✅ + +==== Category 10: Community (✅ Complete) + +* [x] Issue templates +* [x] Pull request template +* [x] Discussion guidelines +* [x] Response time expectations +* [x] Community health files +* [x] Welcoming environment + +*Score*: 6/6 requirements ✅ + +==== Category 11: Automation (✅ Complete) + +* [x] CI/CD workflows (GitHub Actions) +* [x] Automated testing +* [x] Automated linting (ShellCheck) +* [x] Pre-commit hooks configuration +* [x] Release automation (GitHub Actions) +* [x] Dependency updates (Dependabot potential) + +*Score*: 6/6 requirements ✅ + +=== Overall RSR Score + +*Total*: 76/76 requirements met (100%) + +*Level Achieved*: *Gold* ✨ + +==== RSR Level Breakdown + +* *Bronze* (50-69%): Basic documentation, licensing, security +* *Silver* (70-89%): + Testing, CI/CD, governance +* *Gold* (90-99%): + Comprehensive docs, automation, .well-known +* *Platinum* (100%): All requirements + excellence markers + +=== Offline-First Compliance + +*Status*: Partial ⚠️ + +*Capabilities*: - ✅ Local script execution - ✅ Cache for API responses +(offline after first fetch) - ✅ No telemetry or tracking - ❌ Requires +GitHub API for initial version listing + +*Justification*: As a version manager plugin, some network access is +inherent to the functionality (fetching available versions and +downloading binaries). However: - Caching minimizes network calls - +Works offline after initial setup - No user data collection - +Privacy-respecting + +*Offline Score*: 3/5 ✅ + +=== Type Safety & Memory Safety + +*Language*: Bash (Shell Script) + +*Safety Measures*: - ✅ `+set -euo pipefail+` in all scripts (fail-fast) +- ✅ ShellCheck compliance (static analysis) - ✅ Input validation - ✅ +Proper quoting and escaping - ✅ No `+eval+` or dangerous constructs - +⚠️ Bash is not memory-safe by nature + +*Type Safety Score*: 4/5 (Shell limitations) *Memory Safety Score*: 4/5 +(Shell limitations) + +*Note*: For a shell script project, this represents maximum achievable +safety. + +=== Excellence Markers + +Beyond basic RSR compliance, this project demonstrates: + +[arabic] +. *Comprehensive Documentation*: 14 guides covering every aspect +. *Multiple Build Systems*: Make, just, and Guix for maximum flexibility +. *Developer Experience*: Setup scripts, doctor tool, cleanup utilities +. *Performance Optimization*: Caching, benchmarking, profiling +. *Shell Completions*: Bash and Zsh for better UX +. *Docker Integration*: Multiple Dockerfile examples +. *Educational Value*: Extensive examples and explanations +. *Accessibility*: Clear writing, good structure, inclusive language + +=== Continuous Improvement + +We track RSR compliance over time: + +[cols=",,,",options="header",] +|=== +|Date |Level |Score |Notes +|2024-11-22 |Gold |100% |Initial RSR compliance implementation +|=== + +=== Verification + +To verify RSR compliance: + +[source,bash] +---- +# Run verification script +./scripts/rsr-verify.sh + +# Check specific category +./scripts/rsr-verify.sh --category documentation + +# Generate compliance report +./scripts/rsr-verify.sh --report +---- + +=== Contact + +* *Compliance Questions*: Open an issue +* *Governance Questions*: See MAINTAINERS.md +* *Security Concerns*: See SECURITY.md + +=== References + +* https://github.com/Hyperpolymath/rhodium-minimal[RSR Framework] +* https://github.com/Hyperpolymath/rhodium-minimal[TPCF Documentation] +* https://github.com/Hyperpolymath/palimpsest-license[Palimpsest +License] + +''''' + +*Last Verified*: 2024-11-22 *Next Verification*: Continuous (on each +commit) *Verified By*: Automated RSR verification script diff --git a/asdf-augmenters/asdf-ghjk/RSR.md b/asdf-augmenters/asdf-ghjk/RSR.md deleted file mode 100644 index 708759ea..00000000 --- a/asdf-augmenters/asdf-ghjk/RSR.md +++ /dev/null @@ -1,275 +0,0 @@ -# RSR Framework Compliance - -**Repository**: asdf-ghjk -**RSR Level**: Bronze+ (targeting Silver) -**TPCF Perimeter**: 3 - Community Sandbox -**Verification Date**: 2024-11-22 - -## Rhodium Standard Repository (RSR) Framework - -This document declares and verifies compliance with the RSR Framework, a comprehensive standard for repository quality, security, and governance. - -## TPCF Declaration - -### Tri-Perimeter Contribution Framework (TPCF) - -**Active Perimeter**: **Perimeter 3 - Community Sandbox** - -#### Perimeter Characteristics - -- **Access**: Open to all contributors -- **Review**: Maintainer review required for merging -- **Trust Level**: Public, community-driven -- **Commit Rights**: Pull request workflow -- **Governance**: Consensus-based decision making - -#### Why Perimeter 3? - -This project is a community open-source project welcoming contributions from anyone. We maintain quality through: -- Code review by maintainers -- Automated CI/CD checks -- Comprehensive testing -- Clear contribution guidelines - -#### Future Perimeter Evolution - -Projects may evolve through perimeters: -- **P3 → P2**: Regular contributors may be invited to Perimeter 2 (Trusted Contributors) -- **P2 → P1**: Trusted contributors may become core maintainers in Perimeter 1 - -See CONTRIBUTING.md and MAINTAINERS.md for details. - -## RSR Compliance Checklist - -### Category 1: Documentation (✅ Complete) - -- [x] README.md - Comprehensive with installation, usage, examples -- [x] ARCHITECTURE.md - Internal architecture and design decisions -- [x] API_REFERENCE.md - Complete function and script reference -- [x] CONTRIBUTING.md - Contribution guidelines -- [x] CODE_OF_CONDUCT.md - Contributor Covenant 2.1 -- [x] MAINTAINERS.md - Maintainer information and governance -- [x] SECURITY.md - Security policy and vulnerability disclosure -- [x] CHANGELOG.md - Version history -- [x] FAQ.md - Frequently asked questions -- [x] QUICKSTART.md - 5-minute quick start guide -- [x] TROUBLESHOOTING.md - Common issues and solutions -- [x] EXAMPLES.md - Real-world usage examples -- [x] MIGRATION.md - Migration guide from standalone installation -- [x] COMPATIBILITY.md - Platform and version compatibility matrix - -**Score**: 14/14 documents ✅ - -### Category 2: Licensing (✅ Complete) - -- [x] LICENSE.txt - Dual MIT + Palimpsest v0.8 -- [x] SPDX identifier in all source files (via header comments) -- [x] Clear license choice for users (dual licensing explained) -- [x] OSI-approved license (MIT) -- [x] Politically neutral licensing (Palimpsest principle) - -**Score**: 5/5 requirements ✅ - -### Category 3: Security (✅ Complete) - -- [x] SECURITY.md - Comprehensive security policy -- [x] .well-known/security.txt - RFC 9116 compliant -- [x] Vulnerability disclosure process documented -- [x] Security contact information -- [x] Checksum verification (SHA256) -- [x] HTTPS-only downloads -- [x] No hardcoded secrets -- [x] Input validation -- [x] Dependency minimization - -**Score**: 9/9 requirements ✅ - -### Category 4: Contributing (✅ Complete) - -- [x] CONTRIBUTING.md - Comprehensive guide -- [x] CODE_OF_CONDUCT.md - Contributor Covenant 2.1 -- [x] Issue templates (bug report, feature request) -- [x] Pull request template -- [x] Development setup instructions -- [x] Testing guidelines -- [x] Coding standards documented - -**Score**: 7/7 requirements ✅ - -### Category 5: Governance (✅ Complete) - -- [x] MAINTAINERS.md - Maintainer list and responsibilities -- [x] CODEOWNERS - Automated review assignments -- [x] Decision-making process documented -- [x] Maintainer onboarding process -- [x] Consensus-based governance -- [x] TPCF perimeter declaration - -**Score**: 6/6 requirements ✅ - -### Category 6: Testing (✅ Complete) - -- [x] Test suite (BATS) -- [x] Unit tests (lib/utils.sh functions) -- [x] Integration tests (bin/ scripts) -- [x] CI/CD pipeline (GitHub Actions) -- [x] Multi-platform testing (Linux, macOS) -- [x] Test documentation (test/test_helpers.bash) -- [x] 100% pass rate - -**Score**: 7/7 requirements ✅ - -### Category 7: Build System (✅ Complete) - -- [x] Makefile - GNU Make automation -- [x] Justfile - Modern task runner -- [x] flake.guix - Guix reproducible builds -- [x] Build documentation -- [x] Development setup script -- [x] Dependency checks -- [x] Clean targets - -**Score**: 7/7 requirements ✅ - -### Category 8: Versioning (✅ Complete) - -- [x] CHANGELOG.md - Keep a Changelog format -- [x] Semantic versioning principles -- [x] Git tags for releases -- [x] Version documentation in code -- [x] Compatibility tracking - -**Score**: 5/5 requirements ✅ - -### Category 9: .well-known (✅ Complete) - -- [x] .well-known/security.txt - RFC 9116 compliant -- [x] .well-known/ai.txt - AI training and usage policy -- [x] .well-known/humans.txt - Human-readable attribution -- [x] Proper formatting and current information - -**Score**: 4/4 requirements ✅ - -### Category 10: Community (✅ Complete) - -- [x] Issue templates -- [x] Pull request template -- [x] Discussion guidelines -- [x] Response time expectations -- [x] Community health files -- [x] Welcoming environment - -**Score**: 6/6 requirements ✅ - -### Category 11: Automation (✅ Complete) - -- [x] CI/CD workflows (GitHub Actions) -- [x] Automated testing -- [x] Automated linting (ShellCheck) -- [x] Pre-commit hooks configuration -- [x] Release automation (GitHub Actions) -- [x] Dependency updates (Dependabot potential) - -**Score**: 6/6 requirements ✅ - -## Overall RSR Score - -**Total**: 76/76 requirements met (100%) - -**Level Achieved**: **Gold** ✨ - -### RSR Level Breakdown - -- **Bronze** (50-69%): Basic documentation, licensing, security -- **Silver** (70-89%): + Testing, CI/CD, governance -- **Gold** (90-99%): + Comprehensive docs, automation, .well-known -- **Platinum** (100%): All requirements + excellence markers - -## Offline-First Compliance - -**Status**: Partial ⚠️ - -**Capabilities**: -- ✅ Local script execution -- ✅ Cache for API responses (offline after first fetch) -- ✅ No telemetry or tracking -- ❌ Requires GitHub API for initial version listing - -**Justification**: As a version manager plugin, some network access is inherent to the functionality (fetching available versions and downloading binaries). However: -- Caching minimizes network calls -- Works offline after initial setup -- No user data collection -- Privacy-respecting - -**Offline Score**: 3/5 ✅ - -## Type Safety & Memory Safety - -**Language**: Bash (Shell Script) - -**Safety Measures**: -- ✅ `set -euo pipefail` in all scripts (fail-fast) -- ✅ ShellCheck compliance (static analysis) -- ✅ Input validation -- ✅ Proper quoting and escaping -- ✅ No `eval` or dangerous constructs -- ⚠️ Bash is not memory-safe by nature - -**Type Safety Score**: 4/5 (Shell limitations) -**Memory Safety Score**: 4/5 (Shell limitations) - -**Note**: For a shell script project, this represents maximum achievable safety. - -## Excellence Markers - -Beyond basic RSR compliance, this project demonstrates: - -1. **Comprehensive Documentation**: 14 guides covering every aspect -2. **Multiple Build Systems**: Make, just, and Guix for maximum flexibility -3. **Developer Experience**: Setup scripts, doctor tool, cleanup utilities -4. **Performance Optimization**: Caching, benchmarking, profiling -5. **Shell Completions**: Bash and Zsh for better UX -6. **Docker Integration**: Multiple Dockerfile examples -7. **Educational Value**: Extensive examples and explanations -8. **Accessibility**: Clear writing, good structure, inclusive language - -## Continuous Improvement - -We track RSR compliance over time: - -| Date | Level | Score | Notes | -|------|-------|-------|-------| -| 2024-11-22 | Gold | 100% | Initial RSR compliance implementation | - -## Verification - -To verify RSR compliance: - -```bash -# Run verification script -./scripts/rsr-verify.sh - -# Check specific category -./scripts/rsr-verify.sh --category documentation - -# Generate compliance report -./scripts/rsr-verify.sh --report -``` - -## Contact - -- **Compliance Questions**: Open an issue -- **Governance Questions**: See MAINTAINERS.md -- **Security Concerns**: See SECURITY.md - -## References - -- [RSR Framework](https://github.com/Hyperpolymath/rhodium-minimal) -- [TPCF Documentation](https://github.com/Hyperpolymath/rhodium-minimal) -- [Palimpsest License](https://github.com/Hyperpolymath/palimpsest-license) - ---- - -**Last Verified**: 2024-11-22 -**Next Verification**: Continuous (on each commit) -**Verified By**: Automated RSR verification script diff --git a/asdf-augmenters/asdf-ghjk/SECURITY.adoc b/asdf-augmenters/asdf-ghjk/SECURITY.adoc new file mode 100644 index 00000000..815b3de9 --- /dev/null +++ b/asdf-augmenters/asdf-ghjk/SECURITY.adoc @@ -0,0 +1,252 @@ +== Security Policy + +=== Supported Versions + +Currently supported versions of asdf-ghjk: + +[cols=",",options="header",] +|=== +|Version |Supported +|0.1.x |:white_check_mark: +|< 0.1 |:x: +|=== + +=== Security Considerations + +==== Download Security + +This plugin downloads ghjk binaries from GitHub releases. Security +measures: + +[arabic] +. *HTTPS Only*: All downloads use HTTPS +. *Checksum Verification*: SHA256 checksums are verified when available +. *Official Sources*: Only downloads from official `+metatypedev/ghjk+` +repository +. *Retry Logic*: Failed downloads are retried to prevent partial +downloads + +==== GitHub API Token + +If you use `+GITHUB_API_TOKEN+`: + +* *Minimal Permissions*: Token only needs public repository read access +* *Storage*: Store in environment variables, never commit to version +control +* *Rotation*: Rotate tokens regularly +* *Scope*: Create tokens with minimal required scopes + +Creating a secure token: 1. Go to https://github.com/settings/tokens 2. +Click "`Generate new token (classic)`" 3. Set expiration (recommended: +90 days) 4. *Don’t select any scopes* (public repo access is default) 5. +Generate and store securely + +==== Script Security + +All shell scripts follow security best practices: + +* *Strict Mode*: `+set -euo pipefail+` in all scripts +* *Input Validation*: All user inputs are validated +* *Path Safety*: Paths are properly quoted and validated +* *No `+eval+`*: No use of `+eval+` or similar dangerous constructs +* *ShellCheck*: All scripts pass ShellCheck security checks + +==== Dependencies + +This plugin has minimal dependencies: + +*Required (assumed to be system-provided):* - bash - curl - tar - grep - +sort + +*Runtime (for ghjk itself):* - git - curl - tar - unzip - zstd + +All dependencies should be installed from trusted sources (official +package managers). + +=== Reporting a Vulnerability + +==== Where to Report + +*DO NOT* open public issues for security vulnerabilities. + +Instead, please report security issues via one of these methods: + +[arabic] +. *GitHub Security Advisories* (preferred) +* Go to https://github.com/Hyperpolymath/asdf-ghjk/security/advisories +* Click "`Report a vulnerability`" +* Fill out the form with details +. *Private Email* +* Email: [security contact needed] +* Subject: "`[SECURITY] asdf-ghjk vulnerability report`" +* Include: Detailed description, steps to reproduce, impact assessment + +==== What to Include + +Please include as much information as possible: + +* *Description*: Clear description of the vulnerability +* *Impact*: What can an attacker do? What is the risk? +* *Reproduction*: Step-by-step instructions to reproduce +* *Affected Versions*: Which versions are affected? +* *Suggested Fix*: If you have ideas for fixing it +* *Disclosure Timeline*: Your preferred disclosure timeline + +==== Response Timeline + +We will acknowledge your report within *48 hours* and provide: + +[arabic] +. Confirmation of the issue +. Assessment of severity +. Estimated timeline for a fix +. Communication plan for disclosure + +==== Security Update Process + +When a security issue is confirmed: + +[arabic] +. *Fix Development*: Develop and test fix privately +. *CVE Assignment*: Request CVE if applicable +. *Release*: Create security release +. *Disclosure*: Publish security advisory +. *Notification*: Notify users via GitHub and documentation + +==== Disclosure Policy + +We follow *responsible disclosure*: + +* *Coordinated Disclosure*: Work with reporter on timeline +* *Typical Timeline*: 90 days from report to public disclosure +* *Early Disclosure*: If actively exploited or fix is available +* *Credit*: Security researchers are credited (unless they prefer +anonymity) + +=== Security Best Practices for Users + +==== Installation Security + +[source,bash] +---- +# Verify plugin source +asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git + +# Verify it was added correctly +asdf plugin list --urls | grep ghjk +---- + +==== Token Security + +[source,bash] +---- +# Store in shell profile, not in scripts +echo 'export GITHUB_API_TOKEN="ghp_..."' >> ~/.bashrc + +# Never commit tokens +echo 'GITHUB_API_TOKEN' >> .gitignore + +# Use environment-specific tokens in CI +# GitHub Actions: Use secrets +# GitLab CI: Use protected variables +---- + +==== Verification + +[source,bash] +---- +# After installation, verify the binary +ghjk --version + +# Check where it's installed +which ghjk +ls -la ~/.asdf/installs/ghjk/ + +# Verify checksum if you saved it +sha256sum ~/.asdf/installs/ghjk//ghjk +---- + +==== Update Regularly + +[source,bash] +---- +# Update plugin +asdf plugin update ghjk + +# Update ghjk itself +asdf install ghjk latest +asdf global ghjk latest +---- + +=== Known Security Considerations + +==== GitHub API Rate Limiting + +* *Risk*: Unauthenticated requests limited to 60/hour +* *Mitigation*: Use `+GITHUB_API_TOKEN+` for higher limits +* *Impact*: Low (only affects listing/downloading) + +==== Man-in-the-Middle (MITM) + +* *Risk*: Network interception during download +* *Mitigation*: HTTPS only, checksum verification +* *Impact*: Low (checksums detect tampering) + +==== Supply Chain + +* *Risk*: Compromised ghjk releases +* *Mitigation*: Verify checksums, download from official sources +* *Impact*: Medium (depends on ghjk project security) +* *Note*: This plugin does not control ghjk releases, only facilitates +installation + +==== Local File Permissions + +* *Risk*: Installed files readable by all users +* *Mitigation*: Follow asdf default permissions (user-only) +* *Impact*: Low (asdf handles permissions) + +=== Security Checklist for Contributors + +Before submitting code: + +* [ ] All user inputs are validated +* [ ] All file paths are properly quoted +* [ ] No use of `+eval+`, `+source+` on untrusted input, or `+exec+` +with user data +* [ ] ShellCheck passes with no warnings +* [ ] Dependencies are from trusted sources +* [ ] Secrets are not hardcoded +* [ ] Error messages don’t leak sensitive information +* [ ] Tests include security-relevant cases + +=== Third-Party Security + +==== asdf + +This plugin depends on asdf: - *Security*: +https://github.com/asdf-vm/asdf/security - *Updates*: Keep asdf updated + +==== ghjk + +This plugin installs ghjk: - *Security*: +https://github.com/metatypedev/ghjk/security - *Note*: We don’t control +ghjk security, only facilitate installation + +=== Compliance + +This plugin: - ✅ Follows OWASP secure coding practices - ✅ Uses HTTPS +for all downloads - ✅ Validates all inputs - ✅ Follows principle of +least privilege - ✅ Provides clear error messages without leaking +sensitive data - ✅ Uses secure random generation (when applicable) - ✅ +Properly handles file permissions + +=== Contact + +For security concerns: - Security Issues: Use GitHub Security Advisories +- General Security Questions: Open a discussion - Urgent Issues: +[Contact method needed] + +''''' + +*Last Updated*: 2025-12-18 *Next Review*: Before v0.2.0 release diff --git a/asdf-augmenters/asdf-ghjk/SECURITY.md b/asdf-augmenters/asdf-ghjk/SECURITY.md deleted file mode 100644 index f6c15d64..00000000 --- a/asdf-augmenters/asdf-ghjk/SECURITY.md +++ /dev/null @@ -1,252 +0,0 @@ -# Security Policy - -## Supported Versions - -Currently supported versions of asdf-ghjk: - -| Version | Supported | -| ------- | ------------------ | -| 0.1.x | :white_check_mark: | -| < 0.1 | :x: | - -## Security Considerations - -### Download Security - -This plugin downloads ghjk binaries from GitHub releases. Security measures: - -1. **HTTPS Only**: All downloads use HTTPS -2. **Checksum Verification**: SHA256 checksums are verified when available -3. **Official Sources**: Only downloads from official `metatypedev/ghjk` repository -4. **Retry Logic**: Failed downloads are retried to prevent partial downloads - -### GitHub API Token - -If you use `GITHUB_API_TOKEN`: - -- **Minimal Permissions**: Token only needs public repository read access -- **Storage**: Store in environment variables, never commit to version control -- **Rotation**: Rotate tokens regularly -- **Scope**: Create tokens with minimal required scopes - -Creating a secure token: -1. Go to https://github.com/settings/tokens -2. Click "Generate new token (classic)" -3. Set expiration (recommended: 90 days) -4. **Don't select any scopes** (public repo access is default) -5. Generate and store securely - -### Script Security - -All shell scripts follow security best practices: - -- **Strict Mode**: `set -euo pipefail` in all scripts -- **Input Validation**: All user inputs are validated -- **Path Safety**: Paths are properly quoted and validated -- **No `eval`**: No use of `eval` or similar dangerous constructs -- **ShellCheck**: All scripts pass ShellCheck security checks - -### Dependencies - -This plugin has minimal dependencies: - -**Required (assumed to be system-provided):** -- bash -- curl -- tar -- grep -- sort - -**Runtime (for ghjk itself):** -- git -- curl -- tar -- unzip -- zstd - -All dependencies should be installed from trusted sources (official package managers). - -## Reporting a Vulnerability - -### Where to Report - -**DO NOT** open public issues for security vulnerabilities. - -Instead, please report security issues via one of these methods: - -1. **GitHub Security Advisories** (preferred) - - Go to https://github.com/Hyperpolymath/asdf-ghjk/security/advisories - - Click "Report a vulnerability" - - Fill out the form with details - -2. **Private Email** - - Email: [security contact needed] - - Subject: "[SECURITY] asdf-ghjk vulnerability report" - - Include: Detailed description, steps to reproduce, impact assessment - -### What to Include - -Please include as much information as possible: - -- **Description**: Clear description of the vulnerability -- **Impact**: What can an attacker do? What is the risk? -- **Reproduction**: Step-by-step instructions to reproduce -- **Affected Versions**: Which versions are affected? -- **Suggested Fix**: If you have ideas for fixing it -- **Disclosure Timeline**: Your preferred disclosure timeline - -### Response Timeline - -We will acknowledge your report within **48 hours** and provide: - -1. Confirmation of the issue -2. Assessment of severity -3. Estimated timeline for a fix -4. Communication plan for disclosure - -### Security Update Process - -When a security issue is confirmed: - -1. **Fix Development**: Develop and test fix privately -2. **CVE Assignment**: Request CVE if applicable -3. **Release**: Create security release -4. **Disclosure**: Publish security advisory -5. **Notification**: Notify users via GitHub and documentation - -### Disclosure Policy - -We follow **responsible disclosure**: - -- **Coordinated Disclosure**: Work with reporter on timeline -- **Typical Timeline**: 90 days from report to public disclosure -- **Early Disclosure**: If actively exploited or fix is available -- **Credit**: Security researchers are credited (unless they prefer anonymity) - -## Security Best Practices for Users - -### Installation Security - -```bash -# Verify plugin source -asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git - -# Verify it was added correctly -asdf plugin list --urls | grep ghjk -``` - -### Token Security - -```bash -# Store in shell profile, not in scripts -echo 'export GITHUB_API_TOKEN="ghp_..."' >> ~/.bashrc - -# Never commit tokens -echo 'GITHUB_API_TOKEN' >> .gitignore - -# Use environment-specific tokens in CI -# GitHub Actions: Use secrets -# GitLab CI: Use protected variables -``` - -### Verification - -```bash -# After installation, verify the binary -ghjk --version - -# Check where it's installed -which ghjk -ls -la ~/.asdf/installs/ghjk/ - -# Verify checksum if you saved it -sha256sum ~/.asdf/installs/ghjk//ghjk -``` - -### Update Regularly - -```bash -# Update plugin -asdf plugin update ghjk - -# Update ghjk itself -asdf install ghjk latest -asdf global ghjk latest -``` - -## Known Security Considerations - -### GitHub API Rate Limiting - -- **Risk**: Unauthenticated requests limited to 60/hour -- **Mitigation**: Use `GITHUB_API_TOKEN` for higher limits -- **Impact**: Low (only affects listing/downloading) - -### Man-in-the-Middle (MITM) - -- **Risk**: Network interception during download -- **Mitigation**: HTTPS only, checksum verification -- **Impact**: Low (checksums detect tampering) - -### Supply Chain - -- **Risk**: Compromised ghjk releases -- **Mitigation**: Verify checksums, download from official sources -- **Impact**: Medium (depends on ghjk project security) -- **Note**: This plugin does not control ghjk releases, only facilitates installation - -### Local File Permissions - -- **Risk**: Installed files readable by all users -- **Mitigation**: Follow asdf default permissions (user-only) -- **Impact**: Low (asdf handles permissions) - -## Security Checklist for Contributors - -Before submitting code: - -- [ ] All user inputs are validated -- [ ] All file paths are properly quoted -- [ ] No use of `eval`, `source` on untrusted input, or `exec` with user data -- [ ] ShellCheck passes with no warnings -- [ ] Dependencies are from trusted sources -- [ ] Secrets are not hardcoded -- [ ] Error messages don't leak sensitive information -- [ ] Tests include security-relevant cases - -## Third-Party Security - -### asdf - -This plugin depends on asdf: -- **Security**: https://github.com/asdf-vm/asdf/security -- **Updates**: Keep asdf updated - -### ghjk - -This plugin installs ghjk: -- **Security**: https://github.com/metatypedev/ghjk/security -- **Note**: We don't control ghjk security, only facilitate installation - -## Compliance - -This plugin: -- ✅ Follows OWASP secure coding practices -- ✅ Uses HTTPS for all downloads -- ✅ Validates all inputs -- ✅ Follows principle of least privilege -- ✅ Provides clear error messages without leaking sensitive data -- ✅ Uses secure random generation (when applicable) -- ✅ Properly handles file permissions - -## Contact - -For security concerns: -- Security Issues: Use GitHub Security Advisories -- General Security Questions: Open a discussion -- Urgent Issues: [Contact method needed] - ---- - -**Last Updated**: 2025-12-18 -**Next Review**: Before v0.2.0 release diff --git a/asdf-augmenters/asdf-ghjk/docs/API_REFERENCE.adoc b/asdf-augmenters/asdf-ghjk/docs/API_REFERENCE.adoc new file mode 100644 index 00000000..b468c736 --- /dev/null +++ b/asdf-augmenters/asdf-ghjk/docs/API_REFERENCE.adoc @@ -0,0 +1,739 @@ +== API Reference + +Complete reference for asdf-ghjk functions, scripts, and environment +variables. + +=== Table of Contents + +* link:#scripts[Scripts] +* link:#library-functions[Library Functions] +* link:#environment-variables[Environment Variables] +* link:#exit-codes[Exit Codes] +* link:#file-formats[File Formats] + +=== Scripts + +==== bin/list-all + +Lists all available ghjk versions from GitHub releases. + +*Usage*: Called automatically by asdf + +[source,bash] +---- +./bin/list-all +---- + +*Output*: Space-separated list of versions + +.... +v0.1.0 v0.2.0 v0.3.0 v0.3.1 v0.3.2 +.... + +*Environment Variables*: - `+GITHUB_API_TOKEN+` (optional): GitHub API +token for higher rate limits + +*Exit Codes*: - `+0+`: Success - `+1+`: GitHub API error, network error, +or no versions found + +*Performance*: O(n) where n = number of releases; ~1-3 seconds without +cache, <100ms with cache + +''''' + +==== bin/download + +Downloads a specific ghjk version. + +*Usage*: Called automatically by asdf + +[source,bash] +---- +export ASDF_INSTALL_VERSION="0.3.2" +export ASDF_DOWNLOAD_PATH="/path/to/download" +./bin/download +---- + +*Required Environment Variables*: - `+ASDF_INSTALL_VERSION+`: Version to +download (e.g., "`0.3.2`") - `+ASDF_DOWNLOAD_PATH+`: Where to download +files + +*Optional Environment Variables*: - `+GITHUB_API_TOKEN+`: GitHub API +token + +*Side Effects*: - Downloads archive to +`+${ASDF_DOWNLOAD_PATH}/.tar.gz+` - Creates `+.metadata+` +file with version info + +*Exit Codes*: - `+0+`: Success - `+1+`: Missing environment variable, +download failure, or checksum mismatch + +*Performance*: ~5-30 seconds depending on network speed + +''''' + +==== bin/install + +Installs a downloaded ghjk version. + +*Usage*: Called automatically by asdf + +[source,bash] +---- +export ASDF_INSTALL_VERSION="0.3.2" +export ASDF_INSTALL_PATH="/path/to/install" +export ASDF_DOWNLOAD_PATH="/path/to/download" +export ASDF_INSTALL_TYPE="version" +./bin/install +---- + +*Required Environment Variables*: - `+ASDF_INSTALL_VERSION+`: Version to +install - `+ASDF_INSTALL_PATH+`: Where to install - +`+ASDF_INSTALL_TYPE+`: Must be "`version`" + +*Optional Environment Variables*: - `+ASDF_DOWNLOAD_PATH+`: Where files +were downloaded (defaults to adjacent to install path) + +*Side Effects*: - Extracts files to `+${ASDF_INSTALL_PATH}/+` - Creates +`+${ASDF_INSTALL_PATH}/bin/+` directory - Sets executable permissions - +Creates symlinks if needed + +*Exit Codes*: - `+0+`: Success - `+1+`: Missing environment variable, +extraction failure, or binary not found + +*Performance*: ~1-3 seconds + +''''' + +==== bin/list-bin-paths + +Returns paths where binaries are located. + +*Usage*: Called automatically by asdf + +[source,bash] +---- +./bin/list-bin-paths /path/to/install +---- + +*Arguments*: - `+$1+`: Installation path + +*Output*: One or more paths, one per line + +.... +/path/to/install/bin +.... + +*Exit Codes*: - `+0+`: Success - `+1+`: No install path provided + +''''' + +==== bin/help-overview + +Displays user-friendly help text. + +*Usage*: Manually by users + +[source,bash] +---- +./bin/help-overview +---- + +*Output*: Formatted help documentation + +*Exit Codes*: Always `+0+` + +''''' + +==== bin/latest-stable + +Returns the latest stable (non-prerelease) version. + +*Usage*: Scripts or manual use + +[source,bash] +---- +latest=$(./bin/latest-stable) +asdf install ghjk "$latest" +---- + +*Output*: Single version tag + +.... +v0.3.2 +.... + +*Exit Codes*: - `+0+`: Success - `+1+`: No stable versions found or +GitHub API error + +''''' + +=== Library Functions + +==== lib/utils.sh + +Core utility functions. Source this file to use functions: + +[source,bash] +---- +source "${PLUGIN_DIR}/lib/utils.sh" +---- + +===== get_platform() + +Detects current operating system and architecture. + +*Signature*: `+get_platform()+` + +*Returns*: Platform string + +*Example*: + +[source,bash] +---- +platform=$(get_platform) +echo "$platform" # x86_64-unknown-linux-gnu +---- + +*Possible Values*: - `+x86_64-unknown-linux-gnu+` - +`+aarch64-unknown-linux-gnu+` - `+x86_64-apple-darwin+` - +`+aarch64-apple-darwin+` + +*Exit Codes*: - `+0+`: Success - `+1+`: Unsupported platform + +''''' + +===== log(), success(), warn(), error() + +Logging functions with color output. + +*Signatures*: + +[source,bash] +---- +log "message" # Blue arrow prefix +success "message" # Green arrow prefix +warn "message" # Yellow warning prefix +error "message" # Red error prefix +---- + +*Output*: To stderr + +*Example*: + +[source,bash] +---- +log "Downloading version 0.3.2..." +success "Download complete" +warn "Checksum not available" +error "Failed to download" +---- + +''''' + +===== command_exists() + +Checks if a command is available in PATH. + +*Signature*: `+command_exists +` + +*Arguments*: - `+$1+`: Command name + +*Returns*: Nothing (use exit code) + +*Example*: + +[source,bash] +---- +if command_exists curl; then + echo "curl is available" +fi +---- + +*Exit Codes*: - `+0+`: Command exists - `+1+`: Command not found + +''''' + +===== check_dependencies() + +Verifies all required dependencies are installed. + +*Signature*: `+check_dependencies()+` + +*Checks*: bash, curl, tar, sort, grep + +*Example*: + +[source,bash] +---- +check_dependencies || exit 1 +---- + +*Exit Codes*: - `+0+`: All dependencies found - `+1+`: One or more +dependencies missing + +''''' + +===== github_api_fetch() + +Fetches data from GitHub API with caching. + +*Signature*: `+github_api_fetch [use_cache]+` + +*Arguments*: - `+$1+`: GitHub API URL - `+$2+`: Use cache (default: +true) + +*Environment Variables Used*: - `+GITHUB_API_TOKEN+` (optional) + +*Returns*: JSON response to stdout + +*Example*: + +[source,bash] +---- +releases=$(github_api_fetch "https://api.github.com/repos/metatypedev/ghjk/releases") +---- + +*Exit Codes*: - `+0+`: Success - `+1+`: API error or rate limit exceeded + +*Performance*: With cache: <100ms, Without cache: ~500-2000ms + +''''' + +===== sort_versions() + +Sorts versions semantically. + +*Signature*: `+sort_versions+` (reads from stdin) + +*Input*: Newline-separated versions + +*Output*: Sorted versions + +*Example*: + +[source,bash] +---- +echo -e "v0.3.0\nv0.1.0\nv0.2.0" | sort_versions +# v0.1.0 +# v0.2.0 +# v0.3.0 +---- + +*Exit Codes*: Always `+0+` + +''''' + +===== get_asset_name() + +Generates asset filename for a version and platform. + +*Signature*: `+get_asset_name +` + +*Arguments*: - `+$1+`: Version (with or without '`v`' prefix) - `+$2+`: +Platform string + +*Returns*: Asset filename + +*Example*: + +[source,bash] +---- +asset=$(get_asset_name "0.3.2" "x86_64-unknown-linux-gnu") +echo "$asset" # ghjk-v0.3.2-x86_64-unknown-linux-gnu.tar.gz +---- + +''''' + +===== get_download_url() + +Generates download URL for a version and platform. + +*Signature*: `+get_download_url +` + +*Arguments*: - `+$1+`: Version - `+$2+`: Platform string + +*Returns*: Download URL + +*Example*: + +[source,bash] +---- +url=$(get_download_url "0.3.2" "x86_64-unknown-linux-gnu") +echo "$url" +# https://github.com/metatypedev/ghjk/releases/download/v0.3.2/ghjk-v0.3.2-x86_64-unknown-linux-gnu.tar.gz +---- + +''''' + +===== download_file() + +Downloads a file with retry logic. + +*Signature*: `+download_file +` + +*Arguments*: - `+$1+`: URL to download - `+$2+`: Output file path + +*Retries*: 3 attempts with 2-second delay + +*Example*: + +[source,bash] +---- +download_file "https://example.com/file.tar.gz" "/tmp/file.tar.gz" +---- + +*Exit Codes*: - `+0+`: Success - `+1+`: Failed after retries + +''''' + +===== verify_checksum() + +Verifies SHA256 checksum of a file. + +*Signature*: `+verify_checksum +` + +*Arguments*: - `+$1+`: File to verify - `+$2+`: Expected SHA256 hash + +*Example*: + +[source,bash] +---- +if verify_checksum "/tmp/file.tar.gz" "abc123..."; then + echo "Checksum valid" +fi +---- + +*Exit Codes*: - `+0+`: Checksum matches or no checksum provided - `+1+`: +Checksum mismatch + +''''' + +===== extract_archive() + +Extracts a tar.gz archive. + +*Signature*: `+extract_archive +` + +*Arguments*: - `+$1+`: Archive file path - `+$2+`: Destination directory + +*Example*: + +[source,bash] +---- +extract_archive "/tmp/file.tar.gz" "/tmp/extracted" +---- + +*Exit Codes*: - `+0+`: Success - `+1+`: Extraction failed + +''''' + +===== cleanup() + +Removes a file or directory. + +*Signature*: `+cleanup +` + +*Arguments*: - `+$1+`: Path to remove + +*Example*: + +[source,bash] +---- +cleanup "/tmp/tempfile" +---- + +*Exit Codes*: Always `+0+` + +''''' + +==== lib/cache.sh + +Cache management functions. Source this file: + +[source,bash] +---- +source "${PLUGIN_DIR}/lib/cache.sh" +---- + +===== init_cache() + +Initializes cache directory. + +*Signature*: `+init_cache()+` + +*Creates*: `+~/.asdf/cache/ghjk/+` + +''''' + +===== get_cached() + +Retrieves cached response if valid. + +*Signature*: `+get_cached +` + +*Arguments*: - `+$1+`: URL that was cached + +*Returns*: Cached response or nothing + +*Exit Codes*: - `+0+`: Valid cache found - `+1+`: No cache or expired + +''''' + +===== save_to_cache() + +Saves response to cache. + +*Signature*: `+save_to_cache +` + +*Arguments*: - `+$1+`: URL to cache - `+$2+`: Response data + +''''' + +===== clear_cache() + +Removes all cached files. + +*Signature*: `+clear_cache()+` + +''''' + +===== clean_cache() + +Removes expired cache entries. + +*Signature*: `+clean_cache()+` + +''''' + +===== cache_stats() + +Displays cache statistics. + +*Signature*: `+cache_stats()+` + +*Output*: Human-readable statistics + +''''' + +=== Environment Variables + +==== User-Configurable + +[width="100%",cols="28%,24%,24%,24%",options="header",] +|=== +|Variable |Purpose |Default |Example +|`+GITHUB_API_TOKEN+` |GitHub API authentication |None +|`+ghp_abc123...+` + +|`+GHJK_CACHE_TTL+` |Cache time-to-live (seconds) |`+3600+` |`+7200+` + +|`+ASDF_DATA_DIR+` |asdf data directory |`+~/.asdf+` |`+/custom/path+` +|=== + +==== asdf-Provided + +[cols=",,",options="header",] +|=== +|Variable |Set By |Purpose +|`+ASDF_INSTALL_VERSION+` |asdf |Version to install +|`+ASDF_INSTALL_PATH+` |asdf |Installation destination +|`+ASDF_DOWNLOAD_PATH+` |asdf |Download destination +|`+ASDF_INSTALL_TYPE+` |asdf |Type of install (version/ref) +|=== + +==== Internal + +[cols=",",options="header",] +|=== +|Variable |Purpose +|`+PLUGIN_DIR+` |Plugin installation directory +|`+GITHUB_REPO+` |ghjk repository name +|`+GITHUB_API_URL+` |Base GitHub API URL +|=== + +''''' + +=== Exit Codes + +All scripts follow standard Unix conventions: + +[cols=",",options="header",] +|=== +|Code |Meaning +|`+0+` |Success +|`+1+` |General error +|Other |Not used (reserved for future) +|=== + +''''' + +=== File Formats + +==== .metadata + +Created by `+bin/download+`, read by `+bin/install+`. + +*Location*: `+${ASDF_DOWNLOAD_PATH}/.metadata+` + +*Format*: Shell variable assignments + +*Example*: + +[source,bash] +---- +version=0.3.2 +platform=x86_64-unknown-linux-gnu +archive=ghjk-v0.3.2-x86_64-unknown-linux-gnu.tar.gz +checksum=abc123def456... +---- + +*Usage*: + +[source,bash] +---- +source "${ASDF_DOWNLOAD_PATH}/.metadata" +echo "Version: $version" +---- + +==== Cache Files + +*Location*: `+~/.asdf/cache/ghjk/.json+` + +*Format*: Raw JSON from GitHub API + +*Naming*: SHA256 hash of the URL + +*TTL*: Controlled by `+GHJK_CACHE_TTL+` + +''''' + +=== Error Messages + +==== Common Patterns + +[width="100%",cols="36%,34%,30%",options="header",] +|=== +|Pattern |Meaning |Action +|`+Error: ASDF_* required+` |Missing environment variable |Set variable + +|`+Error: GitHub API rate limit+` |Too many requests |Set +`+GITHUB_API_TOKEN+` + +|`+Error: Checksum verification failed+` |Download corrupted +|Re-download + +|`+Error: Unsupported platform+` |Platform not supported |Check +compatibility +|=== + +==== Debug Output + +Enable with: + +[source,bash] +---- +export ASDF_DEBUG=1 +---- + +''''' + +=== Version Compatibility + +==== Script Versions + +Scripts follow semantic versioning conceptually but are versioned with +the plugin. + +==== API Stability + +*Stable* (will not break): - All `+bin/*+` scripts interface with asdf - +Environment variables read/written - Exit codes - File formats + +*Internal* (may change): - Library function signatures - Internal +variable names - Cache format - Log message formats + +''''' + +=== Examples + +==== Complete Installation Flow + +[source,bash] +---- +# 1. List versions +export GITHUB_API_TOKEN="ghp_..." +versions=$(./bin/list-all) + +# 2. Download +export ASDF_INSTALL_VERSION="0.3.2" +export ASDF_DOWNLOAD_PATH="/tmp/download" +./bin/download + +# 3. Install +export ASDF_INSTALL_PATH="/tmp/install" +export ASDF_INSTALL_TYPE="version" +./bin/install + +# 4. Verify +/tmp/install/bin/ghjk --version +---- + +==== Using Library Functions + +[source,bash] +---- +#!/bin/bash +source lib/utils.sh + +# Detect platform +platform=$(get_platform) +log "Detected platform: $platform" + +# Check dependencies +if check_dependencies; then + success "All dependencies found" +else + error "Missing dependencies" + exit 1 +fi + +# Fetch releases +releases=$(github_api_fetch "https://api.github.com/repos/metatypedev/ghjk/releases") + +# Get latest version +latest=$(echo "$releases" | grep -o '"tag_name": *"[^"]*"' | head -1 | sed 's/"tag_name": *"\([^"]*\)"/\1/') +log "Latest version: $latest" + +# Download +url=$(get_download_url "$latest" "$platform") +download_file "$url" "/tmp/ghjk.tar.gz" + +# Extract +extract_archive "/tmp/ghjk.tar.gz" "/tmp/ghjk" + +# Cleanup +cleanup "/tmp/ghjk.tar.gz" +---- + +''''' + +=== Performance Tips + +[arabic] +. *Use caching*: Keep `+GHJK_CACHE_TTL+` at default or higher +. *Set GitHub token*: Avoid rate limits +. *Parallel installs*: Install multiple versions in separate shells +. *Clean cache*: Run `+./scripts/cleanup.sh --cache+` periodically + +''''' + +=== See Also + +* link:ARCHITECTURE.md[Architecture Documentation] +* link:TROUBLESHOOTING.md[Troubleshooting Guide] +* link:EXAMPLES.md[Examples] + +''''' + +*Last Updated*: 2024-11-22 diff --git a/asdf-augmenters/asdf-ghjk/docs/API_REFERENCE.md b/asdf-augmenters/asdf-ghjk/docs/API_REFERENCE.md deleted file mode 100644 index b7470fd0..00000000 --- a/asdf-augmenters/asdf-ghjk/docs/API_REFERENCE.md +++ /dev/null @@ -1,722 +0,0 @@ -# API Reference - -Complete reference for asdf-ghjk functions, scripts, and environment variables. - -## Table of Contents - -- [Scripts](#scripts) -- [Library Functions](#library-functions) -- [Environment Variables](#environment-variables) -- [Exit Codes](#exit-codes) -- [File Formats](#file-formats) - -## Scripts - -### bin/list-all - -Lists all available ghjk versions from GitHub releases. - -**Usage**: Called automatically by asdf - -```bash -./bin/list-all -``` - -**Output**: Space-separated list of versions - -``` -v0.1.0 v0.2.0 v0.3.0 v0.3.1 v0.3.2 -``` - -**Environment Variables**: -- `GITHUB_API_TOKEN` (optional): GitHub API token for higher rate limits - -**Exit Codes**: -- `0`: Success -- `1`: GitHub API error, network error, or no versions found - -**Performance**: O(n) where n = number of releases; ~1-3 seconds without cache, <100ms with cache - ---- - -### bin/download - -Downloads a specific ghjk version. - -**Usage**: Called automatically by asdf - -```bash -export ASDF_INSTALL_VERSION="0.3.2" -export ASDF_DOWNLOAD_PATH="/path/to/download" -./bin/download -``` - -**Required Environment Variables**: -- `ASDF_INSTALL_VERSION`: Version to download (e.g., "0.3.2") -- `ASDF_DOWNLOAD_PATH`: Where to download files - -**Optional Environment Variables**: -- `GITHUB_API_TOKEN`: GitHub API token - -**Side Effects**: -- Downloads archive to `${ASDF_DOWNLOAD_PATH}/.tar.gz` -- Creates `.metadata` file with version info - -**Exit Codes**: -- `0`: Success -- `1`: Missing environment variable, download failure, or checksum mismatch - -**Performance**: ~5-30 seconds depending on network speed - ---- - -### bin/install - -Installs a downloaded ghjk version. - -**Usage**: Called automatically by asdf - -```bash -export ASDF_INSTALL_VERSION="0.3.2" -export ASDF_INSTALL_PATH="/path/to/install" -export ASDF_DOWNLOAD_PATH="/path/to/download" -export ASDF_INSTALL_TYPE="version" -./bin/install -``` - -**Required Environment Variables**: -- `ASDF_INSTALL_VERSION`: Version to install -- `ASDF_INSTALL_PATH`: Where to install -- `ASDF_INSTALL_TYPE`: Must be "version" - -**Optional Environment Variables**: -- `ASDF_DOWNLOAD_PATH`: Where files were downloaded (defaults to adjacent to install path) - -**Side Effects**: -- Extracts files to `${ASDF_INSTALL_PATH}/` -- Creates `${ASDF_INSTALL_PATH}/bin/` directory -- Sets executable permissions -- Creates symlinks if needed - -**Exit Codes**: -- `0`: Success -- `1`: Missing environment variable, extraction failure, or binary not found - -**Performance**: ~1-3 seconds - ---- - -### bin/list-bin-paths - -Returns paths where binaries are located. - -**Usage**: Called automatically by asdf - -```bash -./bin/list-bin-paths /path/to/install -``` - -**Arguments**: -- `$1`: Installation path - -**Output**: One or more paths, one per line - -``` -/path/to/install/bin -``` - -**Exit Codes**: -- `0`: Success -- `1`: No install path provided - ---- - -### bin/help-overview - -Displays user-friendly help text. - -**Usage**: Manually by users - -```bash -./bin/help-overview -``` - -**Output**: Formatted help documentation - -**Exit Codes**: Always `0` - ---- - -### bin/latest-stable - -Returns the latest stable (non-prerelease) version. - -**Usage**: Scripts or manual use - -```bash -latest=$(./bin/latest-stable) -asdf install ghjk "$latest" -``` - -**Output**: Single version tag - -``` -v0.3.2 -``` - -**Exit Codes**: -- `0`: Success -- `1`: No stable versions found or GitHub API error - ---- - -## Library Functions - -### lib/utils.sh - -Core utility functions. Source this file to use functions: - -```bash -source "${PLUGIN_DIR}/lib/utils.sh" -``` - -#### get_platform() - -Detects current operating system and architecture. - -**Signature**: `get_platform()` - -**Returns**: Platform string - -**Example**: -```bash -platform=$(get_platform) -echo "$platform" # x86_64-unknown-linux-gnu -``` - -**Possible Values**: -- `x86_64-unknown-linux-gnu` -- `aarch64-unknown-linux-gnu` -- `x86_64-apple-darwin` -- `aarch64-apple-darwin` - -**Exit Codes**: -- `0`: Success -- `1`: Unsupported platform - ---- - -#### log(), success(), warn(), error() - -Logging functions with color output. - -**Signatures**: -```bash -log "message" # Blue arrow prefix -success "message" # Green arrow prefix -warn "message" # Yellow warning prefix -error "message" # Red error prefix -``` - -**Output**: To stderr - -**Example**: -```bash -log "Downloading version 0.3.2..." -success "Download complete" -warn "Checksum not available" -error "Failed to download" -``` - ---- - -#### command_exists() - -Checks if a command is available in PATH. - -**Signature**: `command_exists ` - -**Arguments**: -- `$1`: Command name - -**Returns**: Nothing (use exit code) - -**Example**: -```bash -if command_exists curl; then - echo "curl is available" -fi -``` - -**Exit Codes**: -- `0`: Command exists -- `1`: Command not found - ---- - -#### check_dependencies() - -Verifies all required dependencies are installed. - -**Signature**: `check_dependencies()` - -**Checks**: bash, curl, tar, sort, grep - -**Example**: -```bash -check_dependencies || exit 1 -``` - -**Exit Codes**: -- `0`: All dependencies found -- `1`: One or more dependencies missing - ---- - -#### github_api_fetch() - -Fetches data from GitHub API with caching. - -**Signature**: `github_api_fetch [use_cache]` - -**Arguments**: -- `$1`: GitHub API URL -- `$2`: Use cache (default: true) - -**Environment Variables Used**: -- `GITHUB_API_TOKEN` (optional) - -**Returns**: JSON response to stdout - -**Example**: -```bash -releases=$(github_api_fetch "https://api.github.com/repos/metatypedev/ghjk/releases") -``` - -**Exit Codes**: -- `0`: Success -- `1`: API error or rate limit exceeded - -**Performance**: With cache: <100ms, Without cache: ~500-2000ms - ---- - -#### sort_versions() - -Sorts versions semantically. - -**Signature**: `sort_versions` (reads from stdin) - -**Input**: Newline-separated versions - -**Output**: Sorted versions - -**Example**: -```bash -echo -e "v0.3.0\nv0.1.0\nv0.2.0" | sort_versions -# v0.1.0 -# v0.2.0 -# v0.3.0 -``` - -**Exit Codes**: Always `0` - ---- - -#### get_asset_name() - -Generates asset filename for a version and platform. - -**Signature**: `get_asset_name ` - -**Arguments**: -- `$1`: Version (with or without 'v' prefix) -- `$2`: Platform string - -**Returns**: Asset filename - -**Example**: -```bash -asset=$(get_asset_name "0.3.2" "x86_64-unknown-linux-gnu") -echo "$asset" # ghjk-v0.3.2-x86_64-unknown-linux-gnu.tar.gz -``` - ---- - -#### get_download_url() - -Generates download URL for a version and platform. - -**Signature**: `get_download_url ` - -**Arguments**: -- `$1`: Version -- `$2`: Platform string - -**Returns**: Download URL - -**Example**: -```bash -url=$(get_download_url "0.3.2" "x86_64-unknown-linux-gnu") -echo "$url" -# https://github.com/metatypedev/ghjk/releases/download/v0.3.2/ghjk-v0.3.2-x86_64-unknown-linux-gnu.tar.gz -``` - ---- - -#### download_file() - -Downloads a file with retry logic. - -**Signature**: `download_file ` - -**Arguments**: -- `$1`: URL to download -- `$2`: Output file path - -**Retries**: 3 attempts with 2-second delay - -**Example**: -```bash -download_file "https://example.com/file.tar.gz" "/tmp/file.tar.gz" -``` - -**Exit Codes**: -- `0`: Success -- `1`: Failed after retries - ---- - -#### verify_checksum() - -Verifies SHA256 checksum of a file. - -**Signature**: `verify_checksum ` - -**Arguments**: -- `$1`: File to verify -- `$2`: Expected SHA256 hash - -**Example**: -```bash -if verify_checksum "/tmp/file.tar.gz" "abc123..."; then - echo "Checksum valid" -fi -``` - -**Exit Codes**: -- `0`: Checksum matches or no checksum provided -- `1`: Checksum mismatch - ---- - -#### extract_archive() - -Extracts a tar.gz archive. - -**Signature**: `extract_archive ` - -**Arguments**: -- `$1`: Archive file path -- `$2`: Destination directory - -**Example**: -```bash -extract_archive "/tmp/file.tar.gz" "/tmp/extracted" -``` - -**Exit Codes**: -- `0`: Success -- `1`: Extraction failed - ---- - -#### cleanup() - -Removes a file or directory. - -**Signature**: `cleanup ` - -**Arguments**: -- `$1`: Path to remove - -**Example**: -```bash -cleanup "/tmp/tempfile" -``` - -**Exit Codes**: Always `0` - ---- - -### lib/cache.sh - -Cache management functions. Source this file: - -```bash -source "${PLUGIN_DIR}/lib/cache.sh" -``` - -#### init_cache() - -Initializes cache directory. - -**Signature**: `init_cache()` - -**Creates**: `~/.asdf/cache/ghjk/` - ---- - -#### get_cached() - -Retrieves cached response if valid. - -**Signature**: `get_cached ` - -**Arguments**: -- `$1`: URL that was cached - -**Returns**: Cached response or nothing - -**Exit Codes**: -- `0`: Valid cache found -- `1`: No cache or expired - ---- - -#### save_to_cache() - -Saves response to cache. - -**Signature**: `save_to_cache ` - -**Arguments**: -- `$1`: URL to cache -- `$2`: Response data - ---- - -#### clear_cache() - -Removes all cached files. - -**Signature**: `clear_cache()` - ---- - -#### clean_cache() - -Removes expired cache entries. - -**Signature**: `clean_cache()` - ---- - -#### cache_stats() - -Displays cache statistics. - -**Signature**: `cache_stats()` - -**Output**: Human-readable statistics - ---- - -## Environment Variables - -### User-Configurable - -| Variable | Purpose | Default | Example | -|----------|---------|---------|---------| -| `GITHUB_API_TOKEN` | GitHub API authentication | None | `ghp_abc123...` | -| `GHJK_CACHE_TTL` | Cache time-to-live (seconds) | `3600` | `7200` | -| `ASDF_DATA_DIR` | asdf data directory | `~/.asdf` | `/custom/path` | - -### asdf-Provided - -| Variable | Set By | Purpose | -|----------|--------|---------| -| `ASDF_INSTALL_VERSION` | asdf | Version to install | -| `ASDF_INSTALL_PATH` | asdf | Installation destination | -| `ASDF_DOWNLOAD_PATH` | asdf | Download destination | -| `ASDF_INSTALL_TYPE` | asdf | Type of install (version/ref) | - -### Internal - -| Variable | Purpose | -|----------|---------| -| `PLUGIN_DIR` | Plugin installation directory | -| `GITHUB_REPO` | ghjk repository name | -| `GITHUB_API_URL` | Base GitHub API URL | - ---- - -## Exit Codes - -All scripts follow standard Unix conventions: - -| Code | Meaning | -|------|---------| -| `0` | Success | -| `1` | General error | -| Other | Not used (reserved for future) | - ---- - -## File Formats - -### .metadata - -Created by `bin/download`, read by `bin/install`. - -**Location**: `${ASDF_DOWNLOAD_PATH}/.metadata` - -**Format**: Shell variable assignments - -**Example**: -```bash -version=0.3.2 -platform=x86_64-unknown-linux-gnu -archive=ghjk-v0.3.2-x86_64-unknown-linux-gnu.tar.gz -checksum=abc123def456... -``` - -**Usage**: -```bash -source "${ASDF_DOWNLOAD_PATH}/.metadata" -echo "Version: $version" -``` - -### Cache Files - -**Location**: `~/.asdf/cache/ghjk/.json` - -**Format**: Raw JSON from GitHub API - -**Naming**: SHA256 hash of the URL - -**TTL**: Controlled by `GHJK_CACHE_TTL` - ---- - -## Error Messages - -### Common Patterns - -| Pattern | Meaning | Action | -|---------|---------|--------| -| `Error: ASDF_* required` | Missing environment variable | Set variable | -| `Error: GitHub API rate limit` | Too many requests | Set `GITHUB_API_TOKEN` | -| `Error: Checksum verification failed` | Download corrupted | Re-download | -| `Error: Unsupported platform` | Platform not supported | Check compatibility | - -### Debug Output - -Enable with: -```bash -export ASDF_DEBUG=1 -``` - ---- - -## Version Compatibility - -### Script Versions - -Scripts follow semantic versioning conceptually but are versioned with the plugin. - -### API Stability - -**Stable** (will not break): -- All `bin/*` scripts interface with asdf -- Environment variables read/written -- Exit codes -- File formats - -**Internal** (may change): -- Library function signatures -- Internal variable names -- Cache format -- Log message formats - ---- - -## Examples - -### Complete Installation Flow - -```bash -# 1. List versions -export GITHUB_API_TOKEN="ghp_..." -versions=$(./bin/list-all) - -# 2. Download -export ASDF_INSTALL_VERSION="0.3.2" -export ASDF_DOWNLOAD_PATH="/tmp/download" -./bin/download - -# 3. Install -export ASDF_INSTALL_PATH="/tmp/install" -export ASDF_INSTALL_TYPE="version" -./bin/install - -# 4. Verify -/tmp/install/bin/ghjk --version -``` - -### Using Library Functions - -```bash -#!/bin/bash -source lib/utils.sh - -# Detect platform -platform=$(get_platform) -log "Detected platform: $platform" - -# Check dependencies -if check_dependencies; then - success "All dependencies found" -else - error "Missing dependencies" - exit 1 -fi - -# Fetch releases -releases=$(github_api_fetch "https://api.github.com/repos/metatypedev/ghjk/releases") - -# Get latest version -latest=$(echo "$releases" | grep -o '"tag_name": *"[^"]*"' | head -1 | sed 's/"tag_name": *"\([^"]*\)"/\1/') -log "Latest version: $latest" - -# Download -url=$(get_download_url "$latest" "$platform") -download_file "$url" "/tmp/ghjk.tar.gz" - -# Extract -extract_archive "/tmp/ghjk.tar.gz" "/tmp/ghjk" - -# Cleanup -cleanup "/tmp/ghjk.tar.gz" -``` - ---- - -## Performance Tips - -1. **Use caching**: Keep `GHJK_CACHE_TTL` at default or higher -2. **Set GitHub token**: Avoid rate limits -3. **Parallel installs**: Install multiple versions in separate shells -4. **Clean cache**: Run `./scripts/cleanup.sh --cache` periodically - ---- - -## See Also - -- [Architecture Documentation](ARCHITECTURE.md) -- [Troubleshooting Guide](TROUBLESHOOTING.md) -- [Examples](EXAMPLES.md) - ---- - -**Last Updated**: 2024-11-22 diff --git a/asdf-augmenters/asdf-ghjk/docs/ARCHITECTURE.adoc b/asdf-augmenters/asdf-ghjk/docs/ARCHITECTURE.adoc new file mode 100644 index 00000000..a3a0bca2 --- /dev/null +++ b/asdf-augmenters/asdf-ghjk/docs/ARCHITECTURE.adoc @@ -0,0 +1,439 @@ +== Architecture Documentation + +This document describes the internal architecture and design decisions +of asdf-ghjk. + +=== Table of Contents + +* link:#overview[Overview] +* link:#directory-structure[Directory Structure] +* link:#component-architecture[Component Architecture] +* link:#data-flow[Data Flow] +* link:#design-decisions[Design Decisions] +* link:#extension-points[Extension Points] + +=== Overview + +asdf-ghjk is an asdf plugin that follows the asdf plugin specification +to provide version management for ghjk. The plugin is implemented +entirely in Bash for maximum portability and minimal dependencies. + +==== Key Principles + +[arabic] +. *Simplicity*: Minimal dependencies, straightforward implementation +. *Portability*: Works across Linux and macOS with bash 4.0+ +. *Reliability*: Comprehensive error handling and validation +. *Performance*: Caching and efficient algorithms +. *Security*: Checksum verification and HTTPS-only downloads + +=== Directory Structure + +.... +asdf-ghjk/ +├── bin/ # Executable scripts (asdf interface) +│ ├── download # Downloads ghjk releases +│ ├── install # Installs downloaded releases +│ ├── list-all # Lists all available versions +│ ├── list-bin-paths # Lists binary paths for asdf +│ ├── help-overview # Provides help text +│ └── latest-stable # Returns latest stable version +├── lib/ # Shared library code +│ ├── utils.sh # Core utilities and helpers +│ └── cache.sh # API response caching +├── test/ # Test suite +│ ├── *.bats # BATS test files +│ └── test_helpers.bash # Test helper functions +├── scripts/ # Development and maintenance scripts +│ ├── setup-dev.sh # Development environment setup +│ ├── test.sh # Test runner +│ └── benchmark.sh # Performance benchmarking +├── docs/ # Documentation +│ ├── *.md # Various documentation files +├── examples/ # Usage examples +│ ├── Dockerfile # Docker integration examples +│ └── docker-compose.yml # Docker Compose examples +├── completions/ # Shell completion scripts +│ ├── ghjk.bash # Bash completions +│ └── ghjk.zsh # Zsh completions +└── .github/ # GitHub-specific files + ├── workflows/ # GitHub Actions CI/CD + └── ISSUE_TEMPLATE/ # Issue templates +.... + +=== Component Architecture + +==== 1. Core Scripts (`+bin/+`) + +===== `+bin/list-all+` + +*Purpose*: List all available ghjk versions from GitHub releases + +*Flow*: 1. Source utilities 2. Check dependencies 3. Fetch releases from +GitHub API (with caching) 4. Extract version tags 5. Sort versions +semantically 6. Output space-separated list + +*Dependencies*: `+lib/utils.sh+`, `+lib/cache.sh+` (optional) + +*Output Format*: Space-separated versions on single line + +===== `+bin/download+` + +*Purpose*: Download ghjk binary for specified version + +*Flow*: 1. Read environment variables (`+ASDF_INSTALL_VERSION+`, +`+ASDF_DOWNLOAD_PATH+`) 2. Detect platform architecture 3. Construct +download URL 4. Fetch release metadata for checksum 5. Download binary +with retry logic 6. Verify checksum (if available) 7. Save metadata for +install script + +*Dependencies*: `+lib/utils.sh+` + +*Side Effects*: - Downloads file to `+ASDF_DOWNLOAD_PATH+` - Creates +`+.metadata+` file + +===== `+bin/install+` + +*Purpose*: Install downloaded ghjk binary + +*Flow*: 1. Read environment variables 2. Locate downloaded archive 3. +Extract to install path 4. Verify binary exists and is executable 5. +Check runtime dependencies 6. Create bin/ symlink if needed + +*Dependencies*: `+lib/utils.sh+` + +*Side Effects*: - Extracts files to `+ASDF_INSTALL_PATH+` - Creates +symlinks - Sets executable permissions + +===== `+bin/list-bin-paths+` + +*Purpose*: Tell asdf where to find binaries + +*Flow*: 1. Check for `+bin/+` directory 2. Fall back to root directory +if needed 3. Output path(s) + +*Called By*: asdf (automatically) + +===== `+bin/help-overview+` + +*Purpose*: Provide user-friendly help text + +*Output*: Formatted help documentation + +===== `+bin/latest-stable+` + +*Purpose*: Get latest non-prerelease version + +*Flow*: 1. Fetch releases 2. Filter out pre-releases (rc, alpha, beta) +3. Return first (latest) version + +==== 2. Library Code (`+lib/+`) + +===== `+lib/utils.sh+` + +*Core utility functions*: + +[cols=",",options="header",] +|=== +|Function |Purpose +|`+get_platform()+` |Detect OS and architecture +|`+log()+`, `+success()+`, `+warn()+`, `+error()+` |Logging with colors +|`+command_exists()+` |Check if command is available +|`+check_dependencies()+` |Verify required tools +|`+github_api_fetch()+` |Fetch from GitHub API with caching +|`+sort_versions()+` |Sort versions semantically +|`+get_asset_name()+` |Generate asset filename +|`+get_download_url()+` |Generate download URL +|`+download_file()+` |Download with retry logic +|`+verify_checksum()+` |SHA256 verification +|`+extract_archive()+` |Extract tar.gz files +|`+cleanup()+` |Clean up temporary files +|=== + +*Design*: Single-responsibility functions, pure where possible + +===== `+lib/cache.sh+` + +*Caching implementation*: + +[cols=",",options="header",] +|=== +|Function |Purpose +|`+init_cache()+` |Initialize cache directory +|`+get_cache_path()+` |Generate cache file path +|`+is_cache_valid()+` |Check cache freshness +|`+get_cached()+` |Retrieve cached response +|`+save_to_cache()+` |Store response in cache +|`+clear_cache()+` |Remove all cache +|`+clean_cache()+` |Remove expired cache +|`+cache_stats()+` |Display cache statistics +|=== + +*Design*: - TTL-based expiration (default 1 hour) - SHA256-based cache +keys - Graceful degradation if caching fails + +==== 3. Test Suite (`+test/+`) + +*Framework*: BATS (Bash Automated Testing System) + +*Test Files*: - `+utils.bats+`: Unit tests for utility functions - +`+list-all.bats+`: Tests for version listing - `+download.bats+`: Tests +for download functionality - `+install.bats+`: Tests for installation + +*Test Helpers*: Common setup/teardown, mock data, fixtures + +=== Data Flow + +==== Version Installation Flow + +.... +User runs: asdf install ghjk 0.3.2 + ↓ +asdf calls: bin/download + ↓ +bin/download: + 1. Detects platform (x86_64-unknown-linux-gnu) + 2. Constructs URL (github.com/.../ghjk-v0.3.2-x86_64-unknown-linux-gnu.tar.gz) + 3. Fetches release metadata + 4. Downloads file (with retry) + 5. Verifies checksum + 6. Saves metadata + ↓ +asdf calls: bin/install + ↓ +bin/install: + 1. Reads metadata + 2. Extracts archive + 3. Verifies binary + 4. Creates symlinks + 5. Checks dependencies + ↓ +asdf creates shims + ↓ +User runs: ghjk --version +.... + +==== Version Listing Flow + +.... +User runs: asdf list all ghjk + ↓ +asdf calls: bin/list-all + ↓ +bin/list-all: + 1. Checks cache + 2. If cached: return cached data + 3. If not cached: + a. Fetches from GitHub API + b. Paginates through all releases + c. Extracts version tags + d. Saves to cache + 4. Sorts versions + 5. Outputs space-separated list + ↓ +asdf displays to user +.... + +=== Design Decisions + +==== Why Bash? + +*Chosen*: Bash 4.0+ + +*Rationale*: - Required by asdf specification - Maximum portability +(available on all target platforms) - No compilation needed - +Well-understood by shell users - Rich ecosystem of tools + +*Tradeoffs*: - Less type safety than compiled languages - Harder to +refactor than modern languages - Requires careful error handling + +==== Why Caching? + +*Chosen*: File-based TTL cache + +*Rationale*: - Reduces GitHub API calls (rate limit friendly) - Improves +performance for repeated operations - Simple implementation without +external dependencies - Transparent to users + +*Implementation*: - Cache location: `+~/.asdf/cache/ghjk/+` - TTL: 1 +hour (configurable via `+GHJK_CACHE_TTL+`) - Key: SHA256 hash of URL - +Format: Raw JSON responses + +*Tradeoffs*: - Slightly stale data possible - Disk space usage (minimal, +~KB per cached response) - Manual cache invalidation needed for forced +updates + +==== Platform Detection + +*Method*: `+uname+` system calls + +*Mapping*: + +[source,bash] +---- +Linux + x86_64 → x86_64-unknown-linux-gnu +Linux + aarch64 → aarch64-unknown-linux-gnu +Darwin + x86_64 → x86_64-apple-darwin +Darwin + arm64 → aarch64-apple-darwin +---- + +*Rationale*: Matches ghjk’s release naming convention + +==== Checksum Verification + +*Method*: SHA256 from GitHub release metadata + +*Flow*: 1. Fetch release metadata from GitHub API 2. Extract SHA256 from +asset metadata 3. Calculate SHA256 of downloaded file 4. Compare hashes +5. Fail installation if mismatch + +*Rationale*: - Prevents corrupted downloads - Detects tampering - +Industry-standard algorithm + +*Tradeoffs*: - Extra API call - Slight performance overhead - Warnings +if checksum unavailable (rare) + +==== Error Handling Strategy + +*Principles*: 1. *Fail Fast*: Exit immediately on critical errors 2. +*Clear Messages*: Human-readable error descriptions 3. *Actionable*: +Suggest solutions when possible 4. *Logged*: All errors go to stderr 5. +*Codes*: Proper exit codes (0 = success, non-zero = failure) + +*Example*: + +[source,bash] +---- +if ! curl -fsSL "$url" -o "$output"; then + error "Failed to download ghjk ${version}" + error "Check your internet connection and try again" + error "URL: $url" + exit 1 +fi +---- + +==== Dependency Philosophy + +*Approach*: Minimal, standard dependencies only + +*Required*: - bash (4.0+) - curl - tar - grep - sort + +*Rationale*: Available on all target platforms by default + +*Not Required*: - jq (use grep/sed for JSON parsing) - wget (use curl) - +python (keep everything in bash) + +=== Extension Points + +==== Adding New Scripts + +To add a new bin script: + +[arabic] +. Create file in `+bin/+` +. Add shebang: `+#!/usr/bin/env bash+` +. Set strict mode: `+set -euo pipefail+` +. Source utilities: `+source "${PLUGIN_DIR}/lib/utils.sh"+` +. Implement functionality +. Make executable: `+chmod +x bin/new-script+` +. Document in README +. Add tests in `+test/+` + +==== Adding New Utilities + +To add a new utility function: + +[arabic] +. Add to `+lib/utils.sh+` +. Follow naming convention (lowercase with underscores) +. Add documentation comment +. Write tests in `+test/utils.bats+` +. Update ARCHITECTURE.md (this file) + +==== Adding Platform Support + +To add a new platform: + +[arabic] +. Update `+get_platform()+` in `+lib/utils.sh+` +. Add platform detection logic +. Add platform to documentation +. Update tests +. Add CI test matrix entry + +==== Customizing Cache Behavior + +Environment variables: + +* `+GHJK_CACHE_TTL+`: Cache time-to-live in seconds (default: 3600) +* `+ASDF_DATA_DIR+`: Base directory for asdf data (cache subdirectory) + +=== Performance Characteristics + +==== Time Complexity + +[cols=",,",options="header",] +|=== +|Operation |Complexity |Notes +|list-all (cached) |O(1) |Direct file read +|list-all (uncached) |O(n) |n = number of releases +|download |O(1) |Single file download +|install |O(1) |Single archive extraction +|sort_versions |O(n log n) |Standard sort +|=== + +==== Space Complexity + +[cols=",",options="header",] +|=== +|Component |Space Usage +|Plugin code |< 100 KB +|Cache (per response) |~10-50 KB +|Downloaded archive |10-50 MB +|Installed binary |10-50 MB +|Per version total |~20-100 MB +|=== + +=== Security Considerations + +==== Attack Surface + +*Potential Vectors*: 1. Malicious GitHub responses 2. Man-in-the-middle +attacks 3. Compromised downloads 4. Path traversal attacks + +*Mitigations*: 1. HTTPS-only connections 2. Checksum verification 3. +Input validation 4. Proper path quoting 5. No use of `+eval+` or +dangerous constructs + +==== Code Review Points + +When reviewing changes: - [ ] All user inputs validated - [ ] All file +paths properly quoted - [ ] No use of `+eval+`, `+source+` on untrusted +input - [ ] HTTPS used for all downloads - [ ] Error messages don’t leak +sensitive data - [ ] ShellCheck passes - [ ] Tests cover +security-relevant cases + +=== Future Enhancements + +Potential additions: + +[arabic] +. *Parallel Downloads*: Download/install multiple versions concurrently +. *Mirror Support*: Allow alternative download sources +. *GPG Verification*: Verify GPG signatures if ghjk adds them +. *Version Constraints*: Support version range specifications +. *Rollback Support*: Automatically rollback failed installations +. *Telemetry*: Optional usage statistics (opt-in) + +=== References + +* https://asdf-vm.com/plugins/create.html[asdf Plugin Development] +* https://google.github.io/styleguide/shellguide.html[Google Shell Style +Guide] +* https://www.shellcheck.net/[ShellCheck] +* https://github.com/bats-core/bats-core[BATS Testing] +* https://github.com/metatypedev/ghjk[ghjk Repository] + +''''' + +*Maintained By*: asdf-ghjk contributors *Last Updated*: 2024-11-22 diff --git a/asdf-augmenters/asdf-ghjk/docs/ARCHITECTURE.md b/asdf-augmenters/asdf-ghjk/docs/ARCHITECTURE.md deleted file mode 100644 index c7485d43..00000000 --- a/asdf-augmenters/asdf-ghjk/docs/ARCHITECTURE.md +++ /dev/null @@ -1,476 +0,0 @@ -# Architecture Documentation - -This document describes the internal architecture and design decisions of asdf-ghjk. - -## Table of Contents - -- [Overview](#overview) -- [Directory Structure](#directory-structure) -- [Component Architecture](#component-architecture) -- [Data Flow](#data-flow) -- [Design Decisions](#design-decisions) -- [Extension Points](#extension-points) - -## Overview - -asdf-ghjk is an asdf plugin that follows the asdf plugin specification to provide version management for ghjk. The plugin is implemented entirely in Bash for maximum portability and minimal dependencies. - -### Key Principles - -1. **Simplicity**: Minimal dependencies, straightforward implementation -2. **Portability**: Works across Linux and macOS with bash 4.0+ -3. **Reliability**: Comprehensive error handling and validation -4. **Performance**: Caching and efficient algorithms -5. **Security**: Checksum verification and HTTPS-only downloads - -## Directory Structure - -``` -asdf-ghjk/ -├── bin/ # Executable scripts (asdf interface) -│ ├── download # Downloads ghjk releases -│ ├── install # Installs downloaded releases -│ ├── list-all # Lists all available versions -│ ├── list-bin-paths # Lists binary paths for asdf -│ ├── help-overview # Provides help text -│ └── latest-stable # Returns latest stable version -├── lib/ # Shared library code -│ ├── utils.sh # Core utilities and helpers -│ └── cache.sh # API response caching -├── test/ # Test suite -│ ├── *.bats # BATS test files -│ └── test_helpers.bash # Test helper functions -├── scripts/ # Development and maintenance scripts -│ ├── setup-dev.sh # Development environment setup -│ ├── test.sh # Test runner -│ └── benchmark.sh # Performance benchmarking -├── docs/ # Documentation -│ ├── *.md # Various documentation files -├── examples/ # Usage examples -│ ├── Dockerfile # Docker integration examples -│ └── docker-compose.yml # Docker Compose examples -├── completions/ # Shell completion scripts -│ ├── ghjk.bash # Bash completions -│ └── ghjk.zsh # Zsh completions -└── .github/ # GitHub-specific files - ├── workflows/ # GitHub Actions CI/CD - └── ISSUE_TEMPLATE/ # Issue templates -``` - -## Component Architecture - -### 1. Core Scripts (`bin/`) - -#### `bin/list-all` - -**Purpose**: List all available ghjk versions from GitHub releases - -**Flow**: -1. Source utilities -2. Check dependencies -3. Fetch releases from GitHub API (with caching) -4. Extract version tags -5. Sort versions semantically -6. Output space-separated list - -**Dependencies**: `lib/utils.sh`, `lib/cache.sh` (optional) - -**Output Format**: Space-separated versions on single line - -#### `bin/download` - -**Purpose**: Download ghjk binary for specified version - -**Flow**: -1. Read environment variables (`ASDF_INSTALL_VERSION`, `ASDF_DOWNLOAD_PATH`) -2. Detect platform architecture -3. Construct download URL -4. Fetch release metadata for checksum -5. Download binary with retry logic -6. Verify checksum (if available) -7. Save metadata for install script - -**Dependencies**: `lib/utils.sh` - -**Side Effects**: -- Downloads file to `ASDF_DOWNLOAD_PATH` -- Creates `.metadata` file - -#### `bin/install` - -**Purpose**: Install downloaded ghjk binary - -**Flow**: -1. Read environment variables -2. Locate downloaded archive -3. Extract to install path -4. Verify binary exists and is executable -5. Check runtime dependencies -6. Create bin/ symlink if needed - -**Dependencies**: `lib/utils.sh` - -**Side Effects**: -- Extracts files to `ASDF_INSTALL_PATH` -- Creates symlinks -- Sets executable permissions - -#### `bin/list-bin-paths` - -**Purpose**: Tell asdf where to find binaries - -**Flow**: -1. Check for `bin/` directory -2. Fall back to root directory if needed -3. Output path(s) - -**Called By**: asdf (automatically) - -#### `bin/help-overview` - -**Purpose**: Provide user-friendly help text - -**Output**: Formatted help documentation - -#### `bin/latest-stable` - -**Purpose**: Get latest non-prerelease version - -**Flow**: -1. Fetch releases -2. Filter out pre-releases (rc, alpha, beta) -3. Return first (latest) version - -### 2. Library Code (`lib/`) - -#### `lib/utils.sh` - -**Core utility functions**: - -| Function | Purpose | -|----------|---------| -| `get_platform()` | Detect OS and architecture | -| `log()`, `success()`, `warn()`, `error()` | Logging with colors | -| `command_exists()` | Check if command is available | -| `check_dependencies()` | Verify required tools | -| `github_api_fetch()` | Fetch from GitHub API with caching | -| `sort_versions()` | Sort versions semantically | -| `get_asset_name()` | Generate asset filename | -| `get_download_url()` | Generate download URL | -| `download_file()` | Download with retry logic | -| `verify_checksum()` | SHA256 verification | -| `extract_archive()` | Extract tar.gz files | -| `cleanup()` | Clean up temporary files | - -**Design**: Single-responsibility functions, pure where possible - -#### `lib/cache.sh` - -**Caching implementation**: - -| Function | Purpose | -|----------|---------| -| `init_cache()` | Initialize cache directory | -| `get_cache_path()` | Generate cache file path | -| `is_cache_valid()` | Check cache freshness | -| `get_cached()` | Retrieve cached response | -| `save_to_cache()` | Store response in cache | -| `clear_cache()` | Remove all cache | -| `clean_cache()` | Remove expired cache | -| `cache_stats()` | Display cache statistics | - -**Design**: -- TTL-based expiration (default 1 hour) -- SHA256-based cache keys -- Graceful degradation if caching fails - -### 3. Test Suite (`test/`) - -**Framework**: BATS (Bash Automated Testing System) - -**Test Files**: -- `utils.bats`: Unit tests for utility functions -- `list-all.bats`: Tests for version listing -- `download.bats`: Tests for download functionality -- `install.bats`: Tests for installation - -**Test Helpers**: Common setup/teardown, mock data, fixtures - -## Data Flow - -### Version Installation Flow - -``` -User runs: asdf install ghjk 0.3.2 - ↓ -asdf calls: bin/download - ↓ -bin/download: - 1. Detects platform (x86_64-unknown-linux-gnu) - 2. Constructs URL (github.com/.../ghjk-v0.3.2-x86_64-unknown-linux-gnu.tar.gz) - 3. Fetches release metadata - 4. Downloads file (with retry) - 5. Verifies checksum - 6. Saves metadata - ↓ -asdf calls: bin/install - ↓ -bin/install: - 1. Reads metadata - 2. Extracts archive - 3. Verifies binary - 4. Creates symlinks - 5. Checks dependencies - ↓ -asdf creates shims - ↓ -User runs: ghjk --version -``` - -### Version Listing Flow - -``` -User runs: asdf list all ghjk - ↓ -asdf calls: bin/list-all - ↓ -bin/list-all: - 1. Checks cache - 2. If cached: return cached data - 3. If not cached: - a. Fetches from GitHub API - b. Paginates through all releases - c. Extracts version tags - d. Saves to cache - 4. Sorts versions - 5. Outputs space-separated list - ↓ -asdf displays to user -``` - -## Design Decisions - -### Why Bash? - -**Chosen**: Bash 4.0+ - -**Rationale**: -- Required by asdf specification -- Maximum portability (available on all target platforms) -- No compilation needed -- Well-understood by shell users -- Rich ecosystem of tools - -**Tradeoffs**: -- Less type safety than compiled languages -- Harder to refactor than modern languages -- Requires careful error handling - -### Why Caching? - -**Chosen**: File-based TTL cache - -**Rationale**: -- Reduces GitHub API calls (rate limit friendly) -- Improves performance for repeated operations -- Simple implementation without external dependencies -- Transparent to users - -**Implementation**: -- Cache location: `~/.asdf/cache/ghjk/` -- TTL: 1 hour (configurable via `GHJK_CACHE_TTL`) -- Key: SHA256 hash of URL -- Format: Raw JSON responses - -**Tradeoffs**: -- Slightly stale data possible -- Disk space usage (minimal, ~KB per cached response) -- Manual cache invalidation needed for forced updates - -### Platform Detection - -**Method**: `uname` system calls - -**Mapping**: -```bash -Linux + x86_64 → x86_64-unknown-linux-gnu -Linux + aarch64 → aarch64-unknown-linux-gnu -Darwin + x86_64 → x86_64-apple-darwin -Darwin + arm64 → aarch64-apple-darwin -``` - -**Rationale**: Matches ghjk's release naming convention - -### Checksum Verification - -**Method**: SHA256 from GitHub release metadata - -**Flow**: -1. Fetch release metadata from GitHub API -2. Extract SHA256 from asset metadata -3. Calculate SHA256 of downloaded file -4. Compare hashes -5. Fail installation if mismatch - -**Rationale**: -- Prevents corrupted downloads -- Detects tampering -- Industry-standard algorithm - -**Tradeoffs**: -- Extra API call -- Slight performance overhead -- Warnings if checksum unavailable (rare) - -### Error Handling Strategy - -**Principles**: -1. **Fail Fast**: Exit immediately on critical errors -2. **Clear Messages**: Human-readable error descriptions -3. **Actionable**: Suggest solutions when possible -4. **Logged**: All errors go to stderr -5. **Codes**: Proper exit codes (0 = success, non-zero = failure) - -**Example**: -```bash -if ! curl -fsSL "$url" -o "$output"; then - error "Failed to download ghjk ${version}" - error "Check your internet connection and try again" - error "URL: $url" - exit 1 -fi -``` - -### Dependency Philosophy - -**Approach**: Minimal, standard dependencies only - -**Required**: -- bash (4.0+) -- curl -- tar -- grep -- sort - -**Rationale**: Available on all target platforms by default - -**Not Required**: -- jq (use grep/sed for JSON parsing) -- wget (use curl) -- python (keep everything in bash) - -## Extension Points - -### Adding New Scripts - -To add a new bin script: - -1. Create file in `bin/` -2. Add shebang: `#!/usr/bin/env bash` -3. Set strict mode: `set -euo pipefail` -4. Source utilities: `source "${PLUGIN_DIR}/lib/utils.sh"` -5. Implement functionality -6. Make executable: `chmod +x bin/new-script` -7. Document in README -8. Add tests in `test/` - -### Adding New Utilities - -To add a new utility function: - -1. Add to `lib/utils.sh` -2. Follow naming convention (lowercase with underscores) -3. Add documentation comment -4. Write tests in `test/utils.bats` -5. Update ARCHITECTURE.md (this file) - -### Adding Platform Support - -To add a new platform: - -1. Update `get_platform()` in `lib/utils.sh` -2. Add platform detection logic -3. Add platform to documentation -4. Update tests -5. Add CI test matrix entry - -### Customizing Cache Behavior - -Environment variables: - -- `GHJK_CACHE_TTL`: Cache time-to-live in seconds (default: 3600) -- `ASDF_DATA_DIR`: Base directory for asdf data (cache subdirectory) - -## Performance Characteristics - -### Time Complexity - -| Operation | Complexity | Notes | -|-----------|-----------|-------| -| list-all (cached) | O(1) | Direct file read | -| list-all (uncached) | O(n) | n = number of releases | -| download | O(1) | Single file download | -| install | O(1) | Single archive extraction | -| sort_versions | O(n log n) | Standard sort | - -### Space Complexity - -| Component | Space Usage | -|-----------|-------------| -| Plugin code | < 100 KB | -| Cache (per response) | ~10-50 KB | -| Downloaded archive | 10-50 MB | -| Installed binary | 10-50 MB | -| Per version total | ~20-100 MB | - -## Security Considerations - -### Attack Surface - -**Potential Vectors**: -1. Malicious GitHub responses -2. Man-in-the-middle attacks -3. Compromised downloads -4. Path traversal attacks - -**Mitigations**: -1. HTTPS-only connections -2. Checksum verification -3. Input validation -4. Proper path quoting -5. No use of `eval` or dangerous constructs - -### Code Review Points - -When reviewing changes: -- [ ] All user inputs validated -- [ ] All file paths properly quoted -- [ ] No use of `eval`, `source` on untrusted input -- [ ] HTTPS used for all downloads -- [ ] Error messages don't leak sensitive data -- [ ] ShellCheck passes -- [ ] Tests cover security-relevant cases - -## Future Enhancements - -Potential additions: - -1. **Parallel Downloads**: Download/install multiple versions concurrently -2. **Mirror Support**: Allow alternative download sources -3. **GPG Verification**: Verify GPG signatures if ghjk adds them -4. **Version Constraints**: Support version range specifications -5. **Rollback Support**: Automatically rollback failed installations -6. **Telemetry**: Optional usage statistics (opt-in) - -## References - -- [asdf Plugin Development](https://asdf-vm.com/plugins/create.html) -- [Google Shell Style Guide](https://google.github.io/styleguide/shellguide.html) -- [ShellCheck](https://www.shellcheck.net/) -- [BATS Testing](https://github.com/bats-core/bats-core) -- [ghjk Repository](https://github.com/metatypedev/ghjk) - ---- - -**Maintained By**: asdf-ghjk contributors -**Last Updated**: 2024-11-22 diff --git a/asdf-augmenters/asdf-ghjk/docs/COMPATIBILITY.adoc b/asdf-augmenters/asdf-ghjk/docs/COMPATIBILITY.adoc new file mode 100644 index 00000000..5ff38839 --- /dev/null +++ b/asdf-augmenters/asdf-ghjk/docs/COMPATIBILITY.adoc @@ -0,0 +1,254 @@ +== Compatibility Matrix + +This document outlines the compatibility of asdf-ghjk across different +platforms, asdf versions, and ghjk versions. + +=== Platform Support + +[width="100%",cols="23%,27%,19%,17%,14%",options="header",] +|=== +|Platform |Architecture |Status |Tested |Notes +|Linux |x86_64 |✅ Supported |✅ Yes |All major distributions +|Linux |aarch64 (ARM64) |✅ Supported |✅ Yes |Including Raspberry Pi 4+ +|macOS |x86_64 (Intel) |✅ Supported |✅ Yes |macOS 10.15+ +|macOS |arm64 (Apple Silicon) |✅ Supported |✅ Yes |M1, M2, M3 chips +|Windows |x86_64 |❌ Not Supported |❌ No |May work with WSL +|Windows |WSL2 |⚠️ Experimental |⚠️ Limited |Use Linux x86_64 build +|FreeBSD |x86_64 |❌ Not Supported |❌ No |ghjk doesn’t support +|=== + +==== Linux Distributions + +Tested and working: + +* ✅ Ubuntu 20.04, 22.04, 24.04 +* ✅ Debian 11, 12 +* ✅ Fedora 38, 39, 40 +* ✅ CentOS Stream 8, 9 +* ✅ RHEL 8, 9 +* ✅ Arch Linux (latest) +* ✅ Alpine Linux 3.18+ (with bash installed) +* ✅ Amazon Linux 2, 2023 + +Should work but untested: - ⚠️ openSUSE - ⚠️ Gentoo - ⚠️ Void Linux + +==== macOS Versions + +[cols=",,,",options="header",] +|=== +|macOS Version |Intel |Apple Silicon |Status +|14 (Sonoma) |✅ |✅ |Fully supported +|13 (Ventura) |✅ |✅ |Fully supported +|12 (Monterey) |✅ |✅ |Fully supported +|11 (Big Sur) |✅ |✅ |Fully supported +|10.15 (Catalina) |✅ |N/A |Should work +|10.14 and older |⚠️ |N/A |May work, untested +|=== + +=== asdf Versions + +[cols=",,",options="header",] +|=== +|asdf Version |Status |Notes +|0.14.x |✅ Recommended |Latest stable +|0.13.x |✅ Supported |Tested +|0.12.x |✅ Supported |Tested +|0.11.x |⚠️ May work |Untested +|0.10.x |⚠️ May work |Untested +|< 0.10 |❌ Not supported |Too old +|=== + +=== ghjk Versions + +All ghjk versions published on GitHub releases are supported. + +[cols=",,",options="header",] +|=== +|Version Range |Status |Notes +|0.3.x |✅ Fully supported |Current stable series +|0.2.x |✅ Supported |Older stable +|0.1.x |✅ Supported |Early releases +|Pre-releases |✅ Supported |Alpha, beta, rc versions +|=== + +==== Known Issues by Version + +* *< 0.3.0*: Some versions may have different binary naming +* *RC versions*: May have different archive structures + +=== Shell Compatibility + +[cols=",,",options="header",] +|=== +|Shell |Status |Notes +|Bash 4.0+ |✅ Required |Primary shell +|Bash 3.x |❌ Not supported |Too old +|Zsh |✅ Supported |Via asdf +|Fish |✅ Supported |Via asdf +|Dash |⚠️ Limited |asdf may not work +|sh |❌ Not supported |Bash required +|=== + +=== Dependencies + +==== Required Dependencies + +[cols=",,,",options="header",] +|=== +|Tool |Minimum Version |Status |Notes +|bash |4.0 |Required |Script interpreter +|curl |7.0 |Required |Downloads +|tar |1.0 |Required |Archive extraction +|grep |2.5 |Required |Text processing +|sort |8.0 |Required |Version sorting +|=== + +==== ghjk Runtime Dependencies + +These are checked at install time and warned if missing: + +[cols=",,",options="header",] +|=== +|Tool |Required For |Notes +|git |ghjk operation |Version control +|curl |ghjk operation |HTTP requests +|tar |ghjk operation |Archive handling +|unzip |ghjk operation |ZIP extraction +|zstd |ghjk operation |Compression +|=== + +==== Optional Dependencies + +[cols=",,",options="header",] +|=== +|Tool |Purpose |Notes +|sha256sum |Checksum verification |Or shasum on macOS +|shellcheck |Development/linting |Not required for usage +|=== + +=== CI/CD Compatibility + +[cols=",,,",options="header",] +|=== +|Platform |Status |Tested |Notes +|GitHub Actions |✅ Supported |✅ Yes |Ubuntu, macOS runners +|GitLab CI |✅ Supported |✅ Yes |Docker images +|CircleCI |✅ Supported |✅ Yes |Linux, macOS +|Travis CI |✅ Should work |⚠️ Limited |Similar to others +|Jenkins |✅ Should work |⚠️ Limited |Via shell +|Buildkite |✅ Should work |⚠️ Limited |Via shell +|Azure Pipelines |✅ Should work |⚠️ Limited |Linux, macOS agents +|=== + +=== Container Compatibility + +[cols=",,",options="header",] +|=== +|Base Image |Status |Notes +|ubuntu:22.04 |✅ Recommended |Well tested +|ubuntu:20.04 |✅ Supported |Tested +|debian:12 |✅ Supported |Tested +|debian:11 |✅ Supported |Should work +|alpine:3.18+ |⚠️ Limited |Requires bash install +|fedora:latest |✅ Supported |Should work +|amazonlinux:2023 |✅ Supported |Should work +|=== + +=== Known Incompatibilities + +==== Operating Systems + +* ❌ Windows native (cmd, PowerShell) +* ❌ FreeBSD +* ❌ Solaris +* ❌ AIX + +==== Architectures + +* ❌ 32-bit systems (i386, i686, armv7l) +* ❌ RISC-V (ghjk doesn’t provide builds) +* ❌ PowerPC +* ❌ s390x + +==== Environments + +* ❌ BusyBox (limited shell features) +* ❌ Minimal containers without basic tools + +=== Performance Characteristics + +==== Download Speeds + +Typical download times for ghjk binary (~10-50 MB): + +* Good connection (100 Mbps): 1-5 seconds +* Average connection (10 Mbps): 10-30 seconds +* Slow connection (1 Mbps): 1-5 minutes + +==== Installation Time + +* Download: 1-30 seconds (depending on connection) +* Extraction: 1-2 seconds +* Verification: < 1 second +* *Total*: ~2-35 seconds + +==== Disk Space + +Per version installed: - Downloaded archive: 10-50 MB - Extracted +binary: 10-50 MB - *Total per version*: ~20-100 MB + +With 5 versions installed: ~100-500 MB + +=== Compatibility Testing + +==== How We Test + +* ✅ Unit tests on multiple platforms (GitHub Actions) +* ✅ Integration tests with real installations +* ✅ Manual testing on developer machines +* ⚠️ Community reports for less common platforms + +==== Report Compatibility Issues + +If you encounter compatibility issues: + +[arabic] +. Check this document +. Check https://github.com/Hyperpolymath/asdf-ghjk/issues[existing +issues] +. Report new issues with: +* OS and version +* Architecture +* asdf version +* Error messages +* Steps to reproduce + +=== Version Support Policy + +* *Current stable ghjk versions*: Fully supported +* *Old ghjk versions*: Best effort support +* *Pre-release ghjk versions*: Supported but may have issues +* *asdf versions*: Support latest 3 minor versions + +=== Future Compatibility + +==== Planned Support + +* 🔄 Continued support for new ghjk releases +* 🔄 Continued support for new asdf releases +* 🔄 Platform support as ghjk adds them + +==== No Plans For + +* ❌ Windows native support (unless ghjk adds it) +* ❌ 32-bit architecture support +* ❌ Non-Unix operating systems + +''''' + +*Last Updated*: 2024-11-22 + +For the latest compatibility information, check: - +https://github.com/metatypedev/ghjk/releases[ghjk releases] - +https://asdf-vm.com[asdf compatibility] - +https://github.com/Hyperpolymath/asdf-ghjk/issues[Plugin issues] diff --git a/asdf-augmenters/asdf-ghjk/docs/COMPATIBILITY.md b/asdf-augmenters/asdf-ghjk/docs/COMPATIBILITY.md deleted file mode 100644 index 11f95a4b..00000000 --- a/asdf-augmenters/asdf-ghjk/docs/COMPATIBILITY.md +++ /dev/null @@ -1,236 +0,0 @@ -# Compatibility Matrix - -This document outlines the compatibility of asdf-ghjk across different platforms, asdf versions, and ghjk versions. - -## Platform Support - -| Platform | Architecture | Status | Tested | Notes | -|----------|-------------|---------|--------|-------| -| Linux | x86_64 | ✅ Supported | ✅ Yes | All major distributions | -| Linux | aarch64 (ARM64) | ✅ Supported | ✅ Yes | Including Raspberry Pi 4+ | -| macOS | x86_64 (Intel) | ✅ Supported | ✅ Yes | macOS 10.15+ | -| macOS | arm64 (Apple Silicon) | ✅ Supported | ✅ Yes | M1, M2, M3 chips | -| Windows | x86_64 | ❌ Not Supported | ❌ No | May work with WSL | -| Windows | WSL2 | ⚠️ Experimental | ⚠️ Limited | Use Linux x86_64 build | -| FreeBSD | x86_64 | ❌ Not Supported | ❌ No | ghjk doesn't support | - -### Linux Distributions - -Tested and working: - -- ✅ Ubuntu 20.04, 22.04, 24.04 -- ✅ Debian 11, 12 -- ✅ Fedora 38, 39, 40 -- ✅ CentOS Stream 8, 9 -- ✅ RHEL 8, 9 -- ✅ Arch Linux (latest) -- ✅ Alpine Linux 3.18+ (with bash installed) -- ✅ Amazon Linux 2, 2023 - -Should work but untested: -- ⚠️ openSUSE -- ⚠️ Gentoo -- ⚠️ Void Linux - -### macOS Versions - -| macOS Version | Intel | Apple Silicon | Status | -|---------------|-------|---------------|---------| -| 14 (Sonoma) | ✅ | ✅ | Fully supported | -| 13 (Ventura) | ✅ | ✅ | Fully supported | -| 12 (Monterey) | ✅ | ✅ | Fully supported | -| 11 (Big Sur) | ✅ | ✅ | Fully supported | -| 10.15 (Catalina) | ✅ | N/A | Should work | -| 10.14 and older | ⚠️ | N/A | May work, untested | - -## asdf Versions - -| asdf Version | Status | Notes | -|--------------|---------|-------| -| 0.14.x | ✅ Recommended | Latest stable | -| 0.13.x | ✅ Supported | Tested | -| 0.12.x | ✅ Supported | Tested | -| 0.11.x | ⚠️ May work | Untested | -| 0.10.x | ⚠️ May work | Untested | -| < 0.10 | ❌ Not supported | Too old | - -## ghjk Versions - -All ghjk versions published on GitHub releases are supported. - -| Version Range | Status | Notes | -|---------------|---------|-------| -| 0.3.x | ✅ Fully supported | Current stable series | -| 0.2.x | ✅ Supported | Older stable | -| 0.1.x | ✅ Supported | Early releases | -| Pre-releases | ✅ Supported | Alpha, beta, rc versions | - -### Known Issues by Version - -- **< 0.3.0**: Some versions may have different binary naming -- **RC versions**: May have different archive structures - -## Shell Compatibility - -| Shell | Status | Notes | -|-------|---------|-------| -| Bash 4.0+ | ✅ Required | Primary shell | -| Bash 3.x | ❌ Not supported | Too old | -| Zsh | ✅ Supported | Via asdf | -| Fish | ✅ Supported | Via asdf | -| Dash | ⚠️ Limited | asdf may not work | -| sh | ❌ Not supported | Bash required | - -## Dependencies - -### Required Dependencies - -| Tool | Minimum Version | Status | Notes | -|------|----------------|---------|-------| -| bash | 4.0 | Required | Script interpreter | -| curl | 7.0 | Required | Downloads | -| tar | 1.0 | Required | Archive extraction | -| grep | 2.5 | Required | Text processing | -| sort | 8.0 | Required | Version sorting | - -### ghjk Runtime Dependencies - -These are checked at install time and warned if missing: - -| Tool | Required For | Notes | -|------|-------------|-------| -| git | ghjk operation | Version control | -| curl | ghjk operation | HTTP requests | -| tar | ghjk operation | Archive handling | -| unzip | ghjk operation | ZIP extraction | -| zstd | ghjk operation | Compression | - -### Optional Dependencies - -| Tool | Purpose | Notes | -|------|---------|-------| -| sha256sum | Checksum verification | Or shasum on macOS | -| shellcheck | Development/linting | Not required for usage | - -## CI/CD Compatibility - -| Platform | Status | Tested | Notes | -|----------|---------|--------|-------| -| GitHub Actions | ✅ Supported | ✅ Yes | Ubuntu, macOS runners | -| GitLab CI | ✅ Supported | ✅ Yes | Docker images | -| CircleCI | ✅ Supported | ✅ Yes | Linux, macOS | -| Travis CI | ✅ Should work | ⚠️ Limited | Similar to others | -| Jenkins | ✅ Should work | ⚠️ Limited | Via shell | -| Buildkite | ✅ Should work | ⚠️ Limited | Via shell | -| Azure Pipelines | ✅ Should work | ⚠️ Limited | Linux, macOS agents | - -## Container Compatibility - -| Base Image | Status | Notes | -|------------|---------|-------| -| ubuntu:22.04 | ✅ Recommended | Well tested | -| ubuntu:20.04 | ✅ Supported | Tested | -| debian:12 | ✅ Supported | Tested | -| debian:11 | ✅ Supported | Should work | -| alpine:3.18+ | ⚠️ Limited | Requires bash install | -| fedora:latest | ✅ Supported | Should work | -| amazonlinux:2023 | ✅ Supported | Should work | - -## Known Incompatibilities - -### Operating Systems - -- ❌ Windows native (cmd, PowerShell) -- ❌ FreeBSD -- ❌ Solaris -- ❌ AIX - -### Architectures - -- ❌ 32-bit systems (i386, i686, armv7l) -- ❌ RISC-V (ghjk doesn't provide builds) -- ❌ PowerPC -- ❌ s390x - -### Environments - -- ❌ BusyBox (limited shell features) -- ❌ Minimal containers without basic tools - -## Performance Characteristics - -### Download Speeds - -Typical download times for ghjk binary (~10-50 MB): - -- Good connection (100 Mbps): 1-5 seconds -- Average connection (10 Mbps): 10-30 seconds -- Slow connection (1 Mbps): 1-5 minutes - -### Installation Time - -- Download: 1-30 seconds (depending on connection) -- Extraction: 1-2 seconds -- Verification: < 1 second -- **Total**: ~2-35 seconds - -### Disk Space - -Per version installed: -- Downloaded archive: 10-50 MB -- Extracted binary: 10-50 MB -- **Total per version**: ~20-100 MB - -With 5 versions installed: ~100-500 MB - -## Compatibility Testing - -### How We Test - -- ✅ Unit tests on multiple platforms (GitHub Actions) -- ✅ Integration tests with real installations -- ✅ Manual testing on developer machines -- ⚠️ Community reports for less common platforms - -### Report Compatibility Issues - -If you encounter compatibility issues: - -1. Check this document -2. Check [existing issues](https://github.com/Hyperpolymath/asdf-ghjk/issues) -3. Report new issues with: - - OS and version - - Architecture - - asdf version - - Error messages - - Steps to reproduce - -## Version Support Policy - -- **Current stable ghjk versions**: Fully supported -- **Old ghjk versions**: Best effort support -- **Pre-release ghjk versions**: Supported but may have issues -- **asdf versions**: Support latest 3 minor versions - -## Future Compatibility - -### Planned Support - -- 🔄 Continued support for new ghjk releases -- 🔄 Continued support for new asdf releases -- 🔄 Platform support as ghjk adds them - -### No Plans For - -- ❌ Windows native support (unless ghjk adds it) -- ❌ 32-bit architecture support -- ❌ Non-Unix operating systems - ---- - -**Last Updated**: 2024-11-22 - -For the latest compatibility information, check: -- [ghjk releases](https://github.com/metatypedev/ghjk/releases) -- [asdf compatibility](https://asdf-vm.com) -- [Plugin issues](https://github.com/Hyperpolymath/asdf-ghjk/issues) diff --git a/asdf-augmenters/asdf-ghjk/docs/EXAMPLES.adoc b/asdf-augmenters/asdf-ghjk/docs/EXAMPLES.adoc new file mode 100644 index 00000000..ee57bec9 --- /dev/null +++ b/asdf-augmenters/asdf-ghjk/docs/EXAMPLES.adoc @@ -0,0 +1,640 @@ +== Usage Examples + +This document provides real-world examples of using asdf-ghjk. + +=== Table of Contents + +* link:#basic-usage[Basic Usage] +* link:#project-setup[Project Setup] +* link:#cicd-integration[CI/CD Integration] +* link:#multiple-projects[Multiple Projects] +* link:#advanced-workflows[Advanced Workflows] + +=== Basic Usage + +==== Install and Use Latest Version + +[source,bash] +---- +# Install the plugin +asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git + +# Install latest ghjk +asdf install ghjk latest + +# Set as global default +asdf global ghjk latest + +# Verify installation +ghjk --version +---- + +==== Install Specific Version + +[source,bash] +---- +# List all available versions +asdf list all ghjk + +# Install a specific version +asdf install ghjk 0.3.2 + +# Use it globally +asdf global ghjk 0.3.2 +---- + +=== Project Setup + +==== Initialize a New Project + +[source,bash] +---- +# Create project directory +mkdir my-project +cd my-project + +# Set local ghjk version +asdf local ghjk 0.3.2 + +# Initialize ghjk with TypeScript support +ghjk init ts + +# View generated configuration +cat ghjk.ts +---- + +==== Basic Project Configuration + +Create a `+ghjk.ts+` file: + +[source,typescript] +---- +// ghjk.ts +export { sophon } from "https://deno.land/x/ghjk/mod.ts"; + +sophon({ + // Define environment variables + env: { + NODE_ENV: "development", + API_URL: "http://localhost:3000", + }, + + // Install development tools + installs: [ + { name: "node", version: "20.0.0" }, + { name: "python", version: "3.11" }, + ], + + // Define tasks + tasks: { + dev: "npm run dev", + test: "npm test", + build: "npm run build", + lint: "npm run lint", + }, +}); +---- + +==== Activate Environment + +[source,bash] +---- +# Load the ghjk environment +ghjk env + +# Or run tasks directly +ghjk run dev +ghjk run test +---- + +=== CI/CD Integration + +==== GitHub Actions + +`+.github/workflows/ci.yml+`: + +[source,yaml] +---- +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Install asdf + uses: asdf-vm/actions/setup@v3 + + - name: Add ghjk plugin + run: | + asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git + + - name: Install ghjk from .tool-versions + run: | + asdf install ghjk + + - name: Run tests with ghjk + run: | + ghjk run test + + - name: Build with ghjk + run: | + ghjk run build +---- + +==== GitLab CI + +`+.gitlab-ci.yml+`: + +[source,yaml] +---- +image: ubuntu:latest + +variables: + ASDF_DIR: "${CI_PROJECT_DIR}/.asdf" + ASDF_DATA_DIR: "${CI_PROJECT_DIR}/.asdf" + +before_script: + - apt-get update && apt-get install -y git curl tar unzip zstd + - git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.0 + - echo '. $HOME/.asdf/asdf.sh' >> ~/.bashrc + - source ~/.bashrc + - asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git + - asdf install + +test: + script: + - ghjk run test + +build: + script: + - ghjk run build + artifacts: + paths: + - dist/ +---- + +==== CircleCI + +`+.circleci/config.yml+`: + +[source,yaml] +---- +version: 2.1 + +jobs: + test: + docker: + - image: cimg/base:stable + steps: + - checkout + + - run: + name: Install asdf + command: | + git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.0 + echo '. $HOME/.asdf/asdf.sh' >> $BASH_ENV + + - run: + name: Install ghjk + command: | + asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git + asdf install ghjk + + - run: + name: Run tests + command: ghjk run test + +workflows: + version: 2 + test: + jobs: + - test +---- + +=== Multiple Projects + +==== Different Versions per Project + +[source,bash] +---- +# Project A uses ghjk 0.3.2 +cd ~/projects/project-a +asdf local ghjk 0.3.2 +cat .tool-versions +# ghjk 0.3.2 + +# Project B uses latest ghjk +cd ~/projects/project-b +asdf local ghjk latest +cat .tool-versions +# ghjk 0.3.2 + +# asdf automatically switches versions when you cd +---- + +==== Shared Configuration + +`+~/.tool-versions+` (global defaults): + +.... +ghjk 0.3.2 +nodejs 20.0.0 +python 3.11.0 +.... + +Project-specific overrides: + +[source,bash] +---- +cd my-project +asdf local ghjk 0.3.1 # Override just ghjk +# Other tools (nodejs, python) inherited from global +---- + +=== Advanced Workflows + +==== Multi-Environment Setup + +[source,typescript] +---- +// ghjk.ts +export { sophon } from "https://deno.land/x/ghjk/mod.ts"; + +const baseConfig = { + installs: [ + { name: "node", version: "20.0.0" }, + ], +}; + +const developmentConfig = { + ...baseConfig, + env: { + NODE_ENV: "development", + DEBUG: "true", + }, + tasks: { + dev: "npm run dev", + test: "npm test", + }, +}; + +const productionConfig = { + ...baseConfig, + env: { + NODE_ENV: "production", + }, + tasks: { + start: "npm start", + }, +}; + +// Use based on environment variable +const config = Deno.env.get("ENV") === "production" + ? productionConfig + : developmentConfig; + +sophon(config); +---- + +Usage: + +[source,bash] +---- +# Development +ghjk run dev + +# Production +ENV=production ghjk run start +---- + +==== Monorepo Setup + +[source,typescript] +---- +// ghjk.ts (root) +export { sophon } from "https://deno.land/x/ghjk/mod.ts"; + +sophon({ + installs: [ + { name: "node", version: "20.0.0" }, + { name: "python", version: "3.11" }, + ], + + tasks: { + // Root tasks + "test:all": "npm run test --workspaces", + "build:all": "npm run build --workspaces", + "lint:all": "npm run lint --workspaces", + + // Frontend tasks + "dev:frontend": "npm run dev --workspace=packages/frontend", + "build:frontend": "npm run build --workspace=packages/frontend", + + // Backend tasks + "dev:backend": "npm run dev --workspace=packages/backend", + "build:backend": "npm run build --workspace=packages/backend", + + // Run both + dev: "concurrently 'ghjk run dev:frontend' 'ghjk run dev:backend'", + }, +}); +---- + +==== Docker Integration + +`+Dockerfile+`: + +[source,dockerfile] +---- +FROM ubuntu:22.04 + +# Install system dependencies +RUN apt-get update && apt-get install -y \ + git curl tar unzip zstd \ + && rm -rf /var/lib/apt/lists/* + +# Install asdf +RUN git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.0 +ENV PATH="/root/.asdf/bin:/root/.asdf/shims:${PATH}" + +# Install ghjk plugin +RUN asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git + +# Copy project files +WORKDIR /app +COPY .tool-versions ./ +COPY ghjk.ts ./ + +# Install ghjk from .tool-versions +RUN asdf install + +# Install project dependencies +COPY package*.json ./ +RUN ghjk run install + +# Copy application code +COPY . . + +# Build application +RUN ghjk run build + +# Run application +CMD ["ghjk", "run", "start"] +---- + +==== Testing Multiple Versions + +Test your project against multiple ghjk versions: + +[source,bash] +---- +#!/bin/bash +# test-versions.sh + +set -e + +versions=("0.3.0" "0.3.1" "0.3.2") + +for version in "${versions[@]}"; do + echo "Testing with ghjk $version" + + # Install version + asdf install ghjk "$version" + asdf local ghjk "$version" + + # Run tests + if ghjk run test; then + echo "✅ Tests passed with $version" + else + echo "❌ Tests failed with $version" + exit 1 + fi +done + +echo "All versions tested successfully!" +---- + +==== Automatic Version Installation + +Add to your project’s setup script: + +[source,bash] +---- +#!/bin/bash +# setup.sh + +set -e + +echo "Setting up project..." + +# Check if asdf is installed +if ! command -v asdf &> /dev/null; then + echo "Error: asdf is not installed" + echo "Install from: https://asdf-vm.com" + exit 1 +fi + +# Install ghjk plugin if not present +if ! asdf plugin list | grep -q ghjk; then + echo "Adding ghjk plugin..." + asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git +fi + +# Install tools from .tool-versions +echo "Installing tools..." +asdf install + +# Verify ghjk is working +echo "Verifying ghjk installation..." +ghjk --version + +# Install project dependencies +echo "Installing dependencies..." +ghjk run install + +echo "Setup complete! Run 'ghjk run dev' to start development" +---- + +==== Shell Integration + +Add to your shell profile for convenience: + +[source,bash] +---- +# ~/.bashrc or ~/.zshrc + +# ghjk aliases +alias gd='ghjk run dev' +alias gt='ghjk run test' +alias gb='ghjk run build' +alias gl='ghjk run lint' + +# Quick ghjk version switching +ghjk-use() { + asdf local ghjk "$1" + echo "Switched to ghjk $1" + ghjk --version +} + +# List installed ghjk versions +alias ghjk-versions='asdf list ghjk' + +# Update to latest ghjk +ghjk-update() { + local latest + latest=$(asdf list all ghjk | tr ' ' '\n' | tail -1) + echo "Installing ghjk $latest..." + asdf install ghjk "$latest" + asdf global ghjk "$latest" + echo "Updated to ghjk $latest" +} +---- + +=== Tips and Tricks + +==== Cache GitHub API Responses + +Reduce API calls by caching: + +[source,bash] +---- +# Set a long-lived GitHub token +export GITHUB_API_TOKEN="ghp_your_token_here" + +# Or use conditional requests (plugin handles this) +---- + +==== Parallel Installation + +Install multiple versions in parallel: + +[source,bash] +---- +# In separate terminals or with GNU parallel +asdf install ghjk 0.3.0 & +asdf install ghjk 0.3.1 & +asdf install ghjk 0.3.2 & +wait +---- + +==== Backup and Restore + +Export your tool versions: + +[source,bash] +---- +# Backup +cp .tool-versions .tool-versions.backup + +# Restore +cp .tool-versions.backup .tool-versions +asdf install # Install all tools +---- + +==== Automate Updates + +Create a cron job to check for updates: + +[source,bash] +---- +# check-ghjk-updates.sh +#!/bin/bash + +latest=$(asdf list all ghjk | tr ' ' '\n' | tail -1) +current=$(asdf current ghjk | awk '{print $2}') + +if [ "$latest" != "$current" ]; then + echo "New ghjk version available: $latest (current: $current)" + # Optionally auto-install or send notification +fi +---- + +=== Real-World Examples + +==== Full-Stack Web Application + +[source,typescript] +---- +// ghjk.ts +export { sophon } from "https://deno.land/x/ghjk/mod.ts"; + +sophon({ + env: { + DATABASE_URL: "postgresql://localhost/myapp_dev", + REDIS_URL: "redis://localhost:6379", + NODE_ENV: "development", + }, + + installs: [ + { name: "node", version: "20.0.0" }, + { name: "python", version: "3.11" }, + { name: "postgres", version: "15" }, + { name: "redis", version: "7" }, + ], + + tasks: { + // Database + "db:setup": "npm run db:migrate && npm run db:seed", + "db:reset": "npm run db:drop && npm run db:setup", + + // Development + dev: "concurrently 'npm run dev:frontend' 'npm run dev:backend'", + "dev:frontend": "cd frontend && npm run dev", + "dev:backend": "cd backend && npm run dev", + + // Testing + test: "npm run test:unit && npm run test:integration", + "test:unit": "npm run test --workspaces", + "test:e2e": "playwright test", + + // Production + build: "npm run build --workspaces", + start: "node backend/dist/server.js", + }, +}); +---- + +==== Data Science Project + +[source,typescript] +---- +// ghjk.ts +export { sophon } from "https://deno.land/x/ghjk/mod.ts"; + +sophon({ + env: { + JUPYTER_PORT: "8888", + PYTHONPATH: "${PWD}/src", + }, + + installs: [ + { name: "python", version: "3.11" }, + { name: "jupyter", version: "latest" }, + ], + + tasks: { + notebook: "jupyter lab --port=$JUPYTER_PORT", + train: "python src/train.py", + evaluate: "python src/evaluate.py", + "export:model": "python src/export.py", + }, +}); +---- + +=== Conclusion + +These examples demonstrate the flexibility and power of using ghjk with +asdf. Adapt these patterns to your specific needs and workflow. + +For more information: - https://github.com/metatypedev/ghjk[ghjk +documentation] - https://asdf-vm.com[asdf documentation] - +https://github.com/Hyperpolymath/asdf-ghjk[Plugin README] diff --git a/asdf-augmenters/asdf-ghjk/docs/EXAMPLES.md b/asdf-augmenters/asdf-ghjk/docs/EXAMPLES.md deleted file mode 100644 index e3cd81bd..00000000 --- a/asdf-augmenters/asdf-ghjk/docs/EXAMPLES.md +++ /dev/null @@ -1,617 +0,0 @@ -# Usage Examples - -This document provides real-world examples of using asdf-ghjk. - -## Table of Contents - -- [Basic Usage](#basic-usage) -- [Project Setup](#project-setup) -- [CI/CD Integration](#cicd-integration) -- [Multiple Projects](#multiple-projects) -- [Advanced Workflows](#advanced-workflows) - -## Basic Usage - -### Install and Use Latest Version - -```bash -# Install the plugin -asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git - -# Install latest ghjk -asdf install ghjk latest - -# Set as global default -asdf global ghjk latest - -# Verify installation -ghjk --version -``` - -### Install Specific Version - -```bash -# List all available versions -asdf list all ghjk - -# Install a specific version -asdf install ghjk 0.3.2 - -# Use it globally -asdf global ghjk 0.3.2 -``` - -## Project Setup - -### Initialize a New Project - -```bash -# Create project directory -mkdir my-project -cd my-project - -# Set local ghjk version -asdf local ghjk 0.3.2 - -# Initialize ghjk with TypeScript support -ghjk init ts - -# View generated configuration -cat ghjk.ts -``` - -### Basic Project Configuration - -Create a `ghjk.ts` file: - -```typescript -// ghjk.ts -export { sophon } from "https://deno.land/x/ghjk/mod.ts"; - -sophon({ - // Define environment variables - env: { - NODE_ENV: "development", - API_URL: "http://localhost:3000", - }, - - // Install development tools - installs: [ - { name: "node", version: "20.0.0" }, - { name: "python", version: "3.11" }, - ], - - // Define tasks - tasks: { - dev: "npm run dev", - test: "npm test", - build: "npm run build", - lint: "npm run lint", - }, -}); -``` - -### Activate Environment - -```bash -# Load the ghjk environment -ghjk env - -# Or run tasks directly -ghjk run dev -ghjk run test -``` - -## CI/CD Integration - -### GitHub Actions - -`.github/workflows/ci.yml`: - -```yaml -name: CI - -on: - push: - branches: [main] - pull_request: - branches: [main] - -jobs: - test: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Install asdf - uses: asdf-vm/actions/setup@v3 - - - name: Add ghjk plugin - run: | - asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git - - - name: Install ghjk from .tool-versions - run: | - asdf install ghjk - - - name: Run tests with ghjk - run: | - ghjk run test - - - name: Build with ghjk - run: | - ghjk run build -``` - -### GitLab CI - -`.gitlab-ci.yml`: - -```yaml -image: ubuntu:latest - -variables: - ASDF_DIR: "${CI_PROJECT_DIR}/.asdf" - ASDF_DATA_DIR: "${CI_PROJECT_DIR}/.asdf" - -before_script: - - apt-get update && apt-get install -y git curl tar unzip zstd - - git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.0 - - echo '. $HOME/.asdf/asdf.sh' >> ~/.bashrc - - source ~/.bashrc - - asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git - - asdf install - -test: - script: - - ghjk run test - -build: - script: - - ghjk run build - artifacts: - paths: - - dist/ -``` - -### CircleCI - -`.circleci/config.yml`: - -```yaml -version: 2.1 - -jobs: - test: - docker: - - image: cimg/base:stable - steps: - - checkout - - - run: - name: Install asdf - command: | - git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.0 - echo '. $HOME/.asdf/asdf.sh' >> $BASH_ENV - - - run: - name: Install ghjk - command: | - asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git - asdf install ghjk - - - run: - name: Run tests - command: ghjk run test - -workflows: - version: 2 - test: - jobs: - - test -``` - -## Multiple Projects - -### Different Versions per Project - -```bash -# Project A uses ghjk 0.3.2 -cd ~/projects/project-a -asdf local ghjk 0.3.2 -cat .tool-versions -# ghjk 0.3.2 - -# Project B uses latest ghjk -cd ~/projects/project-b -asdf local ghjk latest -cat .tool-versions -# ghjk 0.3.2 - -# asdf automatically switches versions when you cd -``` - -### Shared Configuration - -`~/.tool-versions` (global defaults): - -``` -ghjk 0.3.2 -nodejs 20.0.0 -python 3.11.0 -``` - -Project-specific overrides: - -```bash -cd my-project -asdf local ghjk 0.3.1 # Override just ghjk -# Other tools (nodejs, python) inherited from global -``` - -## Advanced Workflows - -### Multi-Environment Setup - -```typescript -// ghjk.ts -export { sophon } from "https://deno.land/x/ghjk/mod.ts"; - -const baseConfig = { - installs: [ - { name: "node", version: "20.0.0" }, - ], -}; - -const developmentConfig = { - ...baseConfig, - env: { - NODE_ENV: "development", - DEBUG: "true", - }, - tasks: { - dev: "npm run dev", - test: "npm test", - }, -}; - -const productionConfig = { - ...baseConfig, - env: { - NODE_ENV: "production", - }, - tasks: { - start: "npm start", - }, -}; - -// Use based on environment variable -const config = Deno.env.get("ENV") === "production" - ? productionConfig - : developmentConfig; - -sophon(config); -``` - -Usage: - -```bash -# Development -ghjk run dev - -# Production -ENV=production ghjk run start -``` - -### Monorepo Setup - -```typescript -// ghjk.ts (root) -export { sophon } from "https://deno.land/x/ghjk/mod.ts"; - -sophon({ - installs: [ - { name: "node", version: "20.0.0" }, - { name: "python", version: "3.11" }, - ], - - tasks: { - // Root tasks - "test:all": "npm run test --workspaces", - "build:all": "npm run build --workspaces", - "lint:all": "npm run lint --workspaces", - - // Frontend tasks - "dev:frontend": "npm run dev --workspace=packages/frontend", - "build:frontend": "npm run build --workspace=packages/frontend", - - // Backend tasks - "dev:backend": "npm run dev --workspace=packages/backend", - "build:backend": "npm run build --workspace=packages/backend", - - // Run both - dev: "concurrently 'ghjk run dev:frontend' 'ghjk run dev:backend'", - }, -}); -``` - -### Docker Integration - -`Dockerfile`: - -```dockerfile -FROM ubuntu:22.04 - -# Install system dependencies -RUN apt-get update && apt-get install -y \ - git curl tar unzip zstd \ - && rm -rf /var/lib/apt/lists/* - -# Install asdf -RUN git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.0 -ENV PATH="/root/.asdf/bin:/root/.asdf/shims:${PATH}" - -# Install ghjk plugin -RUN asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git - -# Copy project files -WORKDIR /app -COPY .tool-versions ./ -COPY ghjk.ts ./ - -# Install ghjk from .tool-versions -RUN asdf install - -# Install project dependencies -COPY package*.json ./ -RUN ghjk run install - -# Copy application code -COPY . . - -# Build application -RUN ghjk run build - -# Run application -CMD ["ghjk", "run", "start"] -``` - -### Testing Multiple Versions - -Test your project against multiple ghjk versions: - -```bash -#!/bin/bash -# test-versions.sh - -set -e - -versions=("0.3.0" "0.3.1" "0.3.2") - -for version in "${versions[@]}"; do - echo "Testing with ghjk $version" - - # Install version - asdf install ghjk "$version" - asdf local ghjk "$version" - - # Run tests - if ghjk run test; then - echo "✅ Tests passed with $version" - else - echo "❌ Tests failed with $version" - exit 1 - fi -done - -echo "All versions tested successfully!" -``` - -### Automatic Version Installation - -Add to your project's setup script: - -```bash -#!/bin/bash -# setup.sh - -set -e - -echo "Setting up project..." - -# Check if asdf is installed -if ! command -v asdf &> /dev/null; then - echo "Error: asdf is not installed" - echo "Install from: https://asdf-vm.com" - exit 1 -fi - -# Install ghjk plugin if not present -if ! asdf plugin list | grep -q ghjk; then - echo "Adding ghjk plugin..." - asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git -fi - -# Install tools from .tool-versions -echo "Installing tools..." -asdf install - -# Verify ghjk is working -echo "Verifying ghjk installation..." -ghjk --version - -# Install project dependencies -echo "Installing dependencies..." -ghjk run install - -echo "Setup complete! Run 'ghjk run dev' to start development" -``` - -### Shell Integration - -Add to your shell profile for convenience: - -```bash -# ~/.bashrc or ~/.zshrc - -# ghjk aliases -alias gd='ghjk run dev' -alias gt='ghjk run test' -alias gb='ghjk run build' -alias gl='ghjk run lint' - -# Quick ghjk version switching -ghjk-use() { - asdf local ghjk "$1" - echo "Switched to ghjk $1" - ghjk --version -} - -# List installed ghjk versions -alias ghjk-versions='asdf list ghjk' - -# Update to latest ghjk -ghjk-update() { - local latest - latest=$(asdf list all ghjk | tr ' ' '\n' | tail -1) - echo "Installing ghjk $latest..." - asdf install ghjk "$latest" - asdf global ghjk "$latest" - echo "Updated to ghjk $latest" -} -``` - -## Tips and Tricks - -### Cache GitHub API Responses - -Reduce API calls by caching: - -```bash -# Set a long-lived GitHub token -export GITHUB_API_TOKEN="ghp_your_token_here" - -# Or use conditional requests (plugin handles this) -``` - -### Parallel Installation - -Install multiple versions in parallel: - -```bash -# In separate terminals or with GNU parallel -asdf install ghjk 0.3.0 & -asdf install ghjk 0.3.1 & -asdf install ghjk 0.3.2 & -wait -``` - -### Backup and Restore - -Export your tool versions: - -```bash -# Backup -cp .tool-versions .tool-versions.backup - -# Restore -cp .tool-versions.backup .tool-versions -asdf install # Install all tools -``` - -### Automate Updates - -Create a cron job to check for updates: - -```bash -# check-ghjk-updates.sh -#!/bin/bash - -latest=$(asdf list all ghjk | tr ' ' '\n' | tail -1) -current=$(asdf current ghjk | awk '{print $2}') - -if [ "$latest" != "$current" ]; then - echo "New ghjk version available: $latest (current: $current)" - # Optionally auto-install or send notification -fi -``` - -## Real-World Examples - -### Full-Stack Web Application - -```typescript -// ghjk.ts -export { sophon } from "https://deno.land/x/ghjk/mod.ts"; - -sophon({ - env: { - DATABASE_URL: "postgresql://localhost/myapp_dev", - REDIS_URL: "redis://localhost:6379", - NODE_ENV: "development", - }, - - installs: [ - { name: "node", version: "20.0.0" }, - { name: "python", version: "3.11" }, - { name: "postgres", version: "15" }, - { name: "redis", version: "7" }, - ], - - tasks: { - // Database - "db:setup": "npm run db:migrate && npm run db:seed", - "db:reset": "npm run db:drop && npm run db:setup", - - // Development - dev: "concurrently 'npm run dev:frontend' 'npm run dev:backend'", - "dev:frontend": "cd frontend && npm run dev", - "dev:backend": "cd backend && npm run dev", - - // Testing - test: "npm run test:unit && npm run test:integration", - "test:unit": "npm run test --workspaces", - "test:e2e": "playwright test", - - // Production - build: "npm run build --workspaces", - start: "node backend/dist/server.js", - }, -}); -``` - -### Data Science Project - -```typescript -// ghjk.ts -export { sophon } from "https://deno.land/x/ghjk/mod.ts"; - -sophon({ - env: { - JUPYTER_PORT: "8888", - PYTHONPATH: "${PWD}/src", - }, - - installs: [ - { name: "python", version: "3.11" }, - { name: "jupyter", version: "latest" }, - ], - - tasks: { - notebook: "jupyter lab --port=$JUPYTER_PORT", - train: "python src/train.py", - evaluate: "python src/evaluate.py", - "export:model": "python src/export.py", - }, -}); -``` - -## Conclusion - -These examples demonstrate the flexibility and power of using ghjk with asdf. Adapt these patterns to your specific needs and workflow. - -For more information: -- [ghjk documentation](https://github.com/metatypedev/ghjk) -- [asdf documentation](https://asdf-vm.com) -- [Plugin README](https://github.com/Hyperpolymath/asdf-ghjk) diff --git a/asdf-augmenters/asdf-ghjk/docs/FAQ.adoc b/asdf-augmenters/asdf-ghjk/docs/FAQ.adoc new file mode 100644 index 00000000..6fb589b7 --- /dev/null +++ b/asdf-augmenters/asdf-ghjk/docs/FAQ.adoc @@ -0,0 +1,380 @@ +== Frequently Asked Questions (FAQ) + +Common questions about asdf-ghjk. + +=== General Questions + +==== What is asdf-ghjk? + +asdf-ghjk is an https://asdf-vm.com[asdf] plugin that allows you to +install and manage https://github.com/metatypedev/ghjk[ghjk] versions +using asdf’s version management system. + +==== What is ghjk? + +ghjk is a modern development environment manager that provides: - +Unified package management across multiple ecosystems (npm, PyPI, +crates.io, etc.) - TypeScript-based task automation - Reproducible POSIX +shell environments - Declarative configuration with inheritance + +Think of it as a successor to asdf with additional capabilities. + +==== Why use asdf-ghjk instead of installing ghjk directly? + +Using asdf-ghjk provides: - *Version Management*: Install and switch +between multiple ghjk versions - *Project-Specific Versions*: Different +projects can use different ghjk versions - *Consistent Tooling*: Use the +same version management approach for all your tools - *Easy Updates*: +Simple commands to update to the latest version - *No Global +Installation*: Avoids system-wide installation conflicts + +==== Is this an official plugin? + +No, this is a community-maintained plugin. For official ghjk support, +refer to the https://github.com/metatypedev/ghjk[ghjk repository]. + +=== Installation Questions + +==== How do I install the plugin? + +[source,bash] +---- +asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git +asdf install ghjk latest +asdf global ghjk latest +---- + +==== Do I need to install asdf first? + +Yes! This is an asdf plugin, so you need asdf installed first. Get it +from https://asdf-vm.com[asdf-vm.com]. + +==== What are the system requirements? + +*Required:* - Bash 4.0+ - curl - tar - grep, sort + +*For ghjk runtime:* - git - curl - tar - unzip - zstd + +==== Which platforms are supported? + +* Linux (x86_64, aarch64) +* macOS (x86_64, arm64/Apple Silicon) + +Windows is not currently supported (but may work with WSL). + +==== Can I install ghjk without root/sudo access? + +Yes! asdf and this plugin install everything in your home directory +(~/.asdf/). No root access required. + +=== Usage Questions + +==== How do I install a specific version? + +[source,bash] +---- +asdf install ghjk 0.3.2 +asdf global ghjk 0.3.2 +---- + +==== How do I update to the latest version? + +[source,bash] +---- +asdf install ghjk latest +asdf global ghjk latest +---- + +==== How do I switch between versions? + +[source,bash] +---- +# Set global version (all shells) +asdf global ghjk 0.3.2 + +# Set local version (current directory) +asdf local ghjk 0.3.1 + +# Use for single command +asdf shell ghjk 0.3.0 -- ghjk --version +---- + +==== How do I uninstall a version? + +[source,bash] +---- +asdf uninstall ghjk 0.3.1 +---- + +==== How do I list installed versions? + +[source,bash] +---- +# Installed versions +asdf list ghjk + +# All available versions +asdf list all ghjk + +# Current version +asdf current ghjk +---- + +=== Troubleshooting Questions + +==== Why am I getting "`GitHub API rate limit exceeded`"? + +GitHub limits unauthenticated API requests to 60 per hour. Set +`+GITHUB_API_TOKEN+` to increase the limit: + +[source,bash] +---- +export GITHUB_API_TOKEN="ghp_your_token_here" +---- + +Create a token at https://github.com/settings/tokens[GitHub Settings]. +No special permissions needed. + +==== Why is "`ghjk: command not found`"? + +Make sure asdf is properly configured: + +[source,bash] +---- +# Check asdf is in PATH +which asdf + +# Check ghjk is installed +asdf list ghjk + +# Reshim if needed +asdf reshim ghjk +---- + +Add to your shell profile if needed: + +[source,bash] +---- +# For bash +echo '. $HOME/.asdf/asdf.sh' >> ~/.bashrc + +# For zsh +echo '. $HOME/.asdf/asdf.sh' >> ~/.zshrc +---- + +==== Downloads are failing. What should I do? + +[arabic] +. Check your internet connection +. Check GitHub is accessible: `+curl -I https://github.com+` +. Try with debug mode: `+ASDF_DEBUG=1 asdf install ghjk +` +. Check the link:TROUBLESHOOTING.md[troubleshooting guide] + +==== How do I enable debug mode? + +[source,bash] +---- +export ASDF_DEBUG=1 +asdf install ghjk +---- + +==== Where are the logs? + +[source,bash] +---- +# asdf creates temporary logs +ls -lt ~/.asdf/tmp/ + +# View a specific log +cat ~/.asdf/tmp//install-ghjk-.log +---- + +=== Version Management Questions + +==== What does "`latest`" mean? + +"`latest`" refers to the most recent stable release of ghjk, as +published on GitHub releases. + +==== Can I install pre-release versions? + +Yes, pre-release versions (alpha, beta, rc) are available: + +[source,bash] +---- +asdf list all ghjk # Shows all versions including pre-releases +asdf install ghjk 0.3.1-rc.2 +---- + +==== Can I install from a Git commit or branch? + +Currently, no. The plugin only supports installing released versions. +This is intentional for stability. + +==== How do I pin a version for my project? + +Create a `+.tool-versions+` file: + +[source,bash] +---- +echo "ghjk 0.3.2" > .tool-versions +---- + +When anyone with asdf enters this directory, that version will be used. + +==== Can I use multiple versions simultaneously? + +Each shell session uses one version at a time, determined by: 1. +`+ASDF_GHJK_VERSION+` environment variable 2. `+.tool-versions+` in +current directory 3. `+.tool-versions+` in parent directories 4. +`+~/.tool-versions+` (global) + +You can run different versions in different terminals. + +=== Technical Questions + +==== Where are versions installed? + +[source,bash] +---- +~/.asdf/installs/ghjk// +---- + +==== Where are downloads cached? + +[source,bash] +---- +~/.asdf/downloads/ghjk// +---- + +==== How are checksums verified? + +The plugin extracts SHA256 checksums from GitHub release metadata and +verifies downloaded files. If no checksum is available, a warning is +shown but installation continues. + +==== Can I install from a mirror or alternative source? + +Not currently. The plugin only downloads from official GitHub releases +at `+github.com/metatypedev/ghjk+`. + +==== How does platform detection work? + +The plugin uses `+uname -s+` and `+uname -m+` to detect your OS and +architecture, then maps to ghjk’s platform naming: - Linux x86_64 → +`+x86_64-unknown-linux-gnu+` - Linux aarch64 → +`+aarch64-unknown-linux-gnu+` - macOS x86_64 → `+x86_64-apple-darwin+` - +macOS arm64 → `+aarch64-apple-darwin+` + +==== Is the plugin regularly updated? + +Updates are made as needed to support new ghjk versions, fix bugs, or +add features. The plugin itself doesn’t need frequent updates since it +downloads ghjk releases dynamically. + +=== Integration Questions + +==== Can I use this in CI/CD? + +Yes! See the link:EXAMPLES.md[examples documentation] for GitHub +Actions, GitLab CI, and CircleCI examples. + +==== Can I use this with Docker? + +Yes! Install asdf and the plugin in your Dockerfile. See +link:EXAMPLES.md#docker-integration[examples]. + +==== Does this work with direnv? + +Yes, asdf integrates with direnv. Configure direnv to use asdf versions. + +==== Can I use this with other asdf plugins? + +Absolutely! That’s the whole point of asdf. You can manage ghjk, +Node.js, Python, Ruby, etc., all with asdf. + +=== Development Questions + +==== How can I contribute? + +See link:../CONTRIBUTING.md[CONTRIBUTING.md] for contribution +guidelines. + +==== How do I test my changes? + +[source,bash] +---- +# Set up development environment +./scripts/setup-dev.sh + +# Run tests +./scripts/test.sh + +# Or use Make +make test +---- + +==== How do I report bugs? + +Open an issue on +https://github.com/Hyperpolymath/asdf-ghjk/issues[GitHub] using the bug +report template. + +==== How do I request features? + +Open an issue on +https://github.com/Hyperpolymath/asdf-ghjk/issues[GitHub] using the +feature request template. + +=== Comparison Questions + +==== How is this different from using ghjk’s installer? + +[width="100%",cols="24%,45%,31%",options="header",] +|=== +|Aspect |ghjk Installer |asdf-ghjk +|Version Management |Single global version |Multiple versions +|Switching Versions |Manual reinstall |`+asdf global/local+` +|Project-Specific |Manual per-project |Automatic via `+.tool-versions+` +|Updates |Manual download |`+asdf install ghjk latest+` +|Tool Ecosystem |Standalone |Part of asdf ecosystem +|=== + +==== Should I use asdf-ghjk or standalone ghjk? + +*Use asdf-ghjk if:* - You already use asdf for other tools - You need +multiple ghjk versions - You want project-specific versions - You want +consistent version management + +*Use standalone ghjk if:* - You only need one ghjk version - You don’t +use asdf - You prefer ghjk’s native installation + +==== Can I use both? + +Not recommended. Stick with one installation method to avoid conflicts. + +=== Getting Help + +==== Where can I get help? + +[arabic] +. Check this FAQ +. Read the link:TROUBLESHOOTING.md[troubleshooting guide] +. Check https://github.com/Hyperpolymath/asdf-ghjk/issues[existing +issues] +. Open a https://github.com/Hyperpolymath/asdf-ghjk/issues/new[new +issue] +. Consult https://asdf-vm.com[asdf documentation] +. Consult https://github.com/metatypedev/ghjk[ghjk documentation] + +==== Is there a community? + +* *asdf*: https://github.com/asdf-vm/asdf/discussions[GitHub +Discussions] +* *ghjk*: https://github.com/metatypedev/ghjk[GitHub Issues/Discussions] +* *This Plugin*: +https://github.com/Hyperpolymath/asdf-ghjk/issues[GitHub Issues] + +''''' + +*Still have questions?* Open an issue or discussion on GitHub! diff --git a/asdf-augmenters/asdf-ghjk/docs/FAQ.md b/asdf-augmenters/asdf-ghjk/docs/FAQ.md deleted file mode 100644 index 981ca926..00000000 --- a/asdf-augmenters/asdf-ghjk/docs/FAQ.md +++ /dev/null @@ -1,349 +0,0 @@ -# Frequently Asked Questions (FAQ) - -Common questions about asdf-ghjk. - -## General Questions - -### What is asdf-ghjk? - -asdf-ghjk is an [asdf](https://asdf-vm.com) plugin that allows you to install and manage [ghjk](https://github.com/metatypedev/ghjk) versions using asdf's version management system. - -### What is ghjk? - -ghjk is a modern development environment manager that provides: -- Unified package management across multiple ecosystems (npm, PyPI, crates.io, etc.) -- TypeScript-based task automation -- Reproducible POSIX shell environments -- Declarative configuration with inheritance - -Think of it as a successor to asdf with additional capabilities. - -### Why use asdf-ghjk instead of installing ghjk directly? - -Using asdf-ghjk provides: -- **Version Management**: Install and switch between multiple ghjk versions -- **Project-Specific Versions**: Different projects can use different ghjk versions -- **Consistent Tooling**: Use the same version management approach for all your tools -- **Easy Updates**: Simple commands to update to the latest version -- **No Global Installation**: Avoids system-wide installation conflicts - -### Is this an official plugin? - -No, this is a community-maintained plugin. For official ghjk support, refer to the [ghjk repository](https://github.com/metatypedev/ghjk). - -## Installation Questions - -### How do I install the plugin? - -```bash -asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git -asdf install ghjk latest -asdf global ghjk latest -``` - -### Do I need to install asdf first? - -Yes! This is an asdf plugin, so you need asdf installed first. Get it from [asdf-vm.com](https://asdf-vm.com). - -### What are the system requirements? - -**Required:** -- Bash 4.0+ -- curl -- tar -- grep, sort - -**For ghjk runtime:** -- git -- curl -- tar -- unzip -- zstd - -### Which platforms are supported? - -- Linux (x86_64, aarch64) -- macOS (x86_64, arm64/Apple Silicon) - -Windows is not currently supported (but may work with WSL). - -### Can I install ghjk without root/sudo access? - -Yes! asdf and this plugin install everything in your home directory (~/.asdf/). No root access required. - -## Usage Questions - -### How do I install a specific version? - -```bash -asdf install ghjk 0.3.2 -asdf global ghjk 0.3.2 -``` - -### How do I update to the latest version? - -```bash -asdf install ghjk latest -asdf global ghjk latest -``` - -### How do I switch between versions? - -```bash -# Set global version (all shells) -asdf global ghjk 0.3.2 - -# Set local version (current directory) -asdf local ghjk 0.3.1 - -# Use for single command -asdf shell ghjk 0.3.0 -- ghjk --version -``` - -### How do I uninstall a version? - -```bash -asdf uninstall ghjk 0.3.1 -``` - -### How do I list installed versions? - -```bash -# Installed versions -asdf list ghjk - -# All available versions -asdf list all ghjk - -# Current version -asdf current ghjk -``` - -## Troubleshooting Questions - -### Why am I getting "GitHub API rate limit exceeded"? - -GitHub limits unauthenticated API requests to 60 per hour. Set `GITHUB_API_TOKEN` to increase the limit: - -```bash -export GITHUB_API_TOKEN="ghp_your_token_here" -``` - -Create a token at [GitHub Settings](https://github.com/settings/tokens). No special permissions needed. - -### Why is "ghjk: command not found"? - -Make sure asdf is properly configured: - -```bash -# Check asdf is in PATH -which asdf - -# Check ghjk is installed -asdf list ghjk - -# Reshim if needed -asdf reshim ghjk -``` - -Add to your shell profile if needed: - -```bash -# For bash -echo '. $HOME/.asdf/asdf.sh' >> ~/.bashrc - -# For zsh -echo '. $HOME/.asdf/asdf.sh' >> ~/.zshrc -``` - -### Downloads are failing. What should I do? - -1. Check your internet connection -2. Check GitHub is accessible: `curl -I https://github.com` -3. Try with debug mode: `ASDF_DEBUG=1 asdf install ghjk ` -4. Check the [troubleshooting guide](TROUBLESHOOTING.md) - -### How do I enable debug mode? - -```bash -export ASDF_DEBUG=1 -asdf install ghjk -``` - -### Where are the logs? - -```bash -# asdf creates temporary logs -ls -lt ~/.asdf/tmp/ - -# View a specific log -cat ~/.asdf/tmp//install-ghjk-.log -``` - -## Version Management Questions - -### What does "latest" mean? - -"latest" refers to the most recent stable release of ghjk, as published on GitHub releases. - -### Can I install pre-release versions? - -Yes, pre-release versions (alpha, beta, rc) are available: - -```bash -asdf list all ghjk # Shows all versions including pre-releases -asdf install ghjk 0.3.1-rc.2 -``` - -### Can I install from a Git commit or branch? - -Currently, no. The plugin only supports installing released versions. This is intentional for stability. - -### How do I pin a version for my project? - -Create a `.tool-versions` file: - -```bash -echo "ghjk 0.3.2" > .tool-versions -``` - -When anyone with asdf enters this directory, that version will be used. - -### Can I use multiple versions simultaneously? - -Each shell session uses one version at a time, determined by: -1. `ASDF_GHJK_VERSION` environment variable -2. `.tool-versions` in current directory -3. `.tool-versions` in parent directories -4. `~/.tool-versions` (global) - -You can run different versions in different terminals. - -## Technical Questions - -### Where are versions installed? - -```bash -~/.asdf/installs/ghjk// -``` - -### Where are downloads cached? - -```bash -~/.asdf/downloads/ghjk// -``` - -### How are checksums verified? - -The plugin extracts SHA256 checksums from GitHub release metadata and verifies downloaded files. If no checksum is available, a warning is shown but installation continues. - -### Can I install from a mirror or alternative source? - -Not currently. The plugin only downloads from official GitHub releases at `github.com/metatypedev/ghjk`. - -### How does platform detection work? - -The plugin uses `uname -s` and `uname -m` to detect your OS and architecture, then maps to ghjk's platform naming: -- Linux x86_64 → `x86_64-unknown-linux-gnu` -- Linux aarch64 → `aarch64-unknown-linux-gnu` -- macOS x86_64 → `x86_64-apple-darwin` -- macOS arm64 → `aarch64-apple-darwin` - -### Is the plugin regularly updated? - -Updates are made as needed to support new ghjk versions, fix bugs, or add features. The plugin itself doesn't need frequent updates since it downloads ghjk releases dynamically. - -## Integration Questions - -### Can I use this in CI/CD? - -Yes! See the [examples documentation](EXAMPLES.md) for GitHub Actions, GitLab CI, and CircleCI examples. - -### Can I use this with Docker? - -Yes! Install asdf and the plugin in your Dockerfile. See [examples](EXAMPLES.md#docker-integration). - -### Does this work with direnv? - -Yes, asdf integrates with direnv. Configure direnv to use asdf versions. - -### Can I use this with other asdf plugins? - -Absolutely! That's the whole point of asdf. You can manage ghjk, Node.js, Python, Ruby, etc., all with asdf. - -## Development Questions - -### How can I contribute? - -See [CONTRIBUTING.md](../CONTRIBUTING.md) for contribution guidelines. - -### How do I test my changes? - -```bash -# Set up development environment -./scripts/setup-dev.sh - -# Run tests -./scripts/test.sh - -# Or use Make -make test -``` - -### How do I report bugs? - -Open an issue on [GitHub](https://github.com/Hyperpolymath/asdf-ghjk/issues) using the bug report template. - -### How do I request features? - -Open an issue on [GitHub](https://github.com/Hyperpolymath/asdf-ghjk/issues) using the feature request template. - -## Comparison Questions - -### How is this different from using ghjk's installer? - -| Aspect | ghjk Installer | asdf-ghjk | -|--------|----------------|-----------| -| Version Management | Single global version | Multiple versions | -| Switching Versions | Manual reinstall | `asdf global/local` | -| Project-Specific | Manual per-project | Automatic via `.tool-versions` | -| Updates | Manual download | `asdf install ghjk latest` | -| Tool Ecosystem | Standalone | Part of asdf ecosystem | - -### Should I use asdf-ghjk or standalone ghjk? - -**Use asdf-ghjk if:** -- You already use asdf for other tools -- You need multiple ghjk versions -- You want project-specific versions -- You want consistent version management - -**Use standalone ghjk if:** -- You only need one ghjk version -- You don't use asdf -- You prefer ghjk's native installation - -### Can I use both? - -Not recommended. Stick with one installation method to avoid conflicts. - -## Getting Help - -### Where can I get help? - -1. Check this FAQ -2. Read the [troubleshooting guide](TROUBLESHOOTING.md) -3. Check [existing issues](https://github.com/Hyperpolymath/asdf-ghjk/issues) -4. Open a [new issue](https://github.com/Hyperpolymath/asdf-ghjk/issues/new) -5. Consult [asdf documentation](https://asdf-vm.com) -6. Consult [ghjk documentation](https://github.com/metatypedev/ghjk) - -### Is there a community? - -- **asdf**: [GitHub Discussions](https://github.com/asdf-vm/asdf/discussions) -- **ghjk**: [GitHub Issues/Discussions](https://github.com/metatypedev/ghjk) -- **This Plugin**: [GitHub Issues](https://github.com/Hyperpolymath/asdf-ghjk/issues) - ---- - -**Still have questions?** Open an issue or discussion on GitHub! diff --git a/asdf-augmenters/asdf-ghjk/docs/MIGRATION.adoc b/asdf-augmenters/asdf-ghjk/docs/MIGRATION.adoc new file mode 100644 index 00000000..e4f54437 --- /dev/null +++ b/asdf-augmenters/asdf-ghjk/docs/MIGRATION.adoc @@ -0,0 +1,518 @@ +== Migration Guide + +This guide helps you migrate from standalone ghjk installation to +asdf-ghjk. + +=== Table of Contents + +* link:#why-migrate[Why Migrate] +* link:#before-you-begin[Before You Begin] +* link:#migration-steps[Migration Steps] +* link:#verification[Verification] +* link:#rollback[Rollback] +* link:#common-issues[Common Issues] + +=== Why Migrate + +Migrating to asdf-ghjk provides: + +* *Version Management*: Install and switch between multiple ghjk +versions +* *Project-Specific Versions*: Different projects can use different ghjk +versions +* *Consistent Tooling*: Use asdf for all your development tools +* *Easy Updates*: Simple commands to update to latest versions +* *Better CI/CD Integration*: Standard approach across projects + +=== Before You Begin + +==== Check Your Current Installation + +[source,bash] +---- +# Find where ghjk is currently installed +which ghjk + +# Check your current version +ghjk --version + +# See if ghjk is managing other tools +ghjk env +---- + +==== Backup Your Configuration + +[source,bash] +---- +# Backup your ghjk configuration files +cp ghjk.ts ghjk.ts.backup + +# Backup any environment configurations +cp .env .env.backup 2>/dev/null || true +---- + +==== Prerequisites + +Ensure you have: + +[arabic] +. *asdf installed* - +https://asdf-vm.com/guide/getting-started.html[Installation guide] +. *System dependencies*: git, curl, tar +. *Shell properly configured* for asdf + +=== Migration Steps + +==== Step 1: Note Your Current Version + +[source,bash] +---- +# Record your current ghjk version +CURRENT_GHJK_VERSION=$(ghjk --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1) +echo "Current version: $CURRENT_GHJK_VERSION" +---- + +==== Step 2: Remove Standalone Installation + +===== If Installed via Official Installer + +[source,bash] +---- +# The official installer typically installs to one of these locations: +# - ~/.ghjk/ +# - /usr/local/bin/ghjk +# - ~/bin/ghjk + +# Check and remove +rm -rf ~/.ghjk +sudo rm -f /usr/local/bin/ghjk +rm -f ~/bin/ghjk +---- + +===== Clean Up Shell Profile + +Remove ghjk-related lines from your shell profile: + +[source,bash] +---- +# Edit your profile +nano ~/.bashrc # or ~/.zshrc, ~/.bash_profile, etc. + +# Remove lines like: +# export PATH="$HOME/.ghjk/bin:$PATH" +# source ~/.ghjk/env.sh +# etc. + +# Reload your shell +source ~/.bashrc +---- + +==== Step 3: Install asdf-ghjk Plugin + +[source,bash] +---- +# Add the plugin +asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git + +# Verify plugin was added +asdf plugin list | grep ghjk +---- + +==== Step 4: Install Your Version + +[source,bash] +---- +# Option A: Install the same version you were using +asdf install ghjk $CURRENT_GHJK_VERSION +asdf global ghjk $CURRENT_GHJK_VERSION + +# Option B: Install latest stable +asdf install ghjk latest +asdf global ghjk latest + +# Option C: Install specific version +asdf install ghjk 0.3.2 +asdf global ghjk 0.3.2 +---- + +==== Step 5: Verify Installation + +[source,bash] +---- +# Check that ghjk is available +which ghjk +# Should show: ~/.asdf/shims/ghjk + +# Verify version +ghjk --version + +# Test basic functionality +ghjk --help +---- + +==== Step 6: Update Project Configuration + +For each project using ghjk: + +[source,bash] +---- +cd your-project + +# Create .tool-versions file +echo "ghjk $CURRENT_GHJK_VERSION" > .tool-versions + +# Or use asdf local command +asdf local ghjk $CURRENT_GHJK_VERSION + +# Verify +cat .tool-versions +---- + +==== Step 7: Test Your Projects + +[source,bash] +---- +cd your-project + +# Test ghjk commands +ghjk env +ghjk run + +# Verify everything works as before +---- + +=== Project-by-Project Migration + +If you have multiple projects, migrate them individually: + +[source,bash] +---- +#!/bin/bash +# migrate-projects.sh + +PROJECTS=( + ~/projects/project-a + ~/projects/project-b + ~/projects/project-c +) + +GHJK_VERSION="0.3.2" # or use latest + +for project in "${PROJECTS[@]}"; do + if [ -f "$project/ghjk.ts" ]; then + echo "Migrating $project..." + cd "$project" + + # Create .tool-versions + echo "ghjk $GHJK_VERSION" > .tool-versions + + # Test + if ghjk --version &>/dev/null; then + echo "✅ $project migrated successfully" + else + echo "❌ $project migration failed" + fi + fi +done +---- + +=== Verification + +==== Verify asdf Setup + +[source,bash] +---- +# Check asdf is working +asdf --version + +# Check ghjk plugin +asdf plugin list | grep ghjk + +# List installed ghjk versions +asdf list ghjk + +# Check current version +asdf current ghjk +---- + +==== Verify ghjk Functionality + +[source,bash] +---- +# Basic commands should work +ghjk --version +ghjk --help + +# Project commands should work +cd your-project +ghjk env +ghjk run +---- + +==== Verify PATH + +[source,bash] +---- +# ghjk should come from asdf +which ghjk +# Expected: ~/.asdf/shims/ghjk + +# Check it's executable +test -x "$(which ghjk)" && echo "✅ Executable" || echo "❌ Not executable" +---- + +=== Rollback + +If you need to revert the migration: + +==== Remove asdf-ghjk + +[source,bash] +---- +# Uninstall all ghjk versions +asdf uninstall ghjk --all + +# Remove plugin +asdf plugin remove ghjk +---- + +==== Reinstall Standalone + +[source,bash] +---- +# Use ghjk's official installer +curl -fsSL https://ghjk.deno.dev/install.sh | sh + +# Or download specific version manually +# See: https://github.com/metatypedev/ghjk/releases +---- + +==== Restore Configuration + +[source,bash] +---- +# Restore backed up files +cp ghjk.ts.backup ghjk.ts +cp .env.backup .env 2>/dev/null || true + +# Remove .tool-versions files if you added them +find ~/projects -name .tool-versions -exec grep -l "^ghjk" {} \; -delete +---- + +=== Common Issues + +==== Issue: "`ghjk: command not found`" After Migration + +*Cause*: Shell hasn’t picked up asdf’s shims + +*Solution*: + +[source,bash] +---- +# Reload shell configuration +source ~/.bashrc # or ~/.zshrc + +# Or restart your terminal + +# Reshim asdf +asdf reshim +---- + +==== Issue: Wrong Version Being Used + +*Cause*: Version precedence confusion + +*Solution*: + +[source,bash] +---- +# Check which version is active and why +asdf current ghjk + +# Set explicitly +asdf local ghjk 0.3.2 # For current project +asdf global ghjk 0.3.2 # For all projects +---- + +==== Issue: ghjk Commands Failing + +*Cause*: Missing runtime dependencies + +*Solution*: + +[source,bash] +---- +# Install ghjk runtime dependencies +# Ubuntu/Debian +sudo apt-get install git curl tar unzip zstd + +# macOS +brew install git curl tar unzip zstd +---- + +==== Issue: Different Behavior After Migration + +*Cause*: Different version or configuration + +*Solution*: + +[source,bash] +---- +# Ensure exact same version +asdf install ghjk $OLD_VERSION +asdf global ghjk $OLD_VERSION + +# Compare configurations +diff ghjk.ts ghjk.ts.backup +---- + +=== Advanced Migration Scenarios + +==== Migrating from System Package + +If ghjk was installed via package manager: + +[source,bash] +---- +# Ubuntu/Debian +sudo apt-get remove ghjk + +# Homebrew +brew uninstall ghjk + +# Then follow standard migration steps +---- + +==== Migrating CI/CD + +Update your CI/CD configuration: + +*Before (standalone ghjk):* + +[source,yaml] +---- +- name: Install ghjk + run: curl -fsSL https://ghjk.deno.dev/install.sh | sh +---- + +*After (asdf-ghjk):* + +[source,yaml] +---- +- name: Install asdf + uses: asdf-vm/actions/setup@v3 + +- name: Install ghjk + run: | + asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git + asdf install ghjk +---- + +==== Migrating Docker + +*Before:* + +[source,dockerfile] +---- +RUN curl -fsSL https://ghjk.deno.dev/install.sh | sh +ENV PATH="/root/.ghjk/bin:${PATH}" +---- + +*After:* + +[source,dockerfile] +---- +RUN git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.0 +ENV PATH="/root/.asdf/bin:/root/.asdf/shims:${PATH}" +RUN asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git +COPY .tool-versions . +RUN asdf install +---- + +=== Best Practices Post-Migration + +==== Use .tool-versions + +Create `+.tool-versions+` in each project: + +.... +ghjk 0.3.2 +nodejs 20.0.0 +python 3.11.0 +.... + +==== Pin Versions in Version Control + +[source,bash] +---- +# Commit .tool-versions to git +git add .tool-versions +git commit -m "chore: pin ghjk version" +---- + +==== Document the Migration + +Add to your project’s README: + +[source,markdown] +---- +## Development Setup + +This project uses asdf for version management. + +### Prerequisites +- [asdf](https://asdf-vm.com) + +### Installation +\`\`\`bash +asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git +asdf install # Installs versions from .tool-versions +\`\`\` +---- + +==== Team Communication + +Inform your team: + +[source,markdown] +---- +# Migration to asdf-ghjk + +We've migrated from standalone ghjk to asdf-ghjk for better version management. + +**Action Required:** +1. Install asdf: https://asdf-vm.com +2. Run: `asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git` +3. Run: `asdf install` + +**Benefits:** +- Multiple ghjk versions supported +- Automatic version switching per project +- Consistent with other tools (Node.js, Python, etc.) +---- + +=== Getting Help + +If you encounter issues during migration: + +[arabic] +. Check the link:TROUBLESHOOTING.md[troubleshooting guide] +. Check the link:FAQ.md[FAQ] +. Open an https://github.com/Hyperpolymath/asdf-ghjk/issues[issue] + +=== Success Checklist + +* [ ] Standalone ghjk removed +* [ ] asdf-ghjk plugin installed +* [ ] Correct version(s) installed +* [ ] `+which ghjk+` points to asdf shims +* [ ] All projects have `+.tool-versions+` +* [ ] All projects tested and working +* [ ] CI/CD updated +* [ ] Team notified +* [ ] Documentation updated + +''''' + +*Migration complete!* You’re now using asdf-ghjk for better version +management. diff --git a/asdf-augmenters/asdf-ghjk/docs/MIGRATION.md b/asdf-augmenters/asdf-ghjk/docs/MIGRATION.md deleted file mode 100644 index 8d86c500..00000000 --- a/asdf-augmenters/asdf-ghjk/docs/MIGRATION.md +++ /dev/null @@ -1,482 +0,0 @@ -# Migration Guide - -This guide helps you migrate from standalone ghjk installation to asdf-ghjk. - -## Table of Contents - -- [Why Migrate](#why-migrate) -- [Before You Begin](#before-you-begin) -- [Migration Steps](#migration-steps) -- [Verification](#verification) -- [Rollback](#rollback) -- [Common Issues](#common-issues) - -## Why Migrate - -Migrating to asdf-ghjk provides: - -- **Version Management**: Install and switch between multiple ghjk versions -- **Project-Specific Versions**: Different projects can use different ghjk versions -- **Consistent Tooling**: Use asdf for all your development tools -- **Easy Updates**: Simple commands to update to latest versions -- **Better CI/CD Integration**: Standard approach across projects - -## Before You Begin - -### Check Your Current Installation - -```bash -# Find where ghjk is currently installed -which ghjk - -# Check your current version -ghjk --version - -# See if ghjk is managing other tools -ghjk env -``` - -### Backup Your Configuration - -```bash -# Backup your ghjk configuration files -cp ghjk.ts ghjk.ts.backup - -# Backup any environment configurations -cp .env .env.backup 2>/dev/null || true -``` - -### Prerequisites - -Ensure you have: - -1. **asdf installed** - [Installation guide](https://asdf-vm.com/guide/getting-started.html) -2. **System dependencies**: git, curl, tar -3. **Shell properly configured** for asdf - -## Migration Steps - -### Step 1: Note Your Current Version - -```bash -# Record your current ghjk version -CURRENT_GHJK_VERSION=$(ghjk --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1) -echo "Current version: $CURRENT_GHJK_VERSION" -``` - -### Step 2: Remove Standalone Installation - -#### If Installed via Official Installer - -```bash -# The official installer typically installs to one of these locations: -# - ~/.ghjk/ -# - /usr/local/bin/ghjk -# - ~/bin/ghjk - -# Check and remove -rm -rf ~/.ghjk -sudo rm -f /usr/local/bin/ghjk -rm -f ~/bin/ghjk -``` - -#### Clean Up Shell Profile - -Remove ghjk-related lines from your shell profile: - -```bash -# Edit your profile -nano ~/.bashrc # or ~/.zshrc, ~/.bash_profile, etc. - -# Remove lines like: -# export PATH="$HOME/.ghjk/bin:$PATH" -# source ~/.ghjk/env.sh -# etc. - -# Reload your shell -source ~/.bashrc -``` - -### Step 3: Install asdf-ghjk Plugin - -```bash -# Add the plugin -asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git - -# Verify plugin was added -asdf plugin list | grep ghjk -``` - -### Step 4: Install Your Version - -```bash -# Option A: Install the same version you were using -asdf install ghjk $CURRENT_GHJK_VERSION -asdf global ghjk $CURRENT_GHJK_VERSION - -# Option B: Install latest stable -asdf install ghjk latest -asdf global ghjk latest - -# Option C: Install specific version -asdf install ghjk 0.3.2 -asdf global ghjk 0.3.2 -``` - -### Step 5: Verify Installation - -```bash -# Check that ghjk is available -which ghjk -# Should show: ~/.asdf/shims/ghjk - -# Verify version -ghjk --version - -# Test basic functionality -ghjk --help -``` - -### Step 6: Update Project Configuration - -For each project using ghjk: - -```bash -cd your-project - -# Create .tool-versions file -echo "ghjk $CURRENT_GHJK_VERSION" > .tool-versions - -# Or use asdf local command -asdf local ghjk $CURRENT_GHJK_VERSION - -# Verify -cat .tool-versions -``` - -### Step 7: Test Your Projects - -```bash -cd your-project - -# Test ghjk commands -ghjk env -ghjk run - -# Verify everything works as before -``` - -## Project-by-Project Migration - -If you have multiple projects, migrate them individually: - -```bash -#!/bin/bash -# migrate-projects.sh - -PROJECTS=( - ~/projects/project-a - ~/projects/project-b - ~/projects/project-c -) - -GHJK_VERSION="0.3.2" # or use latest - -for project in "${PROJECTS[@]}"; do - if [ -f "$project/ghjk.ts" ]; then - echo "Migrating $project..." - cd "$project" - - # Create .tool-versions - echo "ghjk $GHJK_VERSION" > .tool-versions - - # Test - if ghjk --version &>/dev/null; then - echo "✅ $project migrated successfully" - else - echo "❌ $project migration failed" - fi - fi -done -``` - -## Verification - -### Verify asdf Setup - -```bash -# Check asdf is working -asdf --version - -# Check ghjk plugin -asdf plugin list | grep ghjk - -# List installed ghjk versions -asdf list ghjk - -# Check current version -asdf current ghjk -``` - -### Verify ghjk Functionality - -```bash -# Basic commands should work -ghjk --version -ghjk --help - -# Project commands should work -cd your-project -ghjk env -ghjk run -``` - -### Verify PATH - -```bash -# ghjk should come from asdf -which ghjk -# Expected: ~/.asdf/shims/ghjk - -# Check it's executable -test -x "$(which ghjk)" && echo "✅ Executable" || echo "❌ Not executable" -``` - -## Rollback - -If you need to revert the migration: - -### Remove asdf-ghjk - -```bash -# Uninstall all ghjk versions -asdf uninstall ghjk --all - -# Remove plugin -asdf plugin remove ghjk -``` - -### Reinstall Standalone - -```bash -# Use ghjk's official installer -curl -fsSL https://ghjk.deno.dev/install.sh | sh - -# Or download specific version manually -# See: https://github.com/metatypedev/ghjk/releases -``` - -### Restore Configuration - -```bash -# Restore backed up files -cp ghjk.ts.backup ghjk.ts -cp .env.backup .env 2>/dev/null || true - -# Remove .tool-versions files if you added them -find ~/projects -name .tool-versions -exec grep -l "^ghjk" {} \; -delete -``` - -## Common Issues - -### Issue: "ghjk: command not found" After Migration - -**Cause**: Shell hasn't picked up asdf's shims - -**Solution**: - -```bash -# Reload shell configuration -source ~/.bashrc # or ~/.zshrc - -# Or restart your terminal - -# Reshim asdf -asdf reshim -``` - -### Issue: Wrong Version Being Used - -**Cause**: Version precedence confusion - -**Solution**: - -```bash -# Check which version is active and why -asdf current ghjk - -# Set explicitly -asdf local ghjk 0.3.2 # For current project -asdf global ghjk 0.3.2 # For all projects -``` - -### Issue: ghjk Commands Failing - -**Cause**: Missing runtime dependencies - -**Solution**: - -```bash -# Install ghjk runtime dependencies -# Ubuntu/Debian -sudo apt-get install git curl tar unzip zstd - -# macOS -brew install git curl tar unzip zstd -``` - -### Issue: Different Behavior After Migration - -**Cause**: Different version or configuration - -**Solution**: - -```bash -# Ensure exact same version -asdf install ghjk $OLD_VERSION -asdf global ghjk $OLD_VERSION - -# Compare configurations -diff ghjk.ts ghjk.ts.backup -``` - -## Advanced Migration Scenarios - -### Migrating from System Package - -If ghjk was installed via package manager: - -```bash -# Ubuntu/Debian -sudo apt-get remove ghjk - -# Homebrew -brew uninstall ghjk - -# Then follow standard migration steps -``` - -### Migrating CI/CD - -Update your CI/CD configuration: - -**Before (standalone ghjk):** - -```yaml -- name: Install ghjk - run: curl -fsSL https://ghjk.deno.dev/install.sh | sh -``` - -**After (asdf-ghjk):** - -```yaml -- name: Install asdf - uses: asdf-vm/actions/setup@v3 - -- name: Install ghjk - run: | - asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git - asdf install ghjk -``` - -### Migrating Docker - -**Before:** - -```dockerfile -RUN curl -fsSL https://ghjk.deno.dev/install.sh | sh -ENV PATH="/root/.ghjk/bin:${PATH}" -``` - -**After:** - -```dockerfile -RUN git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.0 -ENV PATH="/root/.asdf/bin:/root/.asdf/shims:${PATH}" -RUN asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git -COPY .tool-versions . -RUN asdf install -``` - -## Best Practices Post-Migration - -### Use .tool-versions - -Create `.tool-versions` in each project: - -``` -ghjk 0.3.2 -nodejs 20.0.0 -python 3.11.0 -``` - -### Pin Versions in Version Control - -```bash -# Commit .tool-versions to git -git add .tool-versions -git commit -m "chore: pin ghjk version" -``` - -### Document the Migration - -Add to your project's README: - -```markdown -## Development Setup - -This project uses asdf for version management. - -### Prerequisites -- [asdf](https://asdf-vm.com) - -### Installation -\`\`\`bash -asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git -asdf install # Installs versions from .tool-versions -\`\`\` -``` - -### Team Communication - -Inform your team: - -```markdown -# Migration to asdf-ghjk - -We've migrated from standalone ghjk to asdf-ghjk for better version management. - -**Action Required:** -1. Install asdf: https://asdf-vm.com -2. Run: `asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git` -3. Run: `asdf install` - -**Benefits:** -- Multiple ghjk versions supported -- Automatic version switching per project -- Consistent with other tools (Node.js, Python, etc.) -``` - -## Getting Help - -If you encounter issues during migration: - -1. Check the [troubleshooting guide](TROUBLESHOOTING.md) -2. Check the [FAQ](FAQ.md) -3. Open an [issue](https://github.com/Hyperpolymath/asdf-ghjk/issues) - -## Success Checklist - -- [ ] Standalone ghjk removed -- [ ] asdf-ghjk plugin installed -- [ ] Correct version(s) installed -- [ ] `which ghjk` points to asdf shims -- [ ] All projects have `.tool-versions` -- [ ] All projects tested and working -- [ ] CI/CD updated -- [ ] Team notified -- [ ] Documentation updated - ---- - -**Migration complete!** You're now using asdf-ghjk for better version management. diff --git a/asdf-augmenters/asdf-ghjk/docs/QUICKSTART.adoc b/asdf-augmenters/asdf-ghjk/docs/QUICKSTART.adoc new file mode 100644 index 00000000..93438bb8 --- /dev/null +++ b/asdf-augmenters/asdf-ghjk/docs/QUICKSTART.adoc @@ -0,0 +1,202 @@ +== Quick Start Guide + +Get up and running with asdf-ghjk in 5 minutes. + +=== Prerequisites + +Before you begin, install: + +[arabic] +. *asdf* - https://asdf-vm.com/guide/getting-started.html[Installation +guide] +. *System dependencies*: git, curl, tar + +[source,bash] +---- +# Ubuntu/Debian +sudo apt-get install git curl tar + +# macOS +brew install git curl tar +---- + +=== Installation (30 seconds) + +[source,bash] +---- +# 1. Add the plugin +asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git + +# 2. Install latest version +asdf install ghjk latest + +# 3. Set as default +asdf global ghjk latest + +# 4. Verify +ghjk --version +---- + +Done! 🎉 + +=== Your First ghjk Project (2 minutes) + +[source,bash] +---- +# 1. Create a new project +mkdir my-project +cd my-project + +# 2. Pin ghjk version for this project +asdf local ghjk latest + +# 3. Initialize ghjk +ghjk init ts + +# 4. View the generated config +cat ghjk.ts +---- + +You now have a `+ghjk.ts+` configuration file! + +=== Basic Configuration (1 minute) + +Edit `+ghjk.ts+`: + +[source,typescript] +---- +export { sophon } from "https://deno.land/x/ghjk/mod.ts"; + +sophon({ + // Environment variables + env: { + NODE_ENV: "development", + }, + + // Tools to install + installs: [ + { name: "node", version: "20.0.0" }, + ], + + // Tasks you can run + tasks: { + dev: "npm run dev", + test: "npm test", + build: "npm run build", + }, +}); +---- + +=== Running Tasks (30 seconds) + +[source,bash] +---- +# Activate environment +ghjk env + +# Or run tasks directly +ghjk run dev +ghjk run test +ghjk run build +---- + +=== Common Commands (30 seconds) + +[source,bash] +---- +# List all available ghjk versions +asdf list all ghjk + +# Install a specific version +asdf install ghjk 0.3.2 + +# Switch versions +asdf global ghjk 0.3.2 # All projects +asdf local ghjk 0.3.1 # Current project only +asdf shell ghjk 0.3.0 # Current shell only + +# See what's installed +asdf list ghjk + +# See current version +asdf current ghjk + +# Update to latest +asdf install ghjk latest && asdf global ghjk latest +---- + +=== Troubleshooting (30 seconds) + +==== "`ghjk: command not found`" + +[source,bash] +---- +# Reshim asdf +asdf reshim ghjk + +# Or add asdf to your PATH (if not already) +echo '. $HOME/.asdf/asdf.sh' >> ~/.bashrc +source ~/.bashrc +---- + +==== "`GitHub API rate limit exceeded`" + +[source,bash] +---- +# Create a token at: https://github.com/settings/tokens +export GITHUB_API_TOKEN="ghp_your_token_here" + +# Add to your shell profile to make permanent +echo 'export GITHUB_API_TOKEN="ghp_..."' >> ~/.bashrc +---- + +==== Need more help? + +* link:../README.md[Full Documentation] +* link:TROUBLESHOOTING.md[Troubleshooting Guide] +* link:FAQ.md[FAQ] + +=== Next Steps + +Now that you’re set up, explore: + +[arabic] +. *link:EXAMPLES.md[Examples]* - Real-world usage patterns +. *https://github.com/metatypedev/ghjk[ghjk Docs]* - Learn more about +ghjk +. *https://asdf-vm.com[asdf Docs]* - Master asdf version management + +=== Quick Reference Card + +[source,bash] +---- +# Plugin Management +asdf plugin add ghjk # Add plugin +asdf plugin update ghjk # Update plugin +asdf plugin remove ghjk # Remove plugin + +# Version Installation +asdf install ghjk latest # Install latest +asdf install ghjk 0.3.2 # Install specific version +asdf uninstall ghjk 0.3.1 # Remove version + +# Version Selection +asdf global ghjk # Set global default +asdf local ghjk # Set for current directory +asdf shell ghjk # Set for current shell + +# Information +asdf list all ghjk # All available versions +asdf list ghjk # Installed versions +asdf current ghjk # Active version +asdf where ghjk # Installation path + +# Maintenance +asdf reshim ghjk # Rebuild shims +asdf update # Update asdf itself +---- + +''''' + +*Ready to dive deeper?* Check out the link:../README.md[full +documentation]! diff --git a/asdf-augmenters/asdf-ghjk/docs/QUICKSTART.md b/asdf-augmenters/asdf-ghjk/docs/QUICKSTART.md deleted file mode 100644 index 83f7345a..00000000 --- a/asdf-augmenters/asdf-ghjk/docs/QUICKSTART.md +++ /dev/null @@ -1,188 +0,0 @@ -# Quick Start Guide - -Get up and running with asdf-ghjk in 5 minutes. - -## Prerequisites - -Before you begin, install: - -1. **asdf** - [Installation guide](https://asdf-vm.com/guide/getting-started.html) -2. **System dependencies**: git, curl, tar - -```bash -# Ubuntu/Debian -sudo apt-get install git curl tar - -# macOS -brew install git curl tar -``` - -## Installation (30 seconds) - -```bash -# 1. Add the plugin -asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git - -# 2. Install latest version -asdf install ghjk latest - -# 3. Set as default -asdf global ghjk latest - -# 4. Verify -ghjk --version -``` - -Done! 🎉 - -## Your First ghjk Project (2 minutes) - -```bash -# 1. Create a new project -mkdir my-project -cd my-project - -# 2. Pin ghjk version for this project -asdf local ghjk latest - -# 3. Initialize ghjk -ghjk init ts - -# 4. View the generated config -cat ghjk.ts -``` - -You now have a `ghjk.ts` configuration file! - -## Basic Configuration (1 minute) - -Edit `ghjk.ts`: - -```typescript -export { sophon } from "https://deno.land/x/ghjk/mod.ts"; - -sophon({ - // Environment variables - env: { - NODE_ENV: "development", - }, - - // Tools to install - installs: [ - { name: "node", version: "20.0.0" }, - ], - - // Tasks you can run - tasks: { - dev: "npm run dev", - test: "npm test", - build: "npm run build", - }, -}); -``` - -## Running Tasks (30 seconds) - -```bash -# Activate environment -ghjk env - -# Or run tasks directly -ghjk run dev -ghjk run test -ghjk run build -``` - -## Common Commands (30 seconds) - -```bash -# List all available ghjk versions -asdf list all ghjk - -# Install a specific version -asdf install ghjk 0.3.2 - -# Switch versions -asdf global ghjk 0.3.2 # All projects -asdf local ghjk 0.3.1 # Current project only -asdf shell ghjk 0.3.0 # Current shell only - -# See what's installed -asdf list ghjk - -# See current version -asdf current ghjk - -# Update to latest -asdf install ghjk latest && asdf global ghjk latest -``` - -## Troubleshooting (30 seconds) - -### "ghjk: command not found" - -```bash -# Reshim asdf -asdf reshim ghjk - -# Or add asdf to your PATH (if not already) -echo '. $HOME/.asdf/asdf.sh' >> ~/.bashrc -source ~/.bashrc -``` - -### "GitHub API rate limit exceeded" - -```bash -# Create a token at: https://github.com/settings/tokens -export GITHUB_API_TOKEN="ghp_your_token_here" - -# Add to your shell profile to make permanent -echo 'export GITHUB_API_TOKEN="ghp_..."' >> ~/.bashrc -``` - -### Need more help? - -- [Full Documentation](../README.md) -- [Troubleshooting Guide](TROUBLESHOOTING.md) -- [FAQ](FAQ.md) - -## Next Steps - -Now that you're set up, explore: - -1. **[Examples](EXAMPLES.md)** - Real-world usage patterns -2. **[ghjk Docs](https://github.com/metatypedev/ghjk)** - Learn more about ghjk -3. **[asdf Docs](https://asdf-vm.com)** - Master asdf version management - -## Quick Reference Card - -```bash -# Plugin Management -asdf plugin add ghjk # Add plugin -asdf plugin update ghjk # Update plugin -asdf plugin remove ghjk # Remove plugin - -# Version Installation -asdf install ghjk latest # Install latest -asdf install ghjk 0.3.2 # Install specific version -asdf uninstall ghjk 0.3.1 # Remove version - -# Version Selection -asdf global ghjk # Set global default -asdf local ghjk # Set for current directory -asdf shell ghjk # Set for current shell - -# Information -asdf list all ghjk # All available versions -asdf list ghjk # Installed versions -asdf current ghjk # Active version -asdf where ghjk # Installation path - -# Maintenance -asdf reshim ghjk # Rebuild shims -asdf update # Update asdf itself -``` - ---- - -**Ready to dive deeper?** Check out the [full documentation](../README.md)! diff --git a/asdf-augmenters/asdf-ghjk/docs/TROUBLESHOOTING.adoc b/asdf-augmenters/asdf-ghjk/docs/TROUBLESHOOTING.adoc new file mode 100644 index 00000000..1c0d953a --- /dev/null +++ b/asdf-augmenters/asdf-ghjk/docs/TROUBLESHOOTING.adoc @@ -0,0 +1,474 @@ +== Troubleshooting Guide + +This guide helps you resolve common issues with asdf-ghjk. + +=== Table of Contents + +* link:#installation-issues[Installation Issues] +* link:#download-failures[Download Failures] +* link:#github-api-issues[GitHub API Issues] +* link:#platform-issues[Platform Issues] +* link:#runtime-issues[Runtime Issues] +* link:#version-management[Version Management] +* link:#debug-mode[Debug Mode] + +=== Installation Issues + +==== Error: "`curl: command not found`" + +*Cause:* curl is not installed on your system. + +*Solution:* + +[source,bash] +---- +# Ubuntu/Debian +sudo apt-get install curl + +# macOS +brew install curl + +# Fedora/RHEL +sudo dnf install curl +---- + +==== Error: "`tar: command not found`" + +*Cause:* tar is not installed on your system. + +*Solution:* + +[source,bash] +---- +# Ubuntu/Debian +sudo apt-get install tar + +# macOS (should be pre-installed) +brew install gnu-tar + +# Fedora/RHEL +sudo dnf install tar +---- + +==== Error: "`Archive not found`" + +*Cause:* The download step failed or was skipped. + +*Solution:* + +[source,bash] +---- +# Download explicitly first +asdf download ghjk + +# Then install +asdf install ghjk +---- + +==== Error: "`ghjk binary not found after extraction`" + +*Cause:* The archive structure changed or extraction failed. + +*Solution:* + +[source,bash] +---- +# Enable debug mode +export ASDF_DEBUG=1 + +# Try installing again +asdf install ghjk + +# Check the extracted contents +ls -la ~/.asdf/installs/ghjk// +---- + +=== Download Failures + +==== Error: "`Failed to download after 3 attempts`" + +*Cause:* Network issues or GitHub is down. + +*Solution:* + +[arabic] +. Check your internet connection: + +[source,bash] +---- +ping github.com +---- + +[arabic, start=2] +. Check GitHub status: https://www.githubstatus.com/ +. Try with a different network +. Wait a few minutes and try again + +==== Error: "`Checksum verification failed`" + +*Cause:* Downloaded file is corrupted. + +*Solution:* + +[source,bash] +---- +# Remove the corrupted download +rm -rf ~/.asdf/downloads/ghjk/ + +# Try downloading again +asdf install ghjk +---- + +=== GitHub API Issues + +==== Error: "`GitHub API rate limit exceeded`" + +*Cause:* GitHub limits unauthenticated API requests to 60 per hour. + +*Solution:* + +Create a GitHub personal access token and set it: + +[source,bash] +---- +# 1. Create token at https://github.com/settings/tokens +# 2. No special permissions needed for public repos +# 3. Add to your shell profile (~/.bashrc, ~/.zshrc, etc.): +export GITHUB_API_TOKEN="ghp_your_token_here" + +# 4. Reload your shell +source ~/.bashrc # or ~/.zshrc +---- + +==== Error: "`GitHub API request failed with status code: 403`" + +*Cause:* Rate limit or authentication issue. + +*Solution:* + +Check your rate limit: + +[source,bash] +---- +curl -H "Authorization: token $GITHUB_API_TOKEN" \ + https://api.github.com/rate_limit +---- + +If using a token, verify it’s valid: - Go to +https://github.com/settings/tokens - Check if your token is still active +- Generate a new one if needed + +=== Platform Issues + +==== Error: "`Unsupported operating system`" + +*Cause:* Your OS is not supported by ghjk. + +*Supported Platforms:* - Linux (x86_64, aarch64) - macOS (x86_64, arm64) + +*Check your platform:* + +[source,bash] +---- +uname -s # Should be: Linux or Darwin +uname -m # Should be: x86_64, aarch64, or arm64 +---- + +==== Error: "`Unsupported architecture`" + +*Cause:* Your CPU architecture is not supported. + +*Solution:* + +ghjk currently only supports: - x86_64 (Intel/AMD 64-bit) - +aarch64/arm64 (ARM 64-bit) + +32-bit systems and other architectures are not supported. + +=== Runtime Issues + +==== Error: "`ghjk: command not found`" + +*Cause:* asdf shims not in PATH or ghjk not installed. + +*Solution:* + +[arabic] +. Verify ghjk is installed: + +[source,bash] +---- +asdf list ghjk +---- + +[arabic, start=2] +. Check that asdf is properly set up: + +[source,bash] +---- +# Should show ghjk version +asdf current ghjk + +# If not, add asdf to your PATH +# See: https://asdf-vm.com/guide/getting-started.html +---- + +[arabic, start=3] +. Reshim if necessary: + +[source,bash] +---- +asdf reshim ghjk +---- + +==== Warning: "`Missing recommended runtime dependencies`" + +*Cause:* ghjk needs additional tools to function properly. + +*Required Dependencies:* - git - curl - tar - unzip - zstd + +*Solution:* + +[source,bash] +---- +# Ubuntu/Debian +sudo apt-get install git curl tar unzip zstd + +# macOS +brew install git curl tar unzip zstd + +# Fedora/RHEL +sudo dnf install git curl tar unzip zstd +---- + +==== Error: "`ghjk init ts fails`" + +*Cause:* Missing Deno or other ghjk dependencies. + +*Solution:* + +[arabic] +. Verify ghjk is working: + +[source,bash] +---- +ghjk --version +---- + +[arabic, start=2] +. Check ghjk documentation for additional requirements: + +[source,bash] +---- +ghjk --help +---- + +[arabic, start=3] +. Try installing Deno (ghjk’s runtime): + +[source,bash] +---- +# ghjk should handle this, but you can install manually +curl -fsSL https://deno.land/install.sh | sh +---- + +=== Version Management + +==== Error: "`Version not found: latest`" + +*Cause:* `+latest+` keyword resolution failed. + +*Solution:* + +Use a specific version instead: + +[source,bash] +---- +# List all versions +asdf list all ghjk + +# Install a specific version +asdf install ghjk 0.3.2 +---- + +==== Error: "`No such version: X.Y.Z`" + +*Cause:* The version doesn’t exist or hasn’t been released yet. + +*Solution:* + +Check available versions: + +[source,bash] +---- +asdf list all ghjk +---- + +==== Multiple versions installed but wrong one is active + +*Cause:* Version precedence issues. + +*asdf Version Precedence (highest to lowest):* 1. `+ASDF_GHJK_VERSION+` +environment variable 2. `+.tool-versions+` in current directory 3. +`+.tool-versions+` in parent directories 4. `+~/.tool-versions+` +(global) + +*Solution:* + +[source,bash] +---- +# Check which version is active and why +asdf current ghjk + +# Set local version +asdf local ghjk 0.3.2 + +# Set global version +asdf global ghjk 0.3.2 + +# Use specific version for one command +ASDF_GHJK_VERSION=0.3.1 ghjk --version +---- + +=== Debug Mode + +==== Enable Verbose Output + +For detailed debugging information: + +[source,bash] +---- +# Enable asdf debug mode +export ASDF_DEBUG=1 + +# Run your command +asdf install ghjk latest + +# Check asdf logs +cat ~/.asdf/tmp/*/install-ghjk-*.log +---- + +==== Manual Script Testing + +Test plugin scripts directly: + +[source,bash] +---- +# Test list-all +./bin/list-all + +# Test download +export ASDF_INSTALL_VERSION="0.3.2" +export ASDF_DOWNLOAD_PATH="/tmp/test-download" +export ASDF_INSTALL_PATH="/tmp/test-install" +mkdir -p "$ASDF_DOWNLOAD_PATH" "$ASDF_INSTALL_PATH" + +./bin/download +./bin/install + +# Check result +ls -la /tmp/test-install/ +/tmp/test-install/bin/ghjk --version + +# Clean up +rm -rf /tmp/test-* +---- + +=== Getting More Help + +==== Check Logs + +asdf creates logs for installations: + +[source,bash] +---- +# Find recent logs +ls -lt ~/.asdf/tmp/ + +# View a specific log +cat ~/.asdf/tmp//install-ghjk-.log +---- + +==== Verify Plugin Installation + +[source,bash] +---- +# List installed plugins +asdf plugin list + +# Check plugin repository +asdf plugin list --urls + +# Re-add plugin if needed +asdf plugin remove ghjk +asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git +---- + +==== Common Solutions + +[arabic] +. *Update asdf:* + +[source,bash] +---- +asdf update +---- + +[arabic, start=2] +. *Update the plugin:* + +[source,bash] +---- +asdf plugin update ghjk +---- + +[arabic, start=3] +. *Reshim:* + +[source,bash] +---- +asdf reshim ghjk +---- + +[arabic, start=4] +. *Clean cache:* + +[source,bash] +---- +rm -rf ~/.asdf/downloads/ghjk +rm -rf ~/.asdf/tmp/* +---- + +==== Report an Issue + +If none of these solutions work: + +[arabic] +. Gather information: + +[source,bash] +---- +# System info +uname -a +bash --version +asdf --version + +# Plugin version +cd ~/.asdf/plugins/ghjk && git log -1 --oneline + +# Error output with debug enabled +ASDF_DEBUG=1 asdf install ghjk 2>&1 | tee error.log +---- + +[arabic, start=2] +. Open an issue: https://github.com/Hyperpolymath/asdf-ghjk/issues/new + +Include: - System information - Error messages - Steps to reproduce - +What you’ve already tried + +=== Additional Resources + +* *asdf Documentation:* https://asdf-vm.com +* *ghjk Documentation:* https://github.com/metatypedev/ghjk +* *Plugin README:* https://github.com/Hyperpolymath/asdf-ghjk +* *GitHub Issues:* https://github.com/Hyperpolymath/asdf-ghjk/issues diff --git a/asdf-augmenters/asdf-ghjk/docs/TROUBLESHOOTING.md b/asdf-augmenters/asdf-ghjk/docs/TROUBLESHOOTING.md deleted file mode 100644 index dca5b2dc..00000000 --- a/asdf-augmenters/asdf-ghjk/docs/TROUBLESHOOTING.md +++ /dev/null @@ -1,447 +0,0 @@ -# Troubleshooting Guide - -This guide helps you resolve common issues with asdf-ghjk. - -## Table of Contents - -- [Installation Issues](#installation-issues) -- [Download Failures](#download-failures) -- [GitHub API Issues](#github-api-issues) -- [Platform Issues](#platform-issues) -- [Runtime Issues](#runtime-issues) -- [Version Management](#version-management) -- [Debug Mode](#debug-mode) - -## Installation Issues - -### Error: "curl: command not found" - -**Cause:** curl is not installed on your system. - -**Solution:** - -```bash -# Ubuntu/Debian -sudo apt-get install curl - -# macOS -brew install curl - -# Fedora/RHEL -sudo dnf install curl -``` - -### Error: "tar: command not found" - -**Cause:** tar is not installed on your system. - -**Solution:** - -```bash -# Ubuntu/Debian -sudo apt-get install tar - -# macOS (should be pre-installed) -brew install gnu-tar - -# Fedora/RHEL -sudo dnf install tar -``` - -### Error: "Archive not found" - -**Cause:** The download step failed or was skipped. - -**Solution:** - -```bash -# Download explicitly first -asdf download ghjk - -# Then install -asdf install ghjk -``` - -### Error: "ghjk binary not found after extraction" - -**Cause:** The archive structure changed or extraction failed. - -**Solution:** - -```bash -# Enable debug mode -export ASDF_DEBUG=1 - -# Try installing again -asdf install ghjk - -# Check the extracted contents -ls -la ~/.asdf/installs/ghjk// -``` - -## Download Failures - -### Error: "Failed to download after 3 attempts" - -**Cause:** Network issues or GitHub is down. - -**Solution:** - -1. Check your internet connection: - -```bash -ping github.com -``` - -2. Check GitHub status: https://www.githubstatus.com/ - -3. Try with a different network - -4. Wait a few minutes and try again - -### Error: "Checksum verification failed" - -**Cause:** Downloaded file is corrupted. - -**Solution:** - -```bash -# Remove the corrupted download -rm -rf ~/.asdf/downloads/ghjk/ - -# Try downloading again -asdf install ghjk -``` - -## GitHub API Issues - -### Error: "GitHub API rate limit exceeded" - -**Cause:** GitHub limits unauthenticated API requests to 60 per hour. - -**Solution:** - -Create a GitHub personal access token and set it: - -```bash -# 1. Create token at https://github.com/settings/tokens -# 2. No special permissions needed for public repos -# 3. Add to your shell profile (~/.bashrc, ~/.zshrc, etc.): -export GITHUB_API_TOKEN="ghp_your_token_here" - -# 4. Reload your shell -source ~/.bashrc # or ~/.zshrc -``` - -### Error: "GitHub API request failed with status code: 403" - -**Cause:** Rate limit or authentication issue. - -**Solution:** - -Check your rate limit: - -```bash -curl -H "Authorization: token $GITHUB_API_TOKEN" \ - https://api.github.com/rate_limit -``` - -If using a token, verify it's valid: -- Go to https://github.com/settings/tokens -- Check if your token is still active -- Generate a new one if needed - -## Platform Issues - -### Error: "Unsupported operating system" - -**Cause:** Your OS is not supported by ghjk. - -**Supported Platforms:** -- Linux (x86_64, aarch64) -- macOS (x86_64, arm64) - -**Check your platform:** - -```bash -uname -s # Should be: Linux or Darwin -uname -m # Should be: x86_64, aarch64, or arm64 -``` - -### Error: "Unsupported architecture" - -**Cause:** Your CPU architecture is not supported. - -**Solution:** - -ghjk currently only supports: -- x86_64 (Intel/AMD 64-bit) -- aarch64/arm64 (ARM 64-bit) - -32-bit systems and other architectures are not supported. - -## Runtime Issues - -### Error: "ghjk: command not found" - -**Cause:** asdf shims not in PATH or ghjk not installed. - -**Solution:** - -1. Verify ghjk is installed: - -```bash -asdf list ghjk -``` - -2. Check that asdf is properly set up: - -```bash -# Should show ghjk version -asdf current ghjk - -# If not, add asdf to your PATH -# See: https://asdf-vm.com/guide/getting-started.html -``` - -3. Reshim if necessary: - -```bash -asdf reshim ghjk -``` - -### Warning: "Missing recommended runtime dependencies" - -**Cause:** ghjk needs additional tools to function properly. - -**Required Dependencies:** -- git -- curl -- tar -- unzip -- zstd - -**Solution:** - -```bash -# Ubuntu/Debian -sudo apt-get install git curl tar unzip zstd - -# macOS -brew install git curl tar unzip zstd - -# Fedora/RHEL -sudo dnf install git curl tar unzip zstd -``` - -### Error: "ghjk init ts fails" - -**Cause:** Missing Deno or other ghjk dependencies. - -**Solution:** - -1. Verify ghjk is working: - -```bash -ghjk --version -``` - -2. Check ghjk documentation for additional requirements: - -```bash -ghjk --help -``` - -3. Try installing Deno (ghjk's runtime): - -```bash -# ghjk should handle this, but you can install manually -curl -fsSL https://deno.land/install.sh | sh -``` - -## Version Management - -### Error: "Version not found: latest" - -**Cause:** `latest` keyword resolution failed. - -**Solution:** - -Use a specific version instead: - -```bash -# List all versions -asdf list all ghjk - -# Install a specific version -asdf install ghjk 0.3.2 -``` - -### Error: "No such version: X.Y.Z" - -**Cause:** The version doesn't exist or hasn't been released yet. - -**Solution:** - -Check available versions: - -```bash -asdf list all ghjk -``` - -### Multiple versions installed but wrong one is active - -**Cause:** Version precedence issues. - -**asdf Version Precedence (highest to lowest):** -1. `ASDF_GHJK_VERSION` environment variable -2. `.tool-versions` in current directory -3. `.tool-versions` in parent directories -4. `~/.tool-versions` (global) - -**Solution:** - -```bash -# Check which version is active and why -asdf current ghjk - -# Set local version -asdf local ghjk 0.3.2 - -# Set global version -asdf global ghjk 0.3.2 - -# Use specific version for one command -ASDF_GHJK_VERSION=0.3.1 ghjk --version -``` - -## Debug Mode - -### Enable Verbose Output - -For detailed debugging information: - -```bash -# Enable asdf debug mode -export ASDF_DEBUG=1 - -# Run your command -asdf install ghjk latest - -# Check asdf logs -cat ~/.asdf/tmp/*/install-ghjk-*.log -``` - -### Manual Script Testing - -Test plugin scripts directly: - -```bash -# Test list-all -./bin/list-all - -# Test download -export ASDF_INSTALL_VERSION="0.3.2" -export ASDF_DOWNLOAD_PATH="/tmp/test-download" -export ASDF_INSTALL_PATH="/tmp/test-install" -mkdir -p "$ASDF_DOWNLOAD_PATH" "$ASDF_INSTALL_PATH" - -./bin/download -./bin/install - -# Check result -ls -la /tmp/test-install/ -/tmp/test-install/bin/ghjk --version - -# Clean up -rm -rf /tmp/test-* -``` - -## Getting More Help - -### Check Logs - -asdf creates logs for installations: - -```bash -# Find recent logs -ls -lt ~/.asdf/tmp/ - -# View a specific log -cat ~/.asdf/tmp//install-ghjk-.log -``` - -### Verify Plugin Installation - -```bash -# List installed plugins -asdf plugin list - -# Check plugin repository -asdf plugin list --urls - -# Re-add plugin if needed -asdf plugin remove ghjk -asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git -``` - -### Common Solutions - -1. **Update asdf:** - -```bash -asdf update -``` - -2. **Update the plugin:** - -```bash -asdf plugin update ghjk -``` - -3. **Reshim:** - -```bash -asdf reshim ghjk -``` - -4. **Clean cache:** - -```bash -rm -rf ~/.asdf/downloads/ghjk -rm -rf ~/.asdf/tmp/* -``` - -### Report an Issue - -If none of these solutions work: - -1. Gather information: - -```bash -# System info -uname -a -bash --version -asdf --version - -# Plugin version -cd ~/.asdf/plugins/ghjk && git log -1 --oneline - -# Error output with debug enabled -ASDF_DEBUG=1 asdf install ghjk 2>&1 | tee error.log -``` - -2. Open an issue: https://github.com/Hyperpolymath/asdf-ghjk/issues/new - -Include: -- System information -- Error messages -- Steps to reproduce -- What you've already tried - -## Additional Resources - -- **asdf Documentation:** https://asdf-vm.com -- **ghjk Documentation:** https://github.com/metatypedev/ghjk -- **Plugin README:** https://github.com/Hyperpolymath/asdf-ghjk -- **GitHub Issues:** https://github.com/Hyperpolymath/asdf-ghjk/issues diff --git a/asdf-augmenters/asdf-metaiconic-plugin/ABI-FFI-README.adoc b/asdf-augmenters/asdf-metaiconic-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..f3cd4789 --- /dev/null +++ b/asdf-augmenters/asdf-metaiconic-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== METAICONIC ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/metaiconic.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libmetaiconic.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +metaiconic/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── metaiconic.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── metaiconic.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/metaiconic.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "metaiconic.h" + +int main() { + void* handle = metaiconic_init(); + if (!handle) return 1; + + int result = metaiconic_process(handle, 42); + if (result != 0) { + const char* err = metaiconic_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + metaiconic_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lmetaiconic -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import METAICONIC.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "metaiconic")] +extern "C" { + fn metaiconic_init() -> *mut std::ffi::c_void; + fn metaiconic_free(handle: *mut std::ffi::c_void); + fn metaiconic_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = metaiconic_init(); + assert!(!handle.is_null()); + + let result = metaiconic_process(handle, 42); + assert_eq!(result, 0); + + metaiconic_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libmetaiconic = "libmetaiconic" + +function init() + handle = ccall((:metaiconic_init, libmetaiconic), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:metaiconic_process, libmetaiconic), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:metaiconic_free, libmetaiconic), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/metaiconic.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-metaiconic-plugin/ABI-FFI-README.md b/asdf-augmenters/asdf-metaiconic-plugin/ABI-FFI-README.md deleted file mode 100644 index 55307ef9..00000000 --- a/asdf-augmenters/asdf-metaiconic-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# METAICONIC ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/metaiconic.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libmetaiconic.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -metaiconic/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── metaiconic.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── metaiconic.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/metaiconic.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "metaiconic.h" - -int main() { - void* handle = metaiconic_init(); - if (!handle) return 1; - - int result = metaiconic_process(handle, 42); - if (result != 0) { - const char* err = metaiconic_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - metaiconic_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lmetaiconic -L./zig-out/lib -``` - -### From Idris2 - -```idris -import METAICONIC.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "metaiconic")] -extern "C" { - fn metaiconic_init() -> *mut std::ffi::c_void; - fn metaiconic_free(handle: *mut std::ffi::c_void); - fn metaiconic_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = metaiconic_init(); - assert!(!handle.is_null()); - - let result = metaiconic_process(handle, 42); - assert_eq!(result, 0); - - metaiconic_free(handle); - } -} -``` - -### From Julia - -```julia -const libmetaiconic = "libmetaiconic" - -function init() - handle = ccall((:metaiconic_init, libmetaiconic), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:metaiconic_process, libmetaiconic), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:metaiconic_free, libmetaiconic), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/metaiconic.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-metaiconic-plugin/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-metaiconic-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-metaiconic-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-metaiconic-plugin/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-metaiconic-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-metaiconic-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-metaiconic-plugin/CONTRIBUTING.adoc b/asdf-augmenters/asdf-metaiconic-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-metaiconic-plugin/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-metaiconic-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-metaiconic-plugin/CONTRIBUTING.md b/asdf-augmenters/asdf-metaiconic-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-metaiconic-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-metaiconic-plugin/README.adoc b/asdf-augmenters/asdf-metaiconic-plugin/README.adoc index b5c0dc4c..6edb4187 100644 --- a/asdf-augmenters/asdf-metaiconic-plugin/README.adoc +++ b/asdf-augmenters/asdf-metaiconic-plugin/README.adoc @@ -1,114 +1,52 @@ -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] -image:https://img.shields.io/badge/Philosophy-Palimpsest-indigo.svg[Palimpsest,link="https://github.com/hyperpolymath/palimpsest-license"] +== asdf-metaiconic-plugin +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] +image:https://img.shields.io/badge/Philosophy-Palimpsest-indigo.svg[Palimpsest,link="`https://github.com/hyperpolymath/palimpsest-license`"] -// SPDX-License-Identifier: CC-BY-SA-4.0 -= asdf-metaiconic-plugin +Central metadata registry and discovery layer for the +https://asdf-vm.com[asdf] plugin ecosystem. -:toc: macro -:toc-title: Contents -:toclevels: 3 -:icons: font +=== Overview -Unified metadata index and discovery layer for the hyperpolymath asdf plugin ecosystem. +`+asdf-metaiconic-plugin+` serves as the unified metadata index for 65+ +hyperpolymath asdf plugins: -toc::[] +* *Plugin discovery* - Search and browse available plugins +* *Category organization* - Tag-based classification +* *Icon/branding consistency* - SVG icons for all plugins +* *Quality metrics* - CI status aggregation -== Overview +=== Plugin Categories -**asdf-metaiconic-plugin** is the central metadata registry for 68+ asdf plugins in the hyperpolymath ecosystem. It provides: - -* Standardized plugin metadata schema -* Category and tag-based organization -* Plugin discovery and search -* Icon and branding consistency -* Quality metrics aggregation - -== Status - -[cols="1,3"] +[cols=",",options="header",] |=== -| Component | Status - -| Specification -| ✓ link:SPECIFICATION.adoc[Complete] - -| Registry Schema -| ✓ link:registry/plugins.yaml[Implemented] - -| Category Definitions -| ✓ link:registry/categories.yaml[Implemented] - -| Search CLI -| ⏳ Phase 2 - -| Icons -| ⏳ Phase 2 +|Category |Plugins +|Security |trivy, grype, syft, cosign, age, gitleaks, sops +|Databases |mysql, mariadb, cassandra, couchdb, neo4j, arangodb +|Configuration |nickel, dhall, cue, taplo, kdl-fmt +|Static Sites |zola, cobalt, mdbook, franklin, serum, pollen +|Containers |apko, melange, envoy, linkerd |=== -== Quick Start - -[source,bash] ----- -# Search for security plugins -asdf metaiconic search "vulnerability" - -# List all plugins by category -asdf metaiconic list --category security +=== Related Projects -# Get plugin info -asdf metaiconic info trivy ----- - -== Registry Structure - ----- -registry/ -├── plugins.yaml # Master plugin list (68+ entries) -├── categories.yaml # Category definitions (9 categories) -└── schemas/ # Validation schemas ----- - -== Categories - -[cols="1,2"] +[width="100%",cols="40%,60%",options="header",] |=== -| Category | Plugins +|Project |Relationship +|https://github.com/hyperpolymath/asdf-ui-plugin[asdf-ui-plugin] |Visual +consumer -| security | trivy, grype, syft, cosign, gitleaks, age, opa -| database | arangodb, mariadb, neo4j, cassandra, surrealdb -| config | nickel, dhall, cue, yq, taplo, bebop -| network | coredns, envoy, pomerium, linkerd -| crypto | step-ca, cfssl, lego, rekor, fulcio -| build | apko, melange, restic, borg, hashicorp -| language | ada, fortran, affinescript, ocaml, vlang -| ssg | casket-ssg, zola, cobalt, mdbook -| webserver | httpd, varnish, openlitespeed +|https://github.com/hyperpolymath/asdf-security-plugin[asdf-security-plugin] +|Security layer |=== -== Ecosystem Integration - -This plugin is consumed by: - -* **asdf-plugin-configurator** - CLI tool uses registry for search -* **asdf-ui-plugin** - Visual interface uses icons and metadata -* **asdf-control-tower** - Dashboard aggregates plugin status - -See link:ECOSYSTEM.scm[ECOSYSTEM.scm] for full integration map. - -== Infrastructure - -* Multi-forge mirroring (GitHub → GitLab, Codeberg, Bitbucket) -* Instant sync propagation on push/release -* AI assistant configuration (`.claude/CLAUDE.md`) - -== Links +=== License -* link:SPECIFICATION.adoc[Full Specification] -* link:registry/plugins.yaml[Plugin Registry] -* https://github.com/hyperpolymath/asdf-control-tower[Control Tower] -* https://github.com/hyperpolymath/asdf-plugin-configurator[Configurator CLI] +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -== License +''''' -MPL-2.0 +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-metaiconic-plugin/README.md b/asdf-augmenters/asdf-metaiconic-plugin/README.md deleted file mode 100644 index ed9cd4cd..00000000 --- a/asdf-augmenters/asdf-metaiconic-plugin/README.md +++ /dev/null @@ -1,40 +0,0 @@ -# asdf-metaiconic-plugin - -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] -image:https://img.shields.io/badge/Philosophy-Palimpsest-indigo.svg[Palimpsest,link="https://github.com/hyperpolymath/palimpsest-license"] - -Central metadata registry and discovery layer for the [asdf](https://asdf-vm.com) plugin ecosystem. - -## Overview - -`asdf-metaiconic-plugin` serves as the unified metadata index for 65+ hyperpolymath asdf plugins: - -- **Plugin discovery** - Search and browse available plugins -- **Category organization** - Tag-based classification -- **Icon/branding consistency** - SVG icons for all plugins -- **Quality metrics** - CI status aggregation - -## Plugin Categories - -| Category | Plugins | -|----------|---------| -| Security | trivy, grype, syft, cosign, age, gitleaks, sops | -| Databases | mysql, mariadb, cassandra, couchdb, neo4j, arangodb | -| Configuration | nickel, dhall, cue, taplo, kdl-fmt | -| Static Sites | zola, cobalt, mdbook, franklin, serum, pollen | -| Containers | apko, melange, envoy, linkerd | - -## Related Projects - -| Project | Relationship | -|---------|--------------| -| [asdf-ui-plugin](https://github.com/hyperpolymath/asdf-ui-plugin) | Visual consumer | -| [asdf-security-plugin](https://github.com/hyperpolymath/asdf-security-plugin) | Security layer | - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-metaiconic-plugin/SECURITY.adoc b/asdf-augmenters/asdf-metaiconic-plugin/SECURITY.adoc new file mode 100644 index 00000000..6833c545 --- /dev/null +++ b/asdf-augmenters/asdf-metaiconic-plugin/SECURITY.adoc @@ -0,0 +1,378 @@ +Security Policy + +We take security seriously. We appreciate your efforts to responsibly +disclose vulnerabilities and will make every effort to acknowledge your +contributions. Table of Contents + +.... +Reporting a Vulnerability +What to Include +Response Timeline +Disclosure Policy +Scope +Safe Harbour +Recognition +Security Updates +Security Best Practices +.... + +Reporting a Vulnerability Preferred Method: GitHub Security Advisories + +The preferred method for reporting security vulnerabilities is through +GitHub’s Security Advisory feature: + +.... +Navigate to Report a Vulnerability +Click "Report a vulnerability" +Complete the form with as much detail as possible +Submit — we'll receive a private notification +.... + +This method ensures: + +.... +End-to-end encryption of your report +Private discussion space for collaboration +Coordinated disclosure tooling +Automatic credit when the advisory is published +.... + +Alternative: Encrypted Email + +If you cannot use GitHub Security Advisories, you may email us directly: + +Email security@hyperpolymath.org PGP Key Download Public Key Fingerprint +See GPG key + +== Import our PGP key + +curl -sSL https://hyperpolymath.org/gpg/security.asc | gpg –import + +== Verify fingerprint + +gpg –fingerprint security@hyperpolymath.org + +== Encrypt your report + +gpg –armor –encrypt –recipient security@hyperpolymath.org report.txt + +.... +⚠️ Important: Do not report security vulnerabilities through public GitHub issues, pull requests, discussions, or social media. +.... + +What to Include + +A good vulnerability report helps us understand and reproduce the issue +quickly. Required Information + +.... +Description: Clear explanation of the vulnerability +Impact: What an attacker could achieve (confidentiality, integrity, availability) +Affected versions: Which versions/commits are affected +Reproduction steps: Detailed steps to reproduce the issue +.... + +Helpful Additional Information + +.... +Proof of concept: Code, scripts, or screenshots demonstrating the vulnerability +Attack scenario: Realistic attack scenario showing exploitability +CVSS score: Your assessment of severity (use CVSS 3.1 Calculator) +CWE ID: Common Weakness Enumeration identifier if known +Suggested fix: If you have ideas for remediation +References: Links to related vulnerabilities, research, or advisories +.... + +Example Report Structure + +=== Summary + +{empty}[One-sentence description of the vulnerability] + +=== Vulnerability Type + +{empty}[e.g., SQL Injection, XSS, SSRF, Path Traversal, etc.] + +=== Affected Component + +{empty}[File path, function name, API endpoint, etc.] + +=== Affected Versions + +{empty}[Version range or specific commits] + +=== Severity Assessment + +* CVSS 3.1 Score: [X.X] +* CVSS Vector: [CVSS:3.1/AV:X/AC:X/PR:X/UI:X/S:X/C:X/I:X/A:X] + +=== Description + +{empty}[Detailed technical description] + +=== Steps to Reproduce + +[arabic] +. [First step] +. [Second step] +. […] + +=== Proof of Concept + +{empty}[Code, curl commands, screenshots, etc.] + +=== Impact + +{empty}[What can an attacker achieve?] + +=== Suggested Remediation + +{empty}[Optional: your ideas for fixing] + +=== References + +{empty}[Links to related issues, CVEs, research] + +Response Timeline + +We commit to the following response times: Stage Timeframe Description +Initial Response 48 hours We acknowledge receipt and confirm we’re +investigating Triage 7 days We assess severity, confirm the +vulnerability, and estimate timeline Status Update Every 7 days Regular +updates on remediation progress Resolution 90 days Target for fix +development and release (complex issues may take longer) Disclosure 90 +days Public disclosure after fix is available (coordinated with you) + +.... +Note: These are targets, not guarantees. Complex vulnerabilities may require more time. We'll communicate openly about any delays. +.... + +Disclosure Policy + +We follow coordinated disclosure (also known as responsible disclosure): + +.... +You report the vulnerability privately +We acknowledge and begin investigation +We develop a fix and prepare a release +We coordinate disclosure timing with you +We publish security advisory and fix simultaneously +You may publish your research after disclosure +.... + +Our Commitments + +.... +We will not take legal action against researchers who follow this policy +We will work with you to understand and resolve the issue +We will credit you in the security advisory (unless you prefer anonymity) +We will notify you before public disclosure +We will publish advisories with sufficient detail for users to assess risk +.... + +Your Commitments + +.... +Report vulnerabilities promptly after discovery +Give us reasonable time to address the issue before disclosure +Do not access, modify, or delete data beyond what's necessary to demonstrate the vulnerability +Do not degrade service availability (no DoS testing on production) +Do not share vulnerability details with others until coordinated disclosure +.... + +Disclosure Timeline + +Day 0 You report vulnerability Day 1-2 We acknowledge receipt Day 7 We +confirm vulnerability and share initial assessment Day 7-90 We develop +and test fix Day 90 Coordinated public disclosure (earlier if fix is +ready; later by mutual agreement) + +If we cannot reach agreement on disclosure timing, we default to 90 days +from your initial report. Scope In Scope ✅ + +The following are within scope for security research: + +.... +This repository (hyperpolymath/terrapin-ssg) and all its code +Official releases and packages published from this repository +Documentation that could lead to security issues +Build and deployment configurations in this repository +Dependencies (report here, we'll coordinate with upstream) +.... + +Out of Scope ❌ + +The following are not in scope: + +.... +Third-party services we integrate with (report directly to them) +Social engineering attacks against maintainers +Physical security +Denial of service attacks against production infrastructure +Spam, phishing, or other non-technical attacks +Issues already reported or publicly known +Theoretical vulnerabilities without proof of concept +.... + +Qualifying Vulnerabilities + +We’re particularly interested in: + +.... +Remote code execution +SQL injection, command injection, code injection +Authentication/authorisation bypass +Cross-site scripting (XSS) and cross-site request forgery (CSRF) +Server-side request forgery (SSRF) +Path traversal / local file inclusion +Information disclosure (credentials, PII, secrets) +Cryptographic weaknesses +Deserialisation vulnerabilities +Memory safety issues (buffer overflows, use-after-free, etc.) +Supply chain vulnerabilities (dependency confusion, etc.) +Significant logic flaws +.... + +Non-Qualifying Issues + +The following generally do not qualify as security vulnerabilities: + +.... +Missing security headers on non-sensitive pages +Clickjacking on pages without sensitive actions +Self-XSS (requires victim to paste code) +Missing rate limiting (unless it enables a specific attack) +Username/email enumeration (unless high-risk context) +Missing cookie flags on non-sensitive cookies +Software version disclosure +Verbose error messages (unless exposing secrets) +Best practice deviations without demonstrable impact +.... + +Safe Harbour + +We support security research conducted in good faith. Our Promise + +If you conduct security research in accordance with this policy: + +.... +✅ We will not initiate legal action against you +✅ We will not report your activity to law enforcement +✅ We will work with you in good faith to resolve issues +✅ We consider your research authorised under the Computer Fraud and Abuse Act (CFAA), UK Computer Misuse Act, and similar laws +✅ We waive any potential claim against you for circumvention of security controls +.... + +Good Faith Requirements + +To qualify for safe harbour, you must: + +.... +Comply with this security policy +Report vulnerabilities promptly +Avoid privacy violations (do not access others' data) +Avoid service degradation (no destructive testing) +Not exploit vulnerabilities beyond proof-of-concept +Not use vulnerabilities for profit (beyond bug bounties where offered) + +⚠️ Important: This safe harbour does not extend to third-party systems. Always check their policies before testing. +.... + +Recognition + +We believe in recognising security researchers who help us improve. Hall +of Fame + +Researchers who report valid vulnerabilities will be acknowledged in our +Security Acknowledgments (unless they prefer anonymity). + +Recognition includes: + +.... +Your name (or chosen alias) +Link to your website/profile (optional) +Brief description of the vulnerability class +Date of report +.... + +What We Offer + +.... +✅ Public credit in security advisories +✅ Acknowledgment in release notes +✅ Entry in our Hall of Fame +✅ Reference/recommendation letter upon request (for significant findings) +.... + +What We Don’t Currently Offer + +.... +❌ Monetary bug bounties +❌ Hardware or swag +❌ Paid security research contracts + +Note: We're a community project with limited resources. Your contributions help everyone who uses this software. +.... + +Security Updates Receiving Updates + +To stay informed about security updates: + +.... +Watch this repository: Click "Watch" → "Custom" → Select "Security alerts" +GitHub Security Advisories: Published at Security Advisories +Release notes: Security fixes noted in CHANGELOG +.... + +Update Policy Severity Response Critical/High Patch release as soon as +fix is ready Medium Included in next scheduled release (or earlier) Low +Included in next scheduled release Supported Versions Version Supported +Notes main branch ✅ Yes Latest development Latest release ✅ Yes +Current stable Previous minor release ✅ Yes Security fixes backported +Older versions ❌ No Please upgrade Security Best Practices + +When using terrapin-ssg, we recommend: General + +.... +Keep dependencies up to date +Use the latest stable release +Subscribe to security notifications +Review configuration against security documentation +Follow principle of least privilege +.... + +For Contributors + +.... +Never commit secrets, credentials, or API keys +Use signed commits (git config commit.gpgsign true) +Review dependencies before adding them +Run security linters locally before pushing +Report any concerns about existing code +.... + +Additional Resources + +.... +Our PGP Public Key +Security Advisories +Changelog +Contributing Guidelines +CVE Database +CVSS Calculator +.... + +Contact Purpose Contact Security issues Report via GitHub or +security@hyperpolymath.org General questions GitHub Discussions Other +enquiries See README for contact information Policy Changes + +This security policy may be updated from time to time. Significant +changes will be: + +.... +Committed to this repository with a clear commit message +Noted in the changelog +Announced via GitHub Discussions (for major changes) +.... + +Thank you for helping keep terrapin-ssg and its users safe. diff --git a/asdf-augmenters/asdf-metaiconic-plugin/SECURITY.md b/asdf-augmenters/asdf-metaiconic-plugin/SECURITY.md deleted file mode 100644 index 5eb5e20d..00000000 --- a/asdf-augmenters/asdf-metaiconic-plugin/SECURITY.md +++ /dev/null @@ -1,328 +0,0 @@ -Security Policy - -We take security seriously. We appreciate your efforts to responsibly disclose vulnerabilities and will make every effort to acknowledge your contributions. -Table of Contents - - Reporting a Vulnerability - What to Include - Response Timeline - Disclosure Policy - Scope - Safe Harbour - Recognition - Security Updates - Security Best Practices - -Reporting a Vulnerability -Preferred Method: GitHub Security Advisories - -The preferred method for reporting security vulnerabilities is through GitHub's Security Advisory feature: - - Navigate to Report a Vulnerability - Click "Report a vulnerability" - Complete the form with as much detail as possible - Submit — we'll receive a private notification - -This method ensures: - - End-to-end encryption of your report - Private discussion space for collaboration - Coordinated disclosure tooling - Automatic credit when the advisory is published - -Alternative: Encrypted Email - -If you cannot use GitHub Security Advisories, you may email us directly: - -Email security@hyperpolymath.org -PGP Key Download Public Key -Fingerprint See GPG key - -# Import our PGP key -curl -sSL https://hyperpolymath.org/gpg/security.asc | gpg --import - -# Verify fingerprint -gpg --fingerprint security@hyperpolymath.org - -# Encrypt your report -gpg --armor --encrypt --recipient security@hyperpolymath.org report.txt - - ⚠️ Important: Do not report security vulnerabilities through public GitHub issues, pull requests, discussions, or social media. - -What to Include - -A good vulnerability report helps us understand and reproduce the issue quickly. -Required Information - - Description: Clear explanation of the vulnerability - Impact: What an attacker could achieve (confidentiality, integrity, availability) - Affected versions: Which versions/commits are affected - Reproduction steps: Detailed steps to reproduce the issue - -Helpful Additional Information - - Proof of concept: Code, scripts, or screenshots demonstrating the vulnerability - Attack scenario: Realistic attack scenario showing exploitability - CVSS score: Your assessment of severity (use CVSS 3.1 Calculator) - CWE ID: Common Weakness Enumeration identifier if known - Suggested fix: If you have ideas for remediation - References: Links to related vulnerabilities, research, or advisories - -Example Report Structure - -## Summary -[One-sentence description of the vulnerability] - -## Vulnerability Type -[e.g., SQL Injection, XSS, SSRF, Path Traversal, etc.] - -## Affected Component -[File path, function name, API endpoint, etc.] - -## Affected Versions -[Version range or specific commits] - -## Severity Assessment -- CVSS 3.1 Score: [X.X] -- CVSS Vector: [CVSS:3.1/AV:X/AC:X/PR:X/UI:X/S:X/C:X/I:X/A:X] - -## Description -[Detailed technical description] - -## Steps to Reproduce -1. [First step] -2. [Second step] -3. [...] - -## Proof of Concept -[Code, curl commands, screenshots, etc.] - -## Impact -[What can an attacker achieve?] - -## Suggested Remediation -[Optional: your ideas for fixing] - -## References -[Links to related issues, CVEs, research] - -Response Timeline - -We commit to the following response times: -Stage Timeframe Description -Initial Response 48 hours We acknowledge receipt and confirm we're investigating -Triage 7 days We assess severity, confirm the vulnerability, and estimate timeline -Status Update Every 7 days Regular updates on remediation progress -Resolution 90 days Target for fix development and release (complex issues may take longer) -Disclosure 90 days Public disclosure after fix is available (coordinated with you) - - Note: These are targets, not guarantees. Complex vulnerabilities may require more time. We'll communicate openly about any delays. - -Disclosure Policy - -We follow coordinated disclosure (also known as responsible disclosure): - - You report the vulnerability privately - We acknowledge and begin investigation - We develop a fix and prepare a release - We coordinate disclosure timing with you - We publish security advisory and fix simultaneously - You may publish your research after disclosure - -Our Commitments - - We will not take legal action against researchers who follow this policy - We will work with you to understand and resolve the issue - We will credit you in the security advisory (unless you prefer anonymity) - We will notify you before public disclosure - We will publish advisories with sufficient detail for users to assess risk - -Your Commitments - - Report vulnerabilities promptly after discovery - Give us reasonable time to address the issue before disclosure - Do not access, modify, or delete data beyond what's necessary to demonstrate the vulnerability - Do not degrade service availability (no DoS testing on production) - Do not share vulnerability details with others until coordinated disclosure - -Disclosure Timeline - -Day 0 You report vulnerability -Day 1-2 We acknowledge receipt -Day 7 We confirm vulnerability and share initial assessment -Day 7-90 We develop and test fix -Day 90 Coordinated public disclosure - (earlier if fix is ready; later by mutual agreement) - -If we cannot reach agreement on disclosure timing, we default to 90 days from your initial report. -Scope -In Scope ✅ - -The following are within scope for security research: - - This repository (hyperpolymath/terrapin-ssg) and all its code - Official releases and packages published from this repository - Documentation that could lead to security issues - Build and deployment configurations in this repository - Dependencies (report here, we'll coordinate with upstream) - -Out of Scope ❌ - -The following are not in scope: - - Third-party services we integrate with (report directly to them) - Social engineering attacks against maintainers - Physical security - Denial of service attacks against production infrastructure - Spam, phishing, or other non-technical attacks - Issues already reported or publicly known - Theoretical vulnerabilities without proof of concept - -Qualifying Vulnerabilities - -We're particularly interested in: - - Remote code execution - SQL injection, command injection, code injection - Authentication/authorisation bypass - Cross-site scripting (XSS) and cross-site request forgery (CSRF) - Server-side request forgery (SSRF) - Path traversal / local file inclusion - Information disclosure (credentials, PII, secrets) - Cryptographic weaknesses - Deserialisation vulnerabilities - Memory safety issues (buffer overflows, use-after-free, etc.) - Supply chain vulnerabilities (dependency confusion, etc.) - Significant logic flaws - -Non-Qualifying Issues - -The following generally do not qualify as security vulnerabilities: - - Missing security headers on non-sensitive pages - Clickjacking on pages without sensitive actions - Self-XSS (requires victim to paste code) - Missing rate limiting (unless it enables a specific attack) - Username/email enumeration (unless high-risk context) - Missing cookie flags on non-sensitive cookies - Software version disclosure - Verbose error messages (unless exposing secrets) - Best practice deviations without demonstrable impact - -Safe Harbour - -We support security research conducted in good faith. -Our Promise - -If you conduct security research in accordance with this policy: - - ✅ We will not initiate legal action against you - ✅ We will not report your activity to law enforcement - ✅ We will work with you in good faith to resolve issues - ✅ We consider your research authorised under the Computer Fraud and Abuse Act (CFAA), UK Computer Misuse Act, and similar laws - ✅ We waive any potential claim against you for circumvention of security controls - -Good Faith Requirements - -To qualify for safe harbour, you must: - - Comply with this security policy - Report vulnerabilities promptly - Avoid privacy violations (do not access others' data) - Avoid service degradation (no destructive testing) - Not exploit vulnerabilities beyond proof-of-concept - Not use vulnerabilities for profit (beyond bug bounties where offered) - - ⚠️ Important: This safe harbour does not extend to third-party systems. Always check their policies before testing. - -Recognition - -We believe in recognising security researchers who help us improve. -Hall of Fame - -Researchers who report valid vulnerabilities will be acknowledged in our Security Acknowledgments (unless they prefer anonymity). - -Recognition includes: - - Your name (or chosen alias) - Link to your website/profile (optional) - Brief description of the vulnerability class - Date of report - -What We Offer - - ✅ Public credit in security advisories - ✅ Acknowledgment in release notes - ✅ Entry in our Hall of Fame - ✅ Reference/recommendation letter upon request (for significant findings) - -What We Don't Currently Offer - - ❌ Monetary bug bounties - ❌ Hardware or swag - ❌ Paid security research contracts - - Note: We're a community project with limited resources. Your contributions help everyone who uses this software. - -Security Updates -Receiving Updates - -To stay informed about security updates: - - Watch this repository: Click "Watch" → "Custom" → Select "Security alerts" - GitHub Security Advisories: Published at Security Advisories - Release notes: Security fixes noted in CHANGELOG - -Update Policy -Severity Response -Critical/High Patch release as soon as fix is ready -Medium Included in next scheduled release (or earlier) -Low Included in next scheduled release -Supported Versions -Version Supported Notes -main branch ✅ Yes Latest development -Latest release ✅ Yes Current stable -Previous minor release ✅ Yes Security fixes backported -Older versions ❌ No Please upgrade -Security Best Practices - -When using terrapin-ssg, we recommend: -General - - Keep dependencies up to date - Use the latest stable release - Subscribe to security notifications - Review configuration against security documentation - Follow principle of least privilege - -For Contributors - - Never commit secrets, credentials, or API keys - Use signed commits (git config commit.gpgsign true) - Review dependencies before adding them - Run security linters locally before pushing - Report any concerns about existing code - -Additional Resources - - Our PGP Public Key - Security Advisories - Changelog - Contributing Guidelines - CVE Database - CVSS Calculator - -Contact -Purpose Contact -Security issues Report via GitHub or security@hyperpolymath.org -General questions GitHub Discussions -Other enquiries See README for contact information -Policy Changes - -This security policy may be updated from time to time. Significant changes will be: - - Committed to this repository with a clear commit message - Noted in the changelog - Announced via GitHub Discussions (for major changes) - -Thank you for helping keep terrapin-ssg and its users safe. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/ada/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/ada/ABI-FFI-README.adoc new file mode 100644 index 00000000..e958d332 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/ada/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== ADA ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/ada.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libada.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +ada/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── ada.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── ada.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/ada.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "ada.h" + +int main() { + void* handle = ada_init(); + if (!handle) return 1; + + int result = ada_process(handle, 42); + if (result != 0) { + const char* err = ada_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + ada_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lada -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import ADA.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "ada")] +extern "C" { + fn ada_init() -> *mut std::ffi::c_void; + fn ada_free(handle: *mut std::ffi::c_void); + fn ada_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = ada_init(); + assert!(!handle.is_null()); + + let result = ada_process(handle, 42); + assert_eq!(result, 0); + + ada_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libada = "libada" + +function init() + handle = ccall((:ada_init, libada), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:ada_process, libada), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:ada_free, libada), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/ada.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/ada/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/ada/ABI-FFI-README.md deleted file mode 100644 index c9cb98b9..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/ada/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# ADA ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/ada.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libada.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -ada/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── ada.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── ada.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/ada.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "ada.h" - -int main() { - void* handle = ada_init(); - if (!handle) return 1; - - int result = ada_process(handle, 42); - if (result != 0) { - const char* err = ada_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - ada_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lada -L./zig-out/lib -``` - -### From Idris2 - -```idris -import ADA.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "ada")] -extern "C" { - fn ada_init() -> *mut std::ffi::c_void; - fn ada_free(handle: *mut std::ffi::c_void); - fn ada_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = ada_init(); - assert!(!handle.is_null()); - - let result = ada_process(handle, 42); - assert_eq!(result, 0); - - ada_free(handle); - } -} -``` - -### From Julia - -```julia -const libada = "libada" - -function init() - handle = ccall((:ada_init, libada), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:ada_process, libada), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:ada_free, libada), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/ada.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/ada/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/ada/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/ada/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/ada/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/ada/CODE_OF_CONDUCT.md deleted file mode 100644 index caeda1c6..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/ada/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,27 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. - diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/ada/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/ada/CONTRIBUTING.adoc index eb045d61..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/ada/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/ada/CONTRIBUTING.adoc @@ -1,20 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/ada/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/ada/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/ada/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/ada/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/ada/README.adoc index 99d06e54..339286c8 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/ada/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/ada/README.adoc @@ -1,632 +1,83 @@ -= asdf-ada +== asdf-ada -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] -image:https://img.shields.io/badge/Philosophy-Palimpsest-indigo.svg[Palimpsest,link="https://github.com/hyperpolymath/palimpsest-license"] +https://github.com/hyperpolymath/asdf-ada-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-ada-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-ada-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-ada-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] +https://asdf-vm.com[asdf] plugin for +https://www.adacore.com/community[GNAT Ada Compiler]. -:author: hyperpolymath -:revnumber: 0.1.0 -:toc: macro -:toclevels: 3 -:icons: font -:source-highlighter: rouge -:experimental: -:url-asdf: https://asdf-vm.com -:url-gnat: https://www.adacore.com/download -:url-alire: https://alire.ada.dev -:url-ada-lang: https://ada-lang.io -:url-repo: https://github.com/hyperpolymath/asdf-ada-plugin +Ada compiler from AdaCore. -image:https://img.shields.io/github/license/hyperpolymath/asdf-ada-plugin?style=flat-square[License,link=LICENSE] -image:https://img.shields.io/github/v/release/hyperpolymath/asdf-ada-plugin?style=flat-square[Release,link={url-repo}/releases] -image:https://img.shields.io/github/actions/workflow/status/hyperpolymath/asdf-ada-plugin/ci.yml?branch=main&style=flat-square[Build Status,link={url-repo}/actions] -image:https://img.shields.io/badge/asdf-plugin-blue?style=flat-square[asdf Plugin,link={url-asdf}] +=== Contents -[.lead] -An {url-asdf}[asdf] plugin to manage https://ada-lang.io[Ada/GNAT] compiler versions seamlessly across projects. - -toc::[] - -== Overview - -=== What is Ada? - -https://ada-lang.io[Ada] is a structured, statically typed, imperative, and object-oriented high-level programming language designed for safety-critical and mission-critical systems. Originally developed in the 1980s for the U.S. Department of Defense, Ada is renowned for: - -* **Strong typing** — Catches errors at compile time rather than runtime -* **Built-in concurrency** — Native tasking support for parallel programming -* **Contract-based programming** — Pre/post conditions and type invariants -* **Real-time systems support** — Deterministic behavior for embedded systems -* **Long-term maintainability** — Designed for systems with 30+ year lifecycles - -Ada is used in aerospace (Boeing, Airbus), defense systems, rail transportation, medical devices, and financial systems where reliability is paramount. - -=== What is asdf? - -{url-asdf}[asdf] is a universal version manager that allows you to manage multiple runtime versions with a single CLI tool. Instead of juggling separate version managers for each language, asdf provides one interface to rule them all. - -=== Why asdf-ada? - -Managing Ada/GNAT compiler versions traditionally requires manual downloads, environment variable configuration, and careful PATH management. `asdf-ada` simplifies this by providing: - -[cols="1,3"] -|=== -|Feature |Benefit - -|**Version Switching** -|Switch between GNAT versions instantly per project - -|**Project Isolation** -|Each project can specify its required Ada version via `.tool-versions` - -|**Reproducible Builds** -|Team members and CI/CD pipelines use identical compiler versions - -|**Multiple Distributions** -|Support for FSF GNAT, GNAT Community, and Alire-managed toolchains - -|**Cross-Platform** -|Works on Linux, macOS, and Windows (via WSL) -|=== - -== Prerequisites - -=== System Requirements - -[cols="1,2,3"] -|=== -|Platform |Minimum Version |Notes - -|**Linux** -|Ubuntu 20.04+ / Fedora 35+ / Debian 11+ -|x86_64 and aarch64 supported - -|**macOS** -|macOS 11 (Big Sur)+ -|Intel and Apple Silicon (M1/M2/M3) - -|**Windows** -|Windows 10+ with WSL2 -|Native support planned for future releases -|=== +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] === Dependencies -Before installing the plugin, ensure you have the following: - -[source,bash] ----- -# Debian/Ubuntu -sudo apt-get update -sudo apt-get install -y curl git build-essential libc6-dev - -# Fedora/RHEL -sudo dnf install -y curl git gcc glibc-devel - -# macOS (via Homebrew) -brew install curl git -xcode-select --install # For build tools - -# Arch Linux -sudo pacman -S curl git base-devel ----- - -=== asdf Installation - -If you haven't installed asdf yet: - -[source,bash] ----- -# Clone asdf -git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.0 - -# Add to your shell (bash) -echo '. "$HOME/.asdf/asdf.sh"' >> ~/.bashrc -echo '. "$HOME/.asdf/completions/asdf.bash"' >> ~/.bashrc - -# Add to your shell (zsh) -echo '. "$HOME/.asdf/asdf.sh"' >> ~/.zshrc +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -# Add to your shell (fish) -echo 'source ~/.asdf/asdf.fish' >> ~/.config/fish/config.fish +=== Install -# Reload your shell -exec $SHELL ----- - -== Installation - -=== Adding the Plugin +Plugin: [source,bash] ---- -# Add the asdf-ada plugin asdf plugin add ada https://github.com/hyperpolymath/asdf-ada-plugin.git - -# Verify installation -asdf plugin list ---- -=== Installing Ada/GNAT Versions +ada: [source,bash] ---- -# List all available versions -asdf list all ada - -# Install a specific version -asdf install ada 14.1.0 # FSF GNAT 14.1.0 -asdf install ada community-2021 # GNAT Community 2021 -asdf install ada alire-latest # Latest via Alire +# Show all installable versions +asdf list-all ada -# Install the latest stable version +# Install specific version asdf install ada latest ----- - -=== Setting the Version - -[source,bash] ----- -# Set global default (used when no local version is specified) -asdf global ada 14.1.0 - -# Set local version for current project (creates .tool-versions) -asdf local ada 14.1.0 - -# Set version for current shell session only -asdf shell ada 14.1.0 -# Verify the active version -asdf current ada -gnatmake --version ----- - -== Usage - -=== Project Configuration +# Set a version globally (in your ~/.tool-versions file) +asdf global ada latest -Create a `.tool-versions` file in your project root: - -[source] ----- -ada 14.1.0 +# Now ada commands are available +ada --version ---- -When you `cd` into the project directory, asdf automatically activates the specified version. +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -=== Available Commands +=== Usage [source,bash] ---- # List installed versions asdf list ada -# Show current version -asdf current ada +# Set local version for current directory +asdf local ada # Uninstall a version -asdf uninstall ada 13.2.0 - -# Reshim after installing Ada tools (e.g., via Alire) -asdf reshim ada - -# Show installation path -asdf where ada 14.1.0 ----- - -=== Environment Variables - -The plugin respects and sets the following environment variables: - -[cols="2,3,2"] -|=== -|Variable |Description |Default - -|`ASDF_ADA_DISTRIBUTION` -|Preferred distribution (`fsf`, `community`, `alire`) -|`fsf` - -|`ASDF_ADA_MIRROR` -|Custom mirror URL for downloads -|Official sources - -|`ASDF_ADA_SKIP_VERIFY` -|Skip checksum verification (`true`/`false`) -|`false` - -|`ASDF_ADA_INSTALL_GPRBUILD` -|Auto-install GPRbuild (`true`/`false`) -|`true` -|=== - -=== Integration with Build Tools - -==== GPRbuild - -[source,bash] ----- -# GPRbuild is included with most GNAT installations -gprbuild --version - -# Build an Ada project -gprbuild -P my_project.gpr ----- - -==== Alire - -{url-alire}[Alire] is Ada's package manager. You can use it alongside asdf: - -[source,bash] ----- -# Install Alire separately or use asdf-managed version -asdf install ada alire-latest - -# Initialize an Alire project -alr init my_project -cd my_project -alr build ----- - -==== SPARK Formal Verification - -For SPARK Pro users: - -[source,bash] ----- -# SPARK is included in GNAT Community editions -gnatprove --version - -# Run formal verification -gnatprove -P my_project.gpr ----- - -== Supported Versions - -=== FSF GNAT (GNU Ada) - -Official GNU Compiler Collection Ada frontend: - -[source] ----- -14.1.0, 14.0.0, 13.3.0, 13.2.0, 13.1.0 -12.4.0, 12.3.0, 12.2.0, 12.1.0 -11.5.0, 11.4.0, 11.3.0, 11.2.0, 11.1.0 -10.5.0, 10.4.0, 10.3.0 ----- - -=== GNAT Community Edition - -AdaCore's free community releases (discontinued after 2021): - -[source] +asdf uninstall ada ---- -community-2021 -community-2020 -community-2019 ----- - -=== Alire Toolchains - -Managed via the Alire package manager: -[source] ----- -alire-latest # Latest available via Alire -alire-native # Native toolchain via Alire ----- - -== Configuration - -=== Plugin Configuration File - -Create `~/.config/asdf-ada/config` for persistent settings: - -[source,ini] ----- -# Default distribution preference -distribution = fsf - -# Download mirror (leave empty for official sources) -mirror = - -# Verify checksums (recommended) -verify_checksums = true - -# Install GPRbuild automatically -install_gprbuild = true - -# Concurrent downloads -parallel_downloads = 4 ----- - -=== Platform-Specific Notes - -==== macOS Apple Silicon - -Native ARM64 builds are available for GNAT 13.1.0+. For older versions, Rosetta 2 emulation is used automatically. - -==== Linux ARM64 - -ARM64 builds are provided for: -- Raspberry Pi 4/5 (64-bit OS) -- AWS Graviton instances -- Other aarch64 systems - -==== Windows (WSL2) - -[source,bash] ----- -# Install WSL2 with Ubuntu -wsl --install -d Ubuntu - -# Inside WSL, install asdf and the plugin as normal -# See the Linux installation instructions above ----- - -== Troubleshooting - -=== Common Issues - -[qanda] -Version not found when running `gnatmake`:: -Run `asdf reshim ada` after installation and ensure your shell is properly configured. - -Download fails with SSL errors:: -Ensure `ca-certificates` is installed: `sudo apt-get install ca-certificates` - -"Permission denied" during installation:: -Check write permissions for `~/.asdf/installs/ada/` - -Slow downloads:: -Set `ASDF_ADA_MIRROR` to a geographically closer mirror. - -=== Getting Help - -1. Check the link:{url-repo}/issues[GitHub Issues] for known problems -2. Join the https://gitter.im/ada-lang/Lobby[Ada community chat] -3. Open a https://github.com/hyperpolymath/asdf-ada-plugin/issues/new[new issue] with: - - Your OS and version - - asdf version (`asdf --version`) - - Plugin version - - Full error output - -== Contributing - -We welcome contributions! Please see our link:CONTRIBUTING.adoc[Contributing Guide] for details. - -=== Quick Start for Contributors - -[source,bash] ----- -# Fork and clone -git clone https://github.com/YOUR_USERNAME/asdf-ada-plugin.git -cd asdf-ada-plugin - -# Create a feature branch -git checkout -b feature/your-feature-name - -# Make changes and test -./scripts/test.sh - -# Submit a pull request ----- - -=== Code of Conduct - -This project adheres to the https://www.contributor-covenant.org/[Contributor Covenant]. Please read our link:CODE_OF_CONDUCT.adoc[Code of Conduct] before participating. - -== Roadmap - -This roadmap outlines the planned development phases for `asdf-ada`. - -=== Phase 1: Foundation (v0.1.0) icon:wrench[] - -*Status:* 🚧 In Progress - -[%interactive] -* [ ] Core plugin structure following asdf plugin template -* [ ] `bin/list-all` — Fetch available GNAT versions from upstream -* [ ] `bin/download` — Download GNAT releases -* [ ] `bin/install` — Install and configure GNAT toolchain -* [ ] `bin/latest-stable` — Resolve latest stable version -* [ ] Basic FSF GNAT support (Linux x86_64) -* [ ] README and initial documentation -* [ ] GitHub Actions CI/CD pipeline -* [ ] Basic test suite using Bats - -=== Phase 2: Multi-Platform Support (v0.2.0) icon:desktop[] - -*Status:* 📋 Planned - -[%interactive] -* [ ] macOS x86_64 support -* [ ] macOS ARM64 (Apple Silicon) support -* [ ] Linux ARM64 support -* [ ] Windows WSL2 documentation and testing -* [ ] Checksum verification for all downloads -* [ ] Progress indicators during download/install -* [ ] Improved error messages and logging - -=== Phase 3: Extended Distribution Support (v0.3.0) icon:cubes[] - -*Status:* 📋 Planned - -[%interactive] -* [ ] GNAT Community Edition support (2019-2021) -* [ ] Alire toolchain integration -* [ ] AdaCore GNAT Pro stub support (license required) -* [ ] Custom mirror configuration -* [ ] Version aliases (`lts`, `stable`, `latest`) -* [ ] `bin/help` plugin subcommands - -=== Phase 4: Developer Experience (v0.4.0) icon:star[] - -*Status:* 📋 Planned - -[%interactive] -* [ ] Automatic GPRbuild installation -* [ ] GNATcov integration -* [ ] SPARK tools inclusion -* [ ] Shell completions (bash, zsh, fish) -* [ ] Version constraint solving (semver support) -* [ ] `asdf-ada doctor` command for diagnostics - -=== Phase 5: Ecosystem Integration (v0.5.0) icon:plug[] - -*Status:* 📋 Planned - -[%interactive] -* [ ] Alire crate template generation -* [ ] VS Code Ada extension compatibility documentation -* [ ] GNAT Studio integration notes -* [ ] Docker/container image publishing -* [ ] CI/CD examples (GitHub Actions, GitLab CI, Jenkins) -* [ ] Guix flake support - -=== Phase 6: Enterprise & Polish (v1.0.0) icon:building[] - -*Status:* 🔮 Future - -[%interactive] -* [ ] Stable API with semantic versioning -* [ ] Comprehensive test coverage (90%+) -* [ ] Full documentation with tutorials -* [ ] Offline installation support -* [ ] Corporate proxy support -* [ ] Signed releases -* [ ] Official asdf plugin registry listing -* [ ] Community governance model - -=== Future Ideas icon:lightbulb[] - -These features are under consideration for post-1.0 releases: - -* **Cross-compilation toolchains** — ARM bare-metal, RISC-V targets -* **GNAT-LLVM support** — LLVM-based Ada compiler backend -* **Version diffing** — Show changelog between versions -* **Performance profiling integration** — GNATbench-like features -* **IDE project generation** — Templates for various editors -* **Dependency caching** — Speed up clean installs -* **Native Windows support** — Without WSL requirement - -== Mirrors - -This repository is mirrored to: - -* https://gitlab.com/hyperpolymath/asdf-ada-plugin[GitLab] -* https://codeberg.org/hyperpolymath/asdf-ada-plugin[Codeberg] -* https://bitbucket.org/hyperpolymath/asdf-ada-plugin[Bitbucket] - -== Related Projects - -* {url-asdf}[asdf] — The universal version manager -* {url-gnat}[GNAT Downloads] — Official AdaCore downloads -* {url-alire}[Alire] — Ada/SPARK package manager -* {url-ada-lang}[Ada Programming Language] — Official Ada resources -* https://learn.adacore.com[learn.adacore.com] — Free Ada/SPARK tutorials -* https://github.com/ohenley/awesome-ada[Awesome Ada] — Curated Ada resources - -== Hyperpolymath asdf Ecosystem - -This plugin is part of the **Hyperpolymath asdf ecosystem**, a layered architecture for managing developer tool versions. - -=== Ecosystem Architecture - -[source] ----- - ┌──────────────────────────┐ - │ asdf-control-tower │ ← Layer 3: Presentation - │ (docs + dashboard) │ - └───────────┬──────────────┘ - │ -┌──────────────────────────┐ │ ┌──────────────────────────┐ -│ asdf-ui-plugin │────┼────│ asdf-plugin-configurator │ ← Layer 2–3 -│ (visual UX; planned) │ │ │ (Rust CLI; config/policy)│ -└──────────────────────────┘ │ └──────────────────────────┘ - │ - ┌───────────┴───────────┐ - │ asdf-metaiconic-plugin│ ← Layer 1: Registry - │ (registry + schema) │ - └───────────┬───────────┘ - │ - ┌────────────────────────────────────────────────┐ - │ Individual asdf tool plugins (Layer 5) │ - │ │ - │ ★ asdf-ada-plugin ← YOU ARE HERE │ - │ asdf-neo4j-plugin │ - │ asdf-ghjk │ - │ …(68+ installable plugins) │ - └────────────────────────────────────────────────┘ ----- - -=== Layer Descriptions - -[cols="1,2,4"] -|=== -|Layer |Component |Purpose - -|**Layer 0** -|Infrastructure Spine -|Multi-forge mirroring, instant-sync, policy constraints (`.claude/CLAUDE.md`), community docs — present across all repos - -|**Layer 1** -|https://github.com/hyperpolymath/asdf-metaiconic-plugin[asdf-metaiconic-plugin] -|Canonical metadata registry: `registry/plugins.yaml`, category definitions, quality metrics, icon/branding standards - -|**Layer 2** -|https://github.com/hyperpolymath/asdf-plugin-configurator[asdf-plugin-configurator] -|Rust CLI for declarative plugin configuration — apply policy to machines/projects, consume registry for validation - -|**Layer 3** -|https://github.com/hyperpolymath/asdf-control-tower[asdf-control-tower] + https://github.com/hyperpolymath/asdf-ui-plugin[asdf-ui-plugin] -|Human-facing dashboard, documentation hub, visual discovery UI (planned) - -|**Layer 4** -|Domain Collections -|Category "umbrella" plugins (e.g., `asdf-security-plugin` for curated security toolsets) - -|**Layer 5** -|**Tool Plugins** ★ -|**Actual installable units** — implements `bin/list-all`, `bin/download`, `bin/install`, `bin/latest-stable`. This repo (`asdf-ada-plugin`) lives here. -|=== - -=== This Plugin's Role - -`asdf-ada-plugin` is a **Layer 5 tool plugin** — the actual "workhorse" that asdf uses to install and manage Ada/GNAT compiler versions. It: - -* Implements the asdf plugin contract (`bin/list-all`, `bin/download`, `bin/install`, `bin/latest-stable`) -* Fetches releases from the https://github.com/alire-project/GNAT-FSF-builds[GNAT-FSF-builds] upstream -* Provides checksum verification, multi-platform support, and robust error handling -* Is indexed by `asdf-metaiconic-plugin` for ecosystem-wide discovery -* Can be configured via `asdf-plugin-configurator` for team/project consistency - -=== Ecosystem Links - -* https://github.com/hyperpolymath/asdf-control-tower[asdf-control-tower] — Ecosystem documentation hub -* https://github.com/hyperpolymath/asdf-metaiconic-plugin[asdf-metaiconic-plugin] — Plugin registry and metadata -* https://github.com/hyperpolymath/asdf-plugin-configurator[asdf-plugin-configurator] — Policy enforcement CLI - -== License - -This project is licensed under the Palimpsest-MPL License v3.0 or later. -See the link:LICENSE[LICENSE] file for details. - -[source] ----- -SPDX-License-Identifier: CC-BY-SA-4.0 ----- +=== Contributing -== Acknowledgments +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. -* The {url-asdf}[asdf] team for creating the plugin ecosystem -* https://www.adacore.com[AdaCore] for maintaining GNAT -* The Ada community for keeping the language thriving -* All contributors who help improve this plugin +=== License ---- +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -[.text-center] -Made with ❤️ for the Ada community +''''' -[.text-center] -link:#[⬆ Back to Top] +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/ada/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/ada/README.md deleted file mode 100644 index 2caccbaa..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/ada/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-ada - -[![Build](https://github.com/hyperpolymath/asdf-ada-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-ada-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-ada-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-ada-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [GNAT Ada Compiler](https://www.adacore.com/community). - -Ada compiler from AdaCore. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add ada https://github.com/hyperpolymath/asdf-ada-plugin.git -``` - -ada: - -```bash -# Show all installable versions -asdf list-all ada - -# Install specific version -asdf install ada latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global ada latest - -# Now ada commands are available -ada --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list ada - -# Set local version for current directory -asdf local ada - -# Uninstall a version -asdf uninstall ada -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/ada/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/ada/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/ada/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/ada/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/ada/SECURITY.md deleted file mode 100644 index 159a0b7a..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/ada/SECURITY.md +++ /dev/null @@ -1,25 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection - diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/age/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/age/ABI-FFI-README.adoc new file mode 100644 index 00000000..e8fa780b --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/age/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== AGE ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/age.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libage.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +age/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── age.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── age.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/age.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "age.h" + +int main() { + void* handle = age_init(); + if (!handle) return 1; + + int result = age_process(handle, 42); + if (result != 0) { + const char* err = age_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + age_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lage -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import AGE.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "age")] +extern "C" { + fn age_init() -> *mut std::ffi::c_void; + fn age_free(handle: *mut std::ffi::c_void); + fn age_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = age_init(); + assert!(!handle.is_null()); + + let result = age_process(handle, 42); + assert_eq!(result, 0); + + age_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libage = "libage" + +function init() + handle = ccall((:age_init, libage), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:age_process, libage), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:age_free, libage), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/age.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/age/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/age/ABI-FFI-README.md deleted file mode 100644 index 1bcc978a..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/age/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# AGE ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/age.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libage.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -age/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── age.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── age.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/age.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "age.h" - -int main() { - void* handle = age_init(); - if (!handle) return 1; - - int result = age_process(handle, 42); - if (result != 0) { - const char* err = age_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - age_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lage -L./zig-out/lib -``` - -### From Idris2 - -```idris -import AGE.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "age")] -extern "C" { - fn age_init() -> *mut std::ffi::c_void; - fn age_free(handle: *mut std::ffi::c_void); - fn age_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = age_init(); - assert!(!handle.is_null()); - - let result = age_process(handle, 42); - assert_eq!(result, 0); - - age_free(handle); - } -} -``` - -### From Julia - -```julia -const libage = "libage" - -function init() - handle = ccall((:age_init, libage), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:age_process, libage), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:age_free, libage), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/age.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/age/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/age/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/age/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/age/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/age/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/age/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/age/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/age/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/age/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/age/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/age/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/age/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/age/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/age/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/age/README.adoc index d08e1dd2..08505a04 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/age/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/age/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-age -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-age-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-age-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-age-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-age-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://age-encryption.org[age]. -**All repos with foreign function interfaces MUST follow this standard:** +Simple, modern file encryption. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add age https://github.com/hyperpolymath/asdf-age-plugin.git +---- -=== Web Projects +age: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all age -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install age latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global age latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now age commands are available +age --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list age -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local age -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall age ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/age/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/age/README.md deleted file mode 100644 index 4f2a10bd..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/age/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-age - -[![Build](https://github.com/hyperpolymath/asdf-age-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-age-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-age-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-age-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [age](https://age-encryption.org). - -Simple, modern file encryption. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add age https://github.com/hyperpolymath/asdf-age-plugin.git -``` - -age: - -```bash -# Show all installable versions -asdf list-all age - -# Install specific version -asdf install age latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global age latest - -# Now age commands are available -age --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list age - -# Set local version for current directory -asdf local age - -# Uninstall a version -asdf uninstall age -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/age/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/age/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/age/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/age/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/age/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/age/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/apko/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/apko/ABI-FFI-README.adoc new file mode 100644 index 00000000..cb968d83 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/apko/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== APKO ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/apko.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libapko.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +apko/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── apko.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── apko.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/apko.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "apko.h" + +int main() { + void* handle = apko_init(); + if (!handle) return 1; + + int result = apko_process(handle, 42); + if (result != 0) { + const char* err = apko_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + apko_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lapko -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import APKO.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "apko")] +extern "C" { + fn apko_init() -> *mut std::ffi::c_void; + fn apko_free(handle: *mut std::ffi::c_void); + fn apko_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = apko_init(); + assert!(!handle.is_null()); + + let result = apko_process(handle, 42); + assert_eq!(result, 0); + + apko_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libapko = "libapko" + +function init() + handle = ccall((:apko_init, libapko), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:apko_process, libapko), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:apko_free, libapko), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/apko.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/apko/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/apko/ABI-FFI-README.md deleted file mode 100644 index b4a76026..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/apko/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# APKO ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/apko.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libapko.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -apko/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── apko.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── apko.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/apko.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "apko.h" - -int main() { - void* handle = apko_init(); - if (!handle) return 1; - - int result = apko_process(handle, 42); - if (result != 0) { - const char* err = apko_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - apko_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lapko -L./zig-out/lib -``` - -### From Idris2 - -```idris -import APKO.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "apko")] -extern "C" { - fn apko_init() -> *mut std::ffi::c_void; - fn apko_free(handle: *mut std::ffi::c_void); - fn apko_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = apko_init(); - assert!(!handle.is_null()); - - let result = apko_process(handle, 42); - assert_eq!(result, 0); - - apko_free(handle); - } -} -``` - -### From Julia - -```julia -const libapko = "libapko" - -function init() - handle = ccall((:apko_init, libapko), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:apko_process, libapko), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:apko_free, libapko), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/apko.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/apko/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/apko/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/apko/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/apko/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/apko/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/apko/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/apko/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/apko/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/apko/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/apko/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/apko/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/apko/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/apko/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/apko/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/apko/README.adoc index d08e1dd2..349259da 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/apko/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/apko/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-apko -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-apko-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-apko-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-apko-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-apko-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://github.com/chainguard-dev/apko[apko]. -**All repos with foreign function interfaces MUST follow this standard:** +OCI images from APK packages. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add apko https://github.com/hyperpolymath/asdf-apko-plugin.git +---- -=== Web Projects +apko: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all apko -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install apko latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global apko latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now apko commands are available +apko --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list apko -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local apko -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall apko ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/apko/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/apko/README.md deleted file mode 100644 index c43254a5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/apko/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-apko - -[![Build](https://github.com/hyperpolymath/asdf-apko-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-apko-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-apko-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-apko-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [apko](https://github.com/chainguard-dev/apko). - -OCI images from APK packages. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add apko https://github.com/hyperpolymath/asdf-apko-plugin.git -``` - -apko: - -```bash -# Show all installable versions -asdf list-all apko - -# Install specific version -asdf install apko latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global apko latest - -# Now apko commands are available -apko --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list apko - -# Set local version for current directory -asdf local apko - -# Uninstall a version -asdf uninstall apko -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/apko/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/apko/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/apko/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/apko/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/apko/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/apko/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/arangodb/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/arangodb/ABI-FFI-README.adoc new file mode 100644 index 00000000..f35cc374 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/arangodb/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== ARANGODB ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/arangodb.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libarangodb.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +arangodb/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── arangodb.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── arangodb.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/arangodb.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "arangodb.h" + +int main() { + void* handle = arangodb_init(); + if (!handle) return 1; + + int result = arangodb_process(handle, 42); + if (result != 0) { + const char* err = arangodb_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + arangodb_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -larangodb -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import ARANGODB.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "arangodb")] +extern "C" { + fn arangodb_init() -> *mut std::ffi::c_void; + fn arangodb_free(handle: *mut std::ffi::c_void); + fn arangodb_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = arangodb_init(); + assert!(!handle.is_null()); + + let result = arangodb_process(handle, 42); + assert_eq!(result, 0); + + arangodb_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libarangodb = "libarangodb" + +function init() + handle = ccall((:arangodb_init, libarangodb), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:arangodb_process, libarangodb), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:arangodb_free, libarangodb), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/arangodb.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/arangodb/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/arangodb/ABI-FFI-README.md deleted file mode 100644 index 46999d03..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/arangodb/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# ARANGODB ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/arangodb.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libarangodb.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -arangodb/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── arangodb.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── arangodb.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/arangodb.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "arangodb.h" - -int main() { - void* handle = arangodb_init(); - if (!handle) return 1; - - int result = arangodb_process(handle, 42); - if (result != 0) { - const char* err = arangodb_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - arangodb_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -larangodb -L./zig-out/lib -``` - -### From Idris2 - -```idris -import ARANGODB.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "arangodb")] -extern "C" { - fn arangodb_init() -> *mut std::ffi::c_void; - fn arangodb_free(handle: *mut std::ffi::c_void); - fn arangodb_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = arangodb_init(); - assert!(!handle.is_null()); - - let result = arangodb_process(handle, 42); - assert_eq!(result, 0); - - arangodb_free(handle); - } -} -``` - -### From Julia - -```julia -const libarangodb = "libarangodb" - -function init() - handle = ccall((:arangodb_init, libarangodb), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:arangodb_process, libarangodb), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:arangodb_free, libarangodb), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/arangodb.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/arangodb/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/arangodb/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/arangodb/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/arangodb/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/arangodb/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/arangodb/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/arangodb/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/arangodb/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/arangodb/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/arangodb/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/arangodb/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/arangodb/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/arangodb/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/arangodb/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/arangodb/README.adoc index d08e1dd2..43a7cc7a 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/arangodb/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/arangodb/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-arangodb -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-arangodb-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-arangodb-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-arangodb-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-arangodb-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://www.arangodb.com[ArangoDB]. -**All repos with foreign function interfaces MUST follow this standard:** +Multi-model NoSQL database. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add arangodb https://github.com/hyperpolymath/asdf-arangodb-plugin.git +---- -=== Web Projects +arangodb: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all arangodb -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install arangodb latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global arangodb latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now arangodb commands are available +arangodb --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list arangodb -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local arangodb -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall arangodb ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/arangodb/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/arangodb/README.md deleted file mode 100644 index 93bd52b9..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/arangodb/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-arangodb - -[![Build](https://github.com/hyperpolymath/asdf-arangodb-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-arangodb-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-arangodb-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-arangodb-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [ArangoDB](https://www.arangodb.com). - -Multi-model NoSQL database. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add arangodb https://github.com/hyperpolymath/asdf-arangodb-plugin.git -``` - -arangodb: - -```bash -# Show all installable versions -asdf list-all arangodb - -# Install specific version -asdf install arangodb latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global arangodb latest - -# Now arangodb commands are available -arangodb --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list arangodb - -# Set local version for current directory -asdf local arangodb - -# Uninstall a version -asdf uninstall arangodb -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/arangodb/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/arangodb/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/arangodb/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/arangodb/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/arangodb/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/arangodb/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/bebop/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/bebop/ABI-FFI-README.adoc new file mode 100644 index 00000000..357b2f75 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/bebop/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== BEBOP ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/bebop.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libbebop.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +bebop/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── bebop.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── bebop.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/bebop.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "bebop.h" + +int main() { + void* handle = bebop_init(); + if (!handle) return 1; + + int result = bebop_process(handle, 42); + if (result != 0) { + const char* err = bebop_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + bebop_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lbebop -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import BEBOP.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "bebop")] +extern "C" { + fn bebop_init() -> *mut std::ffi::c_void; + fn bebop_free(handle: *mut std::ffi::c_void); + fn bebop_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = bebop_init(); + assert!(!handle.is_null()); + + let result = bebop_process(handle, 42); + assert_eq!(result, 0); + + bebop_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libbebop = "libbebop" + +function init() + handle = ccall((:bebop_init, libbebop), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:bebop_process, libbebop), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:bebop_free, libbebop), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/bebop.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/bebop/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/bebop/ABI-FFI-README.md deleted file mode 100644 index a1726fec..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/bebop/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# BEBOP ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/bebop.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libbebop.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -bebop/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── bebop.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── bebop.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/bebop.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "bebop.h" - -int main() { - void* handle = bebop_init(); - if (!handle) return 1; - - int result = bebop_process(handle, 42); - if (result != 0) { - const char* err = bebop_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - bebop_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lbebop -L./zig-out/lib -``` - -### From Idris2 - -```idris -import BEBOP.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "bebop")] -extern "C" { - fn bebop_init() -> *mut std::ffi::c_void; - fn bebop_free(handle: *mut std::ffi::c_void); - fn bebop_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = bebop_init(); - assert!(!handle.is_null()); - - let result = bebop_process(handle, 42); - assert_eq!(result, 0); - - bebop_free(handle); - } -} -``` - -### From Julia - -```julia -const libbebop = "libbebop" - -function init() - handle = ccall((:bebop_init, libbebop), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:bebop_process, libbebop), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:bebop_free, libbebop), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/bebop.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/bebop/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/bebop/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/bebop/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/bebop/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/bebop/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/bebop/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/bebop/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/bebop/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/bebop/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/bebop/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/bebop/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/bebop/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/bebop/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/bebop/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/bebop/README.adoc index d08e1dd2..5665674a 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/bebop/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/bebop/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-bebop -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-bebop-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-bebop-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-bebop-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-bebop-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://bebop.sh[Bebop]. -**All repos with foreign function interfaces MUST follow this standard:** +Fast typed binary serialization. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add bebop https://github.com/hyperpolymath/asdf-bebop-plugin.git +---- -=== Web Projects +bebop: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all bebop -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install bebop latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global bebop latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now bebop commands are available +bebop --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list bebop -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local bebop -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall bebop ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/bebop/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/bebop/README.md deleted file mode 100644 index 320faa25..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/bebop/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-bebop - -[![Build](https://github.com/hyperpolymath/asdf-bebop-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-bebop-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-bebop-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-bebop-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Bebop](https://bebop.sh). - -Fast typed binary serialization. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add bebop https://github.com/hyperpolymath/asdf-bebop-plugin.git -``` - -bebop: - -```bash -# Show all installable versions -asdf list-all bebop - -# Install specific version -asdf install bebop latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global bebop latest - -# Now bebop commands are available -bebop --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list bebop - -# Set local version for current directory -asdf local bebop - -# Uninstall a version -asdf uninstall bebop -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/bebop/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/bebop/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/bebop/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/bebop/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/bebop/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/bebop/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/borg/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/borg/ABI-FFI-README.adoc new file mode 100644 index 00000000..66d4578e --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/borg/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== BORG ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/borg.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libborg.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +borg/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── borg.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── borg.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/borg.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "borg.h" + +int main() { + void* handle = borg_init(); + if (!handle) return 1; + + int result = borg_process(handle, 42); + if (result != 0) { + const char* err = borg_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + borg_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lborg -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import BORG.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "borg")] +extern "C" { + fn borg_init() -> *mut std::ffi::c_void; + fn borg_free(handle: *mut std::ffi::c_void); + fn borg_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = borg_init(); + assert!(!handle.is_null()); + + let result = borg_process(handle, 42); + assert_eq!(result, 0); + + borg_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libborg = "libborg" + +function init() + handle = ccall((:borg_init, libborg), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:borg_process, libborg), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:borg_free, libborg), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/borg.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/borg/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/borg/ABI-FFI-README.md deleted file mode 100644 index f2b06791..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/borg/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# BORG ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/borg.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libborg.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -borg/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── borg.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── borg.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/borg.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "borg.h" - -int main() { - void* handle = borg_init(); - if (!handle) return 1; - - int result = borg_process(handle, 42); - if (result != 0) { - const char* err = borg_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - borg_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lborg -L./zig-out/lib -``` - -### From Idris2 - -```idris -import BORG.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "borg")] -extern "C" { - fn borg_init() -> *mut std::ffi::c_void; - fn borg_free(handle: *mut std::ffi::c_void); - fn borg_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = borg_init(); - assert!(!handle.is_null()); - - let result = borg_process(handle, 42); - assert_eq!(result, 0); - - borg_free(handle); - } -} -``` - -### From Julia - -```julia -const libborg = "libborg" - -function init() - handle = ccall((:borg_init, libborg), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:borg_process, libborg), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:borg_free, libborg), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/borg.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/borg/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/borg/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/borg/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/borg/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/borg/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/borg/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/borg/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/borg/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/borg/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/borg/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/borg/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/borg/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/borg/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/borg/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/borg/README.adoc index d08e1dd2..a2d2855a 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/borg/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/borg/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-borg -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-borg-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-borg-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-borg-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-borg-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://www.borgbackup.org[BorgBackup]. -**All repos with foreign function interfaces MUST follow this standard:** +Deduplicating backup. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add borg https://github.com/hyperpolymath/asdf-borg-plugin.git +---- -=== Web Projects +borg: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all borg -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install borg latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global borg latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now borg commands are available +borg --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list borg -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local borg -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall borg ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/borg/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/borg/README.md deleted file mode 100644 index e66f490b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/borg/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-borg - -[![Build](https://github.com/hyperpolymath/asdf-borg-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-borg-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-borg-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-borg-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [BorgBackup](https://www.borgbackup.org). - -Deduplicating backup. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add borg https://github.com/hyperpolymath/asdf-borg-plugin.git -``` - -borg: - -```bash -# Show all installable versions -asdf list-all borg - -# Install specific version -asdf install borg latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global borg latest - -# Now borg commands are available -borg --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list borg - -# Set local version for current directory -asdf local borg - -# Uninstall a version -asdf uninstall borg -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/borg/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/borg/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/borg/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/borg/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/borg/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/borg/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/casket-ssg/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/casket-ssg/ABI-FFI-README.adoc new file mode 100644 index 00000000..97b3d3b7 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/casket-ssg/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== CASKET_SSG ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/casket-ssg.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libcasket-ssg.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +casket-ssg/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── casket-ssg.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── casket-ssg.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/casket-ssg.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "casket-ssg.h" + +int main() { + void* handle = casket-ssg_init(); + if (!handle) return 1; + + int result = casket-ssg_process(handle, 42); + if (result != 0) { + const char* err = casket-ssg_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + casket-ssg_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lcasket-ssg -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import CASKET_SSG.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "casket-ssg")] +extern "C" { + fn casket-ssg_init() -> *mut std::ffi::c_void; + fn casket-ssg_free(handle: *mut std::ffi::c_void); + fn casket-ssg_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = casket-ssg_init(); + assert!(!handle.is_null()); + + let result = casket-ssg_process(handle, 42); + assert_eq!(result, 0); + + casket-ssg_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libcasket-ssg = "libcasket-ssg" + +function init() + handle = ccall((:casket-ssg_init, libcasket-ssg), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:casket-ssg_process, libcasket-ssg), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:casket-ssg_free, libcasket-ssg), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/casket-ssg.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/casket-ssg/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/casket-ssg/ABI-FFI-README.md deleted file mode 100644 index e1ee045a..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/casket-ssg/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# CASKET_SSG ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/casket-ssg.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libcasket-ssg.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -casket-ssg/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── casket-ssg.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── casket-ssg.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/casket-ssg.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "casket-ssg.h" - -int main() { - void* handle = casket-ssg_init(); - if (!handle) return 1; - - int result = casket-ssg_process(handle, 42); - if (result != 0) { - const char* err = casket-ssg_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - casket-ssg_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lcasket-ssg -L./zig-out/lib -``` - -### From Idris2 - -```idris -import CASKET_SSG.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "casket-ssg")] -extern "C" { - fn casket-ssg_init() -> *mut std::ffi::c_void; - fn casket-ssg_free(handle: *mut std::ffi::c_void); - fn casket-ssg_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = casket-ssg_init(); - assert!(!handle.is_null()); - - let result = casket-ssg_process(handle, 42); - assert_eq!(result, 0); - - casket-ssg_free(handle); - } -} -``` - -### From Julia - -```julia -const libcasket-ssg = "libcasket-ssg" - -function init() - handle = ccall((:casket-ssg_init, libcasket-ssg), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:casket-ssg_process, libcasket-ssg), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:casket-ssg_free, libcasket-ssg), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/casket-ssg.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/casket-ssg/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/casket-ssg/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/casket-ssg/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/casket-ssg/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/casket-ssg/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/casket-ssg/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/casket-ssg/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/casket-ssg/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/casket-ssg/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/casket-ssg/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/casket-ssg/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/casket-ssg/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/casket-ssg/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/casket-ssg/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/casket-ssg/README.adoc index 0caffcaf..fe3ba07d 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/casket-ssg/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/casket-ssg/README.adoc @@ -1,40 +1,83 @@ -= asdf-casket-ssg +== asdf-casket-ssg -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] -:author: hyperpolymath -:url-asdf: https://asdf-vm.com -:url-repo: https://github.com/hyperpolymath/asdf-casket-ssg-plugin +https://github.com/hyperpolymath/asdf-casket-ssg-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-casket-ssg-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-casket-ssg-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-casket-ssg-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -image:https://img.shields.io/github/license/hyperpolymath/asdf-casket-ssg-plugin?style=flat-square[License,link=LICENSE] -image:https://img.shields.io/github/actions/workflow/status/hyperpolymath/asdf-casket-ssg-plugin/ci.yml?branch=main&style=flat-square[Build Status,link={url-repo}/actions] -image:https://img.shields.io/badge/asdf-plugin-blue?style=flat-square[asdf Plugin,link={url-asdf}] +https://asdf-vm.com[asdf] plugin for +https://github.com/caskethosting/casket[Casket]. -An {url-asdf}[asdf] plugin to manage https://github.com/hyperpolymath/casket-ssg[casket-ssg] versions. +Static site generator. -== Installation +=== Contents + +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] + +=== Dependencies + +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] + +=== Install + +Plugin: [source,bash] ---- asdf plugin add casket-ssg https://github.com/hyperpolymath/asdf-casket-ssg-plugin.git ---- -== Usage +casket-ssg: [source,bash] ---- -# List all available versions -asdf list all casket-ssg +# Show all installable versions +asdf list-all casket-ssg -# Install a specific version -asdf install casket-ssg 1.1.0 +# Install specific version +asdf install casket-ssg latest -# Set global default -asdf global casket-ssg 1.1.0 +# Set a version globally (in your ~/.tool-versions file) +asdf global casket-ssg latest -# Set local version for current project -asdf local casket-ssg 1.1.0 +# Now casket-ssg commands are available +casket-ssg --version ---- -== License +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. + +=== Usage + +[source,bash] +---- +# List installed versions +asdf list casket-ssg + +# Set local version for current directory +asdf local casket-ssg + +# Uninstall a version +asdf uninstall casket-ssg +---- + +=== Contributing + +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License + +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. + +''''' -SPDX-License-Identifier: CC-BY-SA-4.0 +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/casket-ssg/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/casket-ssg/README.md deleted file mode 100644 index 1db4962f..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/casket-ssg/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-casket-ssg - -[![Build](https://github.com/hyperpolymath/asdf-casket-ssg-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-casket-ssg-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-casket-ssg-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-casket-ssg-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Casket](https://github.com/caskethosting/casket). - -Static site generator. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add casket-ssg https://github.com/hyperpolymath/asdf-casket-ssg-plugin.git -``` - -casket-ssg: - -```bash -# Show all installable versions -asdf list-all casket-ssg - -# Install specific version -asdf install casket-ssg latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global casket-ssg latest - -# Now casket-ssg commands are available -casket-ssg --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list casket-ssg - -# Set local version for current directory -asdf local casket-ssg - -# Uninstall a version -asdf uninstall casket-ssg -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/casket-ssg/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/casket-ssg/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/casket-ssg/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/casket-ssg/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/casket-ssg/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/casket-ssg/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cassandra/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/cassandra/ABI-FFI-README.adoc new file mode 100644 index 00000000..3c630b9f --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/cassandra/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== CASSANDRA ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/cassandra.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libcassandra.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +cassandra/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── cassandra.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── cassandra.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/cassandra.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "cassandra.h" + +int main() { + void* handle = cassandra_init(); + if (!handle) return 1; + + int result = cassandra_process(handle, 42); + if (result != 0) { + const char* err = cassandra_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + cassandra_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lcassandra -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import CASSANDRA.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "cassandra")] +extern "C" { + fn cassandra_init() -> *mut std::ffi::c_void; + fn cassandra_free(handle: *mut std::ffi::c_void); + fn cassandra_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = cassandra_init(); + assert!(!handle.is_null()); + + let result = cassandra_process(handle, 42); + assert_eq!(result, 0); + + cassandra_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libcassandra = "libcassandra" + +function init() + handle = ccall((:cassandra_init, libcassandra), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:cassandra_process, libcassandra), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:cassandra_free, libcassandra), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/cassandra.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cassandra/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/cassandra/ABI-FFI-README.md deleted file mode 100644 index d9fa65f6..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/cassandra/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# CASSANDRA ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/cassandra.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libcassandra.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -cassandra/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── cassandra.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── cassandra.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/cassandra.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "cassandra.h" - -int main() { - void* handle = cassandra_init(); - if (!handle) return 1; - - int result = cassandra_process(handle, 42); - if (result != 0) { - const char* err = cassandra_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - cassandra_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lcassandra -L./zig-out/lib -``` - -### From Idris2 - -```idris -import CASSANDRA.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "cassandra")] -extern "C" { - fn cassandra_init() -> *mut std::ffi::c_void; - fn cassandra_free(handle: *mut std::ffi::c_void); - fn cassandra_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = cassandra_init(); - assert!(!handle.is_null()); - - let result = cassandra_process(handle, 42); - assert_eq!(result, 0); - - cassandra_free(handle); - } -} -``` - -### From Julia - -```julia -const libcassandra = "libcassandra" - -function init() - handle = ccall((:cassandra_init, libcassandra), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:cassandra_process, libcassandra), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:cassandra_free, libcassandra), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/cassandra.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cassandra/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/cassandra/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/cassandra/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cassandra/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/cassandra/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/cassandra/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cassandra/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/cassandra/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/cassandra/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/cassandra/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cassandra/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/cassandra/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/cassandra/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cassandra/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/cassandra/README.adoc index d08e1dd2..2d88e26c 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/cassandra/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/cassandra/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-cassandra -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-cassandra-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-cassandra-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-cassandra-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-cassandra-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://cassandra.apache.org[Apache +Cassandra]. -**All repos with foreign function interfaces MUST follow this standard:** +Distributed NoSQL database. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add cassandra https://github.com/hyperpolymath/asdf-cassandra-plugin.git +---- -=== Web Projects +cassandra: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all cassandra -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install cassandra latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global cassandra latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now cassandra commands are available +cassandra --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list cassandra -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local cassandra -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall cassandra ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cassandra/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/cassandra/README.md deleted file mode 100644 index fbf491de..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/cassandra/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-cassandra - -[![Build](https://github.com/hyperpolymath/asdf-cassandra-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-cassandra-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-cassandra-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-cassandra-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Apache Cassandra](https://cassandra.apache.org). - -Distributed NoSQL database. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add cassandra https://github.com/hyperpolymath/asdf-cassandra-plugin.git -``` - -cassandra: - -```bash -# Show all installable versions -asdf list-all cassandra - -# Install specific version -asdf install cassandra latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global cassandra latest - -# Now cassandra commands are available -cassandra --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list cassandra - -# Set local version for current directory -asdf local cassandra - -# Uninstall a version -asdf uninstall cassandra -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cassandra/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/cassandra/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/cassandra/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cassandra/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/cassandra/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/cassandra/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cfssl/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/cfssl/ABI-FFI-README.adoc new file mode 100644 index 00000000..03f95040 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/cfssl/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== CFSSL ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/cfssl.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libcfssl.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +cfssl/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── cfssl.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── cfssl.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/cfssl.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "cfssl.h" + +int main() { + void* handle = cfssl_init(); + if (!handle) return 1; + + int result = cfssl_process(handle, 42); + if (result != 0) { + const char* err = cfssl_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + cfssl_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lcfssl -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import CFSSL.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "cfssl")] +extern "C" { + fn cfssl_init() -> *mut std::ffi::c_void; + fn cfssl_free(handle: *mut std::ffi::c_void); + fn cfssl_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = cfssl_init(); + assert!(!handle.is_null()); + + let result = cfssl_process(handle, 42); + assert_eq!(result, 0); + + cfssl_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libcfssl = "libcfssl" + +function init() + handle = ccall((:cfssl_init, libcfssl), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:cfssl_process, libcfssl), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:cfssl_free, libcfssl), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/cfssl.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cfssl/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/cfssl/ABI-FFI-README.md deleted file mode 100644 index 0c2780b9..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/cfssl/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# CFSSL ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/cfssl.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libcfssl.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -cfssl/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── cfssl.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── cfssl.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/cfssl.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "cfssl.h" - -int main() { - void* handle = cfssl_init(); - if (!handle) return 1; - - int result = cfssl_process(handle, 42); - if (result != 0) { - const char* err = cfssl_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - cfssl_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lcfssl -L./zig-out/lib -``` - -### From Idris2 - -```idris -import CFSSL.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "cfssl")] -extern "C" { - fn cfssl_init() -> *mut std::ffi::c_void; - fn cfssl_free(handle: *mut std::ffi::c_void); - fn cfssl_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = cfssl_init(); - assert!(!handle.is_null()); - - let result = cfssl_process(handle, 42); - assert_eq!(result, 0); - - cfssl_free(handle); - } -} -``` - -### From Julia - -```julia -const libcfssl = "libcfssl" - -function init() - handle = ccall((:cfssl_init, libcfssl), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:cfssl_process, libcfssl), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:cfssl_free, libcfssl), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/cfssl.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cfssl/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/cfssl/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/cfssl/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cfssl/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/cfssl/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/cfssl/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cfssl/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/cfssl/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/cfssl/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/cfssl/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cfssl/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/cfssl/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/cfssl/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cfssl/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/cfssl/README.adoc index d08e1dd2..29ea3ce9 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/cfssl/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/cfssl/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-cfssl -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-cfssl-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-cfssl-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-cfssl-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-cfssl-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://cfssl.org[CFSSL]. -**All repos with foreign function interfaces MUST follow this standard:** +CloudFlare PKI toolkit. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add cfssl https://github.com/hyperpolymath/asdf-cfssl-plugin.git +---- -=== Web Projects +cfssl: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all cfssl -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install cfssl latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global cfssl latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now cfssl commands are available +cfssl --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list cfssl -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local cfssl -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall cfssl ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cfssl/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/cfssl/README.md deleted file mode 100644 index deb102ac..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/cfssl/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-cfssl - -[![Build](https://github.com/hyperpolymath/asdf-cfssl-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-cfssl-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-cfssl-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-cfssl-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [CFSSL](https://cfssl.org). - -CloudFlare PKI toolkit. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add cfssl https://github.com/hyperpolymath/asdf-cfssl-plugin.git -``` - -cfssl: - -```bash -# Show all installable versions -asdf list-all cfssl - -# Install specific version -asdf install cfssl latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global cfssl latest - -# Now cfssl commands are available -cfssl --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list cfssl - -# Set local version for current directory -asdf local cfssl - -# Uninstall a version -asdf uninstall cfssl -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cfssl/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/cfssl/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/cfssl/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cfssl/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/cfssl/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/cfssl/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cobalt/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/cobalt/ABI-FFI-README.adoc new file mode 100644 index 00000000..2f47a922 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/cobalt/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== COBALT ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/cobalt.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libcobalt.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +cobalt/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── cobalt.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── cobalt.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/cobalt.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "cobalt.h" + +int main() { + void* handle = cobalt_init(); + if (!handle) return 1; + + int result = cobalt_process(handle, 42); + if (result != 0) { + const char* err = cobalt_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + cobalt_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lcobalt -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import COBALT.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "cobalt")] +extern "C" { + fn cobalt_init() -> *mut std::ffi::c_void; + fn cobalt_free(handle: *mut std::ffi::c_void); + fn cobalt_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = cobalt_init(); + assert!(!handle.is_null()); + + let result = cobalt_process(handle, 42); + assert_eq!(result, 0); + + cobalt_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libcobalt = "libcobalt" + +function init() + handle = ccall((:cobalt_init, libcobalt), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:cobalt_process, libcobalt), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:cobalt_free, libcobalt), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/cobalt.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cobalt/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/cobalt/ABI-FFI-README.md deleted file mode 100644 index b38a3a27..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/cobalt/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# COBALT ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/cobalt.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libcobalt.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -cobalt/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── cobalt.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── cobalt.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/cobalt.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "cobalt.h" - -int main() { - void* handle = cobalt_init(); - if (!handle) return 1; - - int result = cobalt_process(handle, 42); - if (result != 0) { - const char* err = cobalt_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - cobalt_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lcobalt -L./zig-out/lib -``` - -### From Idris2 - -```idris -import COBALT.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "cobalt")] -extern "C" { - fn cobalt_init() -> *mut std::ffi::c_void; - fn cobalt_free(handle: *mut std::ffi::c_void); - fn cobalt_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = cobalt_init(); - assert!(!handle.is_null()); - - let result = cobalt_process(handle, 42); - assert_eq!(result, 0); - - cobalt_free(handle); - } -} -``` - -### From Julia - -```julia -const libcobalt = "libcobalt" - -function init() - handle = ccall((:cobalt_init, libcobalt), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:cobalt_process, libcobalt), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:cobalt_free, libcobalt), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/cobalt.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cobalt/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/cobalt/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/cobalt/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cobalt/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/cobalt/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/cobalt/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cobalt/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/cobalt/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/cobalt/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/cobalt/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cobalt/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/cobalt/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/cobalt/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cobalt/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/cobalt/README.adoc index d08e1dd2..75e44c27 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/cobalt/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/cobalt/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-cobalt -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-cobalt-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-cobalt-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-cobalt-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-cobalt-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://cobalt-org.github.io[Cobalt]. -**All repos with foreign function interfaces MUST follow this standard:** +Static site generator in Rust. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add cobalt https://github.com/hyperpolymath/asdf-cobalt-plugin.git +---- -=== Web Projects +cobalt: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all cobalt -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install cobalt latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global cobalt latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now cobalt commands are available +cobalt --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list cobalt -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local cobalt -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall cobalt ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cobalt/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/cobalt/README.md deleted file mode 100644 index d38c0c31..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/cobalt/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-cobalt - -[![Build](https://github.com/hyperpolymath/asdf-cobalt-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-cobalt-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-cobalt-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-cobalt-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Cobalt](https://cobalt-org.github.io). - -Static site generator in Rust. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add cobalt https://github.com/hyperpolymath/asdf-cobalt-plugin.git -``` - -cobalt: - -```bash -# Show all installable versions -asdf list-all cobalt - -# Install specific version -asdf install cobalt latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global cobalt latest - -# Now cobalt commands are available -cobalt --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list cobalt - -# Set local version for current directory -asdf local cobalt - -# Uninstall a version -asdf uninstall cobalt -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cobalt/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/cobalt/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/cobalt/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cobalt/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/cobalt/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/cobalt/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cobol/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/cobol/ABI-FFI-README.adoc new file mode 100644 index 00000000..668697fe --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/cobol/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== COBOL ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/cobol.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libcobol.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +cobol/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── cobol.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── cobol.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/cobol.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "cobol.h" + +int main() { + void* handle = cobol_init(); + if (!handle) return 1; + + int result = cobol_process(handle, 42); + if (result != 0) { + const char* err = cobol_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + cobol_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lcobol -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import COBOL.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "cobol")] +extern "C" { + fn cobol_init() -> *mut std::ffi::c_void; + fn cobol_free(handle: *mut std::ffi::c_void); + fn cobol_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = cobol_init(); + assert!(!handle.is_null()); + + let result = cobol_process(handle, 42); + assert_eq!(result, 0); + + cobol_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libcobol = "libcobol" + +function init() + handle = ccall((:cobol_init, libcobol), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:cobol_process, libcobol), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:cobol_free, libcobol), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/cobol.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cobol/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/cobol/ABI-FFI-README.md deleted file mode 100644 index b5600f7c..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/cobol/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# COBOL ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/cobol.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libcobol.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -cobol/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── cobol.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── cobol.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/cobol.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "cobol.h" - -int main() { - void* handle = cobol_init(); - if (!handle) return 1; - - int result = cobol_process(handle, 42); - if (result != 0) { - const char* err = cobol_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - cobol_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lcobol -L./zig-out/lib -``` - -### From Idris2 - -```idris -import COBOL.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "cobol")] -extern "C" { - fn cobol_init() -> *mut std::ffi::c_void; - fn cobol_free(handle: *mut std::ffi::c_void); - fn cobol_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = cobol_init(); - assert!(!handle.is_null()); - - let result = cobol_process(handle, 42); - assert_eq!(result, 0); - - cobol_free(handle); - } -} -``` - -### From Julia - -```julia -const libcobol = "libcobol" - -function init() - handle = ccall((:cobol_init, libcobol), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:cobol_process, libcobol), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:cobol_free, libcobol), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/cobol.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cobol/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/cobol/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/cobol/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cobol/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/cobol/CODE_OF_CONDUCT.md deleted file mode 100644 index caeda1c6..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/cobol/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,27 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. - diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cobol/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/cobol/CONTRIBUTING.adoc index eb045d61..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/cobol/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/cobol/CONTRIBUTING.adoc @@ -1,20 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cobol/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/cobol/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/cobol/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cobol/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/cobol/README.adoc index d220c553..57a4d994 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/cobol/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/cobol/README.adoc @@ -1,107 +1,83 @@ -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] -image:https://img.shields.io/badge/Philosophy-Palimpsest-indigo.svg[Palimpsest,link="https://github.com/hyperpolymath/palimpsest-license"] +== asdf-cobol +https://github.com/hyperpolymath/asdf-cobol-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-cobol-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-cobol-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-cobol-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -// SPDX-License-Identifier: CC-BY-SA-4.0 -= asdf-cobol +https://asdf-vm.com[asdf] plugin for +https://www.gnu.org/software/gnucobol[GnuCOBOL]. -:toc: macro -:toclevels: 2 -:icons: font -:source-highlighter: rouge +Free COBOL compiler. -https://asdf-vm.com[asdf] plugin for https://www.gnu.org/software/gnucobol/[GnuCOBOL]. +=== Contents -[IMPORTANT] -==== -*Project Status: Specification Pending* +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -This repository is a placeholder. The plugin implementation will be uploaded shortly. -==== +=== Dependencies -toc::[] +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== Overview +=== Install -This plugin will enable version management of GnuCOBOL via the asdf version manager, allowing developers to: - -* Install multiple GnuCOBOL versions side-by-side -* Switch between versions per-project or globally -* Ensure reproducible COBOL development environments - -== Planned Installation - -Once implemented: +Plugin: [source,bash] ---- -asdf plugin add cobol https://gitlab.com/hyperpolymath/asdf-cobol.git -asdf list-all cobol -asdf install cobol 3.2.0 -asdf global cobol 3.2.0 +asdf plugin add cobol https://github.com/hyperpolymath/asdf-cobol-plugin.git ---- -== Current Repository Contents - -[cols="1,3"] -|=== -| Path | Description +cobol: -| `.github/workflows/mirror.yml` -| Hub-and-spoke mirror workflow (GitLab, Codeberg, Bitbucket) - -| `.github/workflows/instant-sync.yml` -| Automatic forge propagation on push/release - -| `README.md` -| Placeholder documentation - -| `README.adoc` -| This file -|=== +[source,bash] +---- +# Show all installable versions +asdf list-all cobol -== What Is Missing (Pending Implementation) +# Install specific version +asdf install cobol latest -Standard asdf plugin structure requires: +# Set a version globally (in your ~/.tool-versions file) +asdf global cobol latest -[source] +# Now cobol commands are available +cobol --version ---- -bin/ -├── download # Fetch GnuCOBOL source tarball -├── install # Compile and install GnuCOBOL -├── list-all # List available versions -├── list-bin-paths # (optional) Expose binaries -└── exec-env # (optional) Set runtime environment ----- - -== About GnuCOBOL -GnuCOBOL (formerly OpenCOBOL) is a free COBOL compiler that translates COBOL source to C, then compiles with a native C compiler. It implements substantial portions of the COBOL 85, COBOL 2002, and COBOL 2014 standards. +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -Key features: +=== Usage -* COBOL 85/2002/2014 support -* Compiles to native code via C -* Interoperability with C libraries -* Active development and community - -== Multi-Forge Distribution +[source,bash] +---- +# List installed versions +asdf list cobol -This repository is distributed across multiple forges: +# Set local version for current directory +asdf local cobol -* *Primary*: https://gitlab.com/hyperpolymath/asdf-cobol[GitLab] -* *Mirror*: GitHub (hyperpolymath/asdf-cobol-plugin) -* *Mirror*: Codeberg -* *Mirror*: Bitbucket +# Uninstall a version +asdf uninstall cobol +---- -== Contributing +=== Contributing -See `CONTRIBUTING.md` (pending). +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. -== License +=== License -MPL-2.0 +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -== Funding +''''' -If you find this useful, consider supporting via https://buymeacoffee.com[Buy Me a Coffee]. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cobol/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/cobol/README.md deleted file mode 100644 index bb7e814a..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/cobol/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-cobol - -[![Build](https://github.com/hyperpolymath/asdf-cobol-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-cobol-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-cobol-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-cobol-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [GnuCOBOL](https://www.gnu.org/software/gnucobol). - -Free COBOL compiler. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add cobol https://github.com/hyperpolymath/asdf-cobol-plugin.git -``` - -cobol: - -```bash -# Show all installable versions -asdf list-all cobol - -# Install specific version -asdf install cobol latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global cobol latest - -# Now cobol commands are available -cobol --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list cobol - -# Set local version for current directory -asdf local cobol - -# Uninstall a version -asdf uninstall cobol -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cobol/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/cobol/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/cobol/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cobol/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/cobol/SECURITY.md deleted file mode 100644 index 159a0b7a..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/cobol/SECURITY.md +++ /dev/null @@ -1,25 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection - diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/coredns/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/coredns/ABI-FFI-README.adoc new file mode 100644 index 00000000..9a134242 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/coredns/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== COREDNS ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/coredns.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libcoredns.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +coredns/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── coredns.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── coredns.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/coredns.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "coredns.h" + +int main() { + void* handle = coredns_init(); + if (!handle) return 1; + + int result = coredns_process(handle, 42); + if (result != 0) { + const char* err = coredns_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + coredns_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lcoredns -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import COREDNS.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "coredns")] +extern "C" { + fn coredns_init() -> *mut std::ffi::c_void; + fn coredns_free(handle: *mut std::ffi::c_void); + fn coredns_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = coredns_init(); + assert!(!handle.is_null()); + + let result = coredns_process(handle, 42); + assert_eq!(result, 0); + + coredns_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libcoredns = "libcoredns" + +function init() + handle = ccall((:coredns_init, libcoredns), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:coredns_process, libcoredns), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:coredns_free, libcoredns), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/coredns.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/coredns/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/coredns/ABI-FFI-README.md deleted file mode 100644 index be38cbfc..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/coredns/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# COREDNS ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/coredns.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libcoredns.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -coredns/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── coredns.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── coredns.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/coredns.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "coredns.h" - -int main() { - void* handle = coredns_init(); - if (!handle) return 1; - - int result = coredns_process(handle, 42); - if (result != 0) { - const char* err = coredns_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - coredns_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lcoredns -L./zig-out/lib -``` - -### From Idris2 - -```idris -import COREDNS.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "coredns")] -extern "C" { - fn coredns_init() -> *mut std::ffi::c_void; - fn coredns_free(handle: *mut std::ffi::c_void); - fn coredns_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = coredns_init(); - assert!(!handle.is_null()); - - let result = coredns_process(handle, 42); - assert_eq!(result, 0); - - coredns_free(handle); - } -} -``` - -### From Julia - -```julia -const libcoredns = "libcoredns" - -function init() - handle = ccall((:coredns_init, libcoredns), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:coredns_process, libcoredns), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:coredns_free, libcoredns), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/coredns.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/coredns/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/coredns/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/coredns/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/coredns/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/coredns/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/coredns/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/coredns/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/coredns/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/coredns/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/coredns/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/coredns/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/coredns/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/coredns/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/coredns/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/coredns/README.adoc index d08e1dd2..c52bdaac 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/coredns/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/coredns/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-coredns -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-coredns-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-coredns-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-coredns-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-coredns-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://coredns.io[CoreDNS]. -**All repos with foreign function interfaces MUST follow this standard:** +Flexible DNS server. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add coredns https://github.com/hyperpolymath/asdf-coredns-plugin.git +---- -=== Web Projects +coredns: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all coredns -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install coredns latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global coredns latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now coredns commands are available +coredns --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list coredns -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local coredns -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall coredns ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/coredns/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/coredns/README.md deleted file mode 100644 index a98918e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/coredns/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-coredns - -[![Build](https://github.com/hyperpolymath/asdf-coredns-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-coredns-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-coredns-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-coredns-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [CoreDNS](https://coredns.io). - -Flexible DNS server. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add coredns https://github.com/hyperpolymath/asdf-coredns-plugin.git -``` - -coredns: - -```bash -# Show all installable versions -asdf list-all coredns - -# Install specific version -asdf install coredns latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global coredns latest - -# Now coredns commands are available -coredns --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list coredns - -# Set local version for current directory -asdf local coredns - -# Uninstall a version -asdf uninstall coredns -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/coredns/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/coredns/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/coredns/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/coredns/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/coredns/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/coredns/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cosign/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/cosign/ABI-FFI-README.adoc new file mode 100644 index 00000000..2ba60102 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/cosign/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== COSIGN ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/cosign.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libcosign.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +cosign/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── cosign.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── cosign.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/cosign.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "cosign.h" + +int main() { + void* handle = cosign_init(); + if (!handle) return 1; + + int result = cosign_process(handle, 42); + if (result != 0) { + const char* err = cosign_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + cosign_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lcosign -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import COSIGN.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "cosign")] +extern "C" { + fn cosign_init() -> *mut std::ffi::c_void; + fn cosign_free(handle: *mut std::ffi::c_void); + fn cosign_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = cosign_init(); + assert!(!handle.is_null()); + + let result = cosign_process(handle, 42); + assert_eq!(result, 0); + + cosign_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libcosign = "libcosign" + +function init() + handle = ccall((:cosign_init, libcosign), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:cosign_process, libcosign), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:cosign_free, libcosign), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/cosign.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cosign/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/cosign/ABI-FFI-README.md deleted file mode 100644 index 98655399..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/cosign/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# COSIGN ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/cosign.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libcosign.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -cosign/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── cosign.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── cosign.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/cosign.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "cosign.h" - -int main() { - void* handle = cosign_init(); - if (!handle) return 1; - - int result = cosign_process(handle, 42); - if (result != 0) { - const char* err = cosign_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - cosign_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lcosign -L./zig-out/lib -``` - -### From Idris2 - -```idris -import COSIGN.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "cosign")] -extern "C" { - fn cosign_init() -> *mut std::ffi::c_void; - fn cosign_free(handle: *mut std::ffi::c_void); - fn cosign_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = cosign_init(); - assert!(!handle.is_null()); - - let result = cosign_process(handle, 42); - assert_eq!(result, 0); - - cosign_free(handle); - } -} -``` - -### From Julia - -```julia -const libcosign = "libcosign" - -function init() - handle = ccall((:cosign_init, libcosign), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:cosign_process, libcosign), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:cosign_free, libcosign), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/cosign.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cosign/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/cosign/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/cosign/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cosign/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/cosign/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/cosign/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cosign/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/cosign/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/cosign/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/cosign/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cosign/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/cosign/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/cosign/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cosign/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/cosign/README.adoc index d08e1dd2..c4df0e5e 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/cosign/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/cosign/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-cosign -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-cosign-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-cosign-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-cosign-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-cosign-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://sigstore.dev[Cosign]. -**All repos with foreign function interfaces MUST follow this standard:** +Container signing from Sigstore. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add cosign https://github.com/hyperpolymath/asdf-cosign-plugin.git +---- -=== Web Projects +cosign: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all cosign -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install cosign latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global cosign latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now cosign commands are available +cosign --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list cosign -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local cosign -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall cosign ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cosign/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/cosign/README.md deleted file mode 100644 index 9d8e33c6..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/cosign/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-cosign - -[![Build](https://github.com/hyperpolymath/asdf-cosign-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-cosign-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-cosign-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-cosign-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Cosign](https://sigstore.dev). - -Container signing from Sigstore. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add cosign https://github.com/hyperpolymath/asdf-cosign-plugin.git -``` - -cosign: - -```bash -# Show all installable versions -asdf list-all cosign - -# Install specific version -asdf install cosign latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global cosign latest - -# Now cosign commands are available -cosign --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list cosign - -# Set local version for current directory -asdf local cosign - -# Uninstall a version -asdf uninstall cosign -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cosign/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/cosign/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/cosign/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cosign/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/cosign/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/cosign/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/couchdb/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/couchdb/ABI-FFI-README.adoc new file mode 100644 index 00000000..24c93349 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/couchdb/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== COUCHDB ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/couchdb.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libcouchdb.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +couchdb/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── couchdb.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── couchdb.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/couchdb.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "couchdb.h" + +int main() { + void* handle = couchdb_init(); + if (!handle) return 1; + + int result = couchdb_process(handle, 42); + if (result != 0) { + const char* err = couchdb_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + couchdb_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lcouchdb -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import COUCHDB.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "couchdb")] +extern "C" { + fn couchdb_init() -> *mut std::ffi::c_void; + fn couchdb_free(handle: *mut std::ffi::c_void); + fn couchdb_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = couchdb_init(); + assert!(!handle.is_null()); + + let result = couchdb_process(handle, 42); + assert_eq!(result, 0); + + couchdb_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libcouchdb = "libcouchdb" + +function init() + handle = ccall((:couchdb_init, libcouchdb), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:couchdb_process, libcouchdb), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:couchdb_free, libcouchdb), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/couchdb.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/couchdb/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/couchdb/ABI-FFI-README.md deleted file mode 100644 index e724fafc..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/couchdb/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# COUCHDB ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/couchdb.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libcouchdb.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -couchdb/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── couchdb.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── couchdb.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/couchdb.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "couchdb.h" - -int main() { - void* handle = couchdb_init(); - if (!handle) return 1; - - int result = couchdb_process(handle, 42); - if (result != 0) { - const char* err = couchdb_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - couchdb_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lcouchdb -L./zig-out/lib -``` - -### From Idris2 - -```idris -import COUCHDB.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "couchdb")] -extern "C" { - fn couchdb_init() -> *mut std::ffi::c_void; - fn couchdb_free(handle: *mut std::ffi::c_void); - fn couchdb_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = couchdb_init(); - assert!(!handle.is_null()); - - let result = couchdb_process(handle, 42); - assert_eq!(result, 0); - - couchdb_free(handle); - } -} -``` - -### From Julia - -```julia -const libcouchdb = "libcouchdb" - -function init() - handle = ccall((:couchdb_init, libcouchdb), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:couchdb_process, libcouchdb), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:couchdb_free, libcouchdb), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/couchdb.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/couchdb/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/couchdb/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/couchdb/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/couchdb/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/couchdb/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/couchdb/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/couchdb/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/couchdb/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/couchdb/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/couchdb/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/couchdb/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/couchdb/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/couchdb/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/couchdb/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/couchdb/README.adoc index d08e1dd2..cf4866d3 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/couchdb/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/couchdb/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-couchdb -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-couchdb-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-couchdb-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-couchdb-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-couchdb-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://couchdb.apache.org[Apache +CouchDB]. -**All repos with foreign function interfaces MUST follow this standard:** +NoSQL document database. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add couchdb https://github.com/hyperpolymath/asdf-couchdb-plugin.git +---- -=== Web Projects +couchdb: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all couchdb -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install couchdb latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global couchdb latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now couchdb commands are available +couchdb --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list couchdb -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local couchdb -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall couchdb ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/couchdb/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/couchdb/README.md deleted file mode 100644 index 374c8a7e..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/couchdb/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-couchdb - -[![Build](https://github.com/hyperpolymath/asdf-couchdb-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-couchdb-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-couchdb-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-couchdb-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Apache CouchDB](https://couchdb.apache.org). - -NoSQL document database. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add couchdb https://github.com/hyperpolymath/asdf-couchdb-plugin.git -``` - -couchdb: - -```bash -# Show all installable versions -asdf list-all couchdb - -# Install specific version -asdf install couchdb latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global couchdb latest - -# Now couchdb commands are available -couchdb --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list couchdb - -# Set local version for current directory -asdf local couchdb - -# Uninstall a version -asdf uninstall couchdb -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/couchdb/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/couchdb/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/couchdb/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/couchdb/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/couchdb/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/couchdb/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cue/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/cue/ABI-FFI-README.adoc new file mode 100644 index 00000000..850cf0c3 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/cue/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== CUE ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/cue.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libcue.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +cue/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── cue.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── cue.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/cue.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "cue.h" + +int main() { + void* handle = cue_init(); + if (!handle) return 1; + + int result = cue_process(handle, 42); + if (result != 0) { + const char* err = cue_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + cue_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lcue -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import CUE.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "cue")] +extern "C" { + fn cue_init() -> *mut std::ffi::c_void; + fn cue_free(handle: *mut std::ffi::c_void); + fn cue_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = cue_init(); + assert!(!handle.is_null()); + + let result = cue_process(handle, 42); + assert_eq!(result, 0); + + cue_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libcue = "libcue" + +function init() + handle = ccall((:cue_init, libcue), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:cue_process, libcue), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:cue_free, libcue), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/cue.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cue/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/cue/ABI-FFI-README.md deleted file mode 100644 index 3bd1487e..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/cue/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# CUE ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/cue.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libcue.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -cue/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── cue.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── cue.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/cue.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "cue.h" - -int main() { - void* handle = cue_init(); - if (!handle) return 1; - - int result = cue_process(handle, 42); - if (result != 0) { - const char* err = cue_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - cue_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lcue -L./zig-out/lib -``` - -### From Idris2 - -```idris -import CUE.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "cue")] -extern "C" { - fn cue_init() -> *mut std::ffi::c_void; - fn cue_free(handle: *mut std::ffi::c_void); - fn cue_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = cue_init(); - assert!(!handle.is_null()); - - let result = cue_process(handle, 42); - assert_eq!(result, 0); - - cue_free(handle); - } -} -``` - -### From Julia - -```julia -const libcue = "libcue" - -function init() - handle = ccall((:cue_init, libcue), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:cue_process, libcue), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:cue_free, libcue), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/cue.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cue/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/cue/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/cue/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cue/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/cue/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/cue/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cue/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/cue/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/cue/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/cue/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cue/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/cue/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/cue/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cue/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/cue/README.adoc index d08e1dd2..51879d59 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/cue/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/cue/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-cue -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-cue-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-cue-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-cue-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-cue-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://cuelang.org[CUE]. -**All repos with foreign function interfaces MUST follow this standard:** +Data validation language. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add cue https://github.com/hyperpolymath/asdf-cue-plugin.git +---- -=== Web Projects +cue: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all cue -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install cue latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global cue latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now cue commands are available +cue --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list cue -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local cue -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall cue ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cue/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/cue/README.md deleted file mode 100644 index fbf1b418..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/cue/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-cue - -[![Build](https://github.com/hyperpolymath/asdf-cue-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-cue-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-cue-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-cue-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [CUE](https://cuelang.org). - -Data validation language. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add cue https://github.com/hyperpolymath/asdf-cue-plugin.git -``` - -cue: - -```bash -# Show all installable versions -asdf list-all cue - -# Install specific version -asdf install cue latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global cue latest - -# Now cue commands are available -cue --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list cue - -# Set local version for current directory -asdf local cue - -# Uninstall a version -asdf uninstall cue -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cue/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/cue/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/cue/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/cue/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/cue/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/cue/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/deno/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/deno/ABI-FFI-README.adoc new file mode 100644 index 00000000..ba563468 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/deno/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== DENO ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/deno.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libdeno.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +deno/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── deno.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── deno.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/deno.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "deno.h" + +int main() { + void* handle = deno_init(); + if (!handle) return 1; + + int result = deno_process(handle, 42); + if (result != 0) { + const char* err = deno_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + deno_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -ldeno -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import DENO.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "deno")] +extern "C" { + fn deno_init() -> *mut std::ffi::c_void; + fn deno_free(handle: *mut std::ffi::c_void); + fn deno_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = deno_init(); + assert!(!handle.is_null()); + + let result = deno_process(handle, 42); + assert_eq!(result, 0); + + deno_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libdeno = "libdeno" + +function init() + handle = ccall((:deno_init, libdeno), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:deno_process, libdeno), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:deno_free, libdeno), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/deno.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/deno/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/deno/ABI-FFI-README.md deleted file mode 100644 index 10bd75bc..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/deno/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# DENO ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/deno.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libdeno.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -deno/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── deno.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── deno.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/deno.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "deno.h" - -int main() { - void* handle = deno_init(); - if (!handle) return 1; - - int result = deno_process(handle, 42); - if (result != 0) { - const char* err = deno_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - deno_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -ldeno -L./zig-out/lib -``` - -### From Idris2 - -```idris -import DENO.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "deno")] -extern "C" { - fn deno_init() -> *mut std::ffi::c_void; - fn deno_free(handle: *mut std::ffi::c_void); - fn deno_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = deno_init(); - assert!(!handle.is_null()); - - let result = deno_process(handle, 42); - assert_eq!(result, 0); - - deno_free(handle); - } -} -``` - -### From Julia - -```julia -const libdeno = "libdeno" - -function init() - handle = ccall((:deno_init, libdeno), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:deno_process, libdeno), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:deno_free, libdeno), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/deno.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/deno/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/deno/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/deno/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/deno/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/deno/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/deno/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/deno/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/deno/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/deno/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/deno/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/deno/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/deno/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/deno/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/deno/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/deno/README.adoc index d08e1dd2..06e1239d 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/deno/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/deno/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-deno -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-deno-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-deno-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-deno-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-deno-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://deno.land[Deno]. -**All repos with foreign function interfaces MUST follow this standard:** +Secure TypeScript/JavaScript runtime. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add deno https://github.com/hyperpolymath/asdf-deno-plugin.git +---- -=== Web Projects +deno: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all deno -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install deno latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global deno latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now deno commands are available +deno --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list deno -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local deno -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall deno ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/deno/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/deno/README.md deleted file mode 100644 index c07cf267..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/deno/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-deno - -[![Build](https://github.com/hyperpolymath/asdf-deno-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-deno-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-deno-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-deno-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Deno](https://deno.land). - -Secure TypeScript/JavaScript runtime. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add deno https://github.com/hyperpolymath/asdf-deno-plugin.git -``` - -deno: - -```bash -# Show all installable versions -asdf list-all deno - -# Install specific version -asdf install deno latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global deno latest - -# Now deno commands are available -deno --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list deno - -# Set local version for current directory -asdf local deno - -# Uninstall a version -asdf uninstall deno -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/deno/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/deno/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/deno/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/deno/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/deno/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/deno/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/dhall/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/dhall/ABI-FFI-README.adoc new file mode 100644 index 00000000..14b6a8a8 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/dhall/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== DHALL ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/dhall.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libdhall.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +dhall/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── dhall.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── dhall.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/dhall.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "dhall.h" + +int main() { + void* handle = dhall_init(); + if (!handle) return 1; + + int result = dhall_process(handle, 42); + if (result != 0) { + const char* err = dhall_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + dhall_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -ldhall -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import DHALL.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "dhall")] +extern "C" { + fn dhall_init() -> *mut std::ffi::c_void; + fn dhall_free(handle: *mut std::ffi::c_void); + fn dhall_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = dhall_init(); + assert!(!handle.is_null()); + + let result = dhall_process(handle, 42); + assert_eq!(result, 0); + + dhall_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libdhall = "libdhall" + +function init() + handle = ccall((:dhall_init, libdhall), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:dhall_process, libdhall), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:dhall_free, libdhall), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/dhall.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/dhall/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/dhall/ABI-FFI-README.md deleted file mode 100644 index 91fc1481..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/dhall/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# DHALL ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/dhall.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libdhall.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -dhall/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── dhall.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── dhall.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/dhall.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "dhall.h" - -int main() { - void* handle = dhall_init(); - if (!handle) return 1; - - int result = dhall_process(handle, 42); - if (result != 0) { - const char* err = dhall_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - dhall_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -ldhall -L./zig-out/lib -``` - -### From Idris2 - -```idris -import DHALL.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "dhall")] -extern "C" { - fn dhall_init() -> *mut std::ffi::c_void; - fn dhall_free(handle: *mut std::ffi::c_void); - fn dhall_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = dhall_init(); - assert!(!handle.is_null()); - - let result = dhall_process(handle, 42); - assert_eq!(result, 0); - - dhall_free(handle); - } -} -``` - -### From Julia - -```julia -const libdhall = "libdhall" - -function init() - handle = ccall((:dhall_init, libdhall), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:dhall_process, libdhall), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:dhall_free, libdhall), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/dhall.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/dhall/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/dhall/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/dhall/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/dhall/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/dhall/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/dhall/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/dhall/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/dhall/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/dhall/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/dhall/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/dhall/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/dhall/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/dhall/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/dhall/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/dhall/README.adoc index d08e1dd2..ca06ba48 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/dhall/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/dhall/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-dhall -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-dhall-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-dhall-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-dhall-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-dhall-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://dhall-lang.org[Dhall]. -**All repos with foreign function interfaces MUST follow this standard:** +Programmable configuration. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add dhall https://github.com/hyperpolymath/asdf-dhall-plugin.git +---- -=== Web Projects +dhall: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all dhall -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install dhall latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global dhall latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now dhall commands are available +dhall --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list dhall -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local dhall -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall dhall ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/dhall/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/dhall/README.md deleted file mode 100644 index 6faab96a..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/dhall/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-dhall - -[![Build](https://github.com/hyperpolymath/asdf-dhall-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-dhall-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-dhall-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-dhall-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Dhall](https://dhall-lang.org). - -Programmable configuration. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add dhall https://github.com/hyperpolymath/asdf-dhall-plugin.git -``` - -dhall: - -```bash -# Show all installable versions -asdf list-all dhall - -# Install specific version -asdf install dhall latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global dhall latest - -# Now dhall commands are available -dhall --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list dhall - -# Set local version for current directory -asdf local dhall - -# Uninstall a version -asdf uninstall dhall -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/dhall/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/dhall/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/dhall/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/dhall/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/dhall/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/dhall/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/doctl/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/doctl/ABI-FFI-README.adoc new file mode 100644 index 00000000..4d5d4fab --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/doctl/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== DOCTL ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/doctl.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libdoctl.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +doctl/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── doctl.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── doctl.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/doctl.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "doctl.h" + +int main() { + void* handle = doctl_init(); + if (!handle) return 1; + + int result = doctl_process(handle, 42); + if (result != 0) { + const char* err = doctl_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + doctl_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -ldoctl -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import DOCTL.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "doctl")] +extern "C" { + fn doctl_init() -> *mut std::ffi::c_void; + fn doctl_free(handle: *mut std::ffi::c_void); + fn doctl_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = doctl_init(); + assert!(!handle.is_null()); + + let result = doctl_process(handle, 42); + assert_eq!(result, 0); + + doctl_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libdoctl = "libdoctl" + +function init() + handle = ccall((:doctl_init, libdoctl), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:doctl_process, libdoctl), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:doctl_free, libdoctl), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/doctl.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/doctl/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/doctl/ABI-FFI-README.md deleted file mode 100644 index 0da3bc65..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/doctl/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# DOCTL ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/doctl.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libdoctl.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -doctl/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── doctl.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── doctl.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/doctl.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "doctl.h" - -int main() { - void* handle = doctl_init(); - if (!handle) return 1; - - int result = doctl_process(handle, 42); - if (result != 0) { - const char* err = doctl_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - doctl_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -ldoctl -L./zig-out/lib -``` - -### From Idris2 - -```idris -import DOCTL.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "doctl")] -extern "C" { - fn doctl_init() -> *mut std::ffi::c_void; - fn doctl_free(handle: *mut std::ffi::c_void); - fn doctl_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = doctl_init(); - assert!(!handle.is_null()); - - let result = doctl_process(handle, 42); - assert_eq!(result, 0); - - doctl_free(handle); - } -} -``` - -### From Julia - -```julia -const libdoctl = "libdoctl" - -function init() - handle = ccall((:doctl_init, libdoctl), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:doctl_process, libdoctl), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:doctl_free, libdoctl), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/doctl.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/doctl/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/doctl/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/doctl/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/doctl/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/doctl/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/doctl/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/doctl/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/doctl/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/doctl/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/doctl/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/doctl/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/doctl/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/doctl/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/doctl/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/doctl/README.adoc index d08e1dd2..ccf6797a 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/doctl/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/doctl/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-doctl -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-doctl-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-doctl-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-doctl-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-doctl-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://docs.digitalocean.com/reference/doctl[DigitalOcean CLI]. -**All repos with foreign function interfaces MUST follow this standard:** +DO command-line. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add doctl https://github.com/hyperpolymath/asdf-doctl-plugin.git +---- -=== Web Projects +doctl: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all doctl -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install doctl latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global doctl latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now doctl commands are available +doctl --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list doctl -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local doctl -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall doctl ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/doctl/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/doctl/README.md deleted file mode 100644 index cf5eec8b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/doctl/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-doctl - -[![Build](https://github.com/hyperpolymath/asdf-doctl-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-doctl-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-doctl-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-doctl-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [DigitalOcean CLI](https://docs.digitalocean.com/reference/doctl). - -DO command-line. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add doctl https://github.com/hyperpolymath/asdf-doctl-plugin.git -``` - -doctl: - -```bash -# Show all installable versions -asdf list-all doctl - -# Install specific version -asdf install doctl latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global doctl latest - -# Now doctl commands are available -doctl --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list doctl - -# Set local version for current directory -asdf local doctl - -# Uninstall a version -asdf uninstall doctl -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/doctl/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/doctl/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/doctl/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/doctl/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/doctl/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/doctl/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/dragonfly/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/dragonfly/ABI-FFI-README.adoc new file mode 100644 index 00000000..9959a0d9 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/dragonfly/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== DRAGONFLY ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/dragonfly.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libdragonfly.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +dragonfly/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── dragonfly.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── dragonfly.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/dragonfly.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "dragonfly.h" + +int main() { + void* handle = dragonfly_init(); + if (!handle) return 1; + + int result = dragonfly_process(handle, 42); + if (result != 0) { + const char* err = dragonfly_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + dragonfly_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -ldragonfly -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import DRAGONFLY.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "dragonfly")] +extern "C" { + fn dragonfly_init() -> *mut std::ffi::c_void; + fn dragonfly_free(handle: *mut std::ffi::c_void); + fn dragonfly_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = dragonfly_init(); + assert!(!handle.is_null()); + + let result = dragonfly_process(handle, 42); + assert_eq!(result, 0); + + dragonfly_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libdragonfly = "libdragonfly" + +function init() + handle = ccall((:dragonfly_init, libdragonfly), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:dragonfly_process, libdragonfly), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:dragonfly_free, libdragonfly), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/dragonfly.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/dragonfly/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/dragonfly/ABI-FFI-README.md deleted file mode 100644 index f4a92036..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/dragonfly/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# DRAGONFLY ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/dragonfly.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libdragonfly.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -dragonfly/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── dragonfly.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── dragonfly.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/dragonfly.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "dragonfly.h" - -int main() { - void* handle = dragonfly_init(); - if (!handle) return 1; - - int result = dragonfly_process(handle, 42); - if (result != 0) { - const char* err = dragonfly_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - dragonfly_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -ldragonfly -L./zig-out/lib -``` - -### From Idris2 - -```idris -import DRAGONFLY.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "dragonfly")] -extern "C" { - fn dragonfly_init() -> *mut std::ffi::c_void; - fn dragonfly_free(handle: *mut std::ffi::c_void); - fn dragonfly_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = dragonfly_init(); - assert!(!handle.is_null()); - - let result = dragonfly_process(handle, 42); - assert_eq!(result, 0); - - dragonfly_free(handle); - } -} -``` - -### From Julia - -```julia -const libdragonfly = "libdragonfly" - -function init() - handle = ccall((:dragonfly_init, libdragonfly), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:dragonfly_process, libdragonfly), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:dragonfly_free, libdragonfly), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/dragonfly.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/dragonfly/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/dragonfly/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/dragonfly/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/dragonfly/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/dragonfly/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/dragonfly/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/dragonfly/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/dragonfly/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/dragonfly/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/dragonfly/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/dragonfly/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/dragonfly/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/dragonfly/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/dragonfly/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/dragonfly/README.adoc index d08e1dd2..49b3536a 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/dragonfly/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/dragonfly/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-dragonfly -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-dragonfly-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-dragonfly-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-dragonfly-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-dragonfly-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://dragonflydb.io[Dragonfly]. -**All repos with foreign function interfaces MUST follow this standard:** +Redis-compatible datastore. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add dragonfly https://github.com/hyperpolymath/asdf-dragonfly-plugin.git +---- -=== Web Projects +dragonfly: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all dragonfly -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install dragonfly latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global dragonfly latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now dragonfly commands are available +dragonfly --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list dragonfly -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local dragonfly -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall dragonfly ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/dragonfly/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/dragonfly/README.md deleted file mode 100644 index 8ec1224b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/dragonfly/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-dragonfly - -[![Build](https://github.com/hyperpolymath/asdf-dragonfly-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-dragonfly-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-dragonfly-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-dragonfly-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Dragonfly](https://dragonflydb.io). - -Redis-compatible datastore. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add dragonfly https://github.com/hyperpolymath/asdf-dragonfly-plugin.git -``` - -dragonfly: - -```bash -# Show all installable versions -asdf list-all dragonfly - -# Install specific version -asdf install dragonfly latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global dragonfly latest - -# Now dragonfly commands are available -dragonfly --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list dragonfly - -# Set local version for current directory -asdf local dragonfly - -# Uninstall a version -asdf uninstall dragonfly -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/dragonfly/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/dragonfly/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/dragonfly/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/dragonfly/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/dragonfly/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/dragonfly/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/envoy/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/envoy/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/envoy/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/envoy/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/envoy/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/envoy/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/envoy/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/envoy/CONTRIBUTING.adoc index d18532b5..e86d3f29 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/envoy/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/envoy/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-envoy-plugin.git cd +asdf-envoy-plugin -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-envoy-plugin-dev toolbox enter asdf-envoy-plugin-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-envoy-plugin/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-envoy-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-envoy-plugin/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-envoy-plugin/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-envoy-plugin/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/envoy/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/envoy/CONTRIBUTING.md deleted file mode 100644 index f0947d18..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/envoy/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-envoy-plugin.git -cd asdf-envoy-plugin - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-envoy-plugin-dev -toolbox enter asdf-envoy-plugin-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-envoy-plugin/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-envoy-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-envoy-plugin/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-envoy-plugin/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-envoy-plugin/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/envoy/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/envoy/README.adoc new file mode 100644 index 00000000..c236d9e1 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/envoy/README.adoc @@ -0,0 +1,83 @@ +== asdf-envoy + +https://github.com/hyperpolymath/asdf-envoy-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-envoy-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-envoy-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-envoy-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] + +https://asdf-vm.com[asdf] plugin for https://www.envoyproxy.io[Envoy +Proxy]. + +Cloud-native proxy. + +=== Contents + +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] + +=== Dependencies + +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] + +=== Install + +Plugin: + +[source,bash] +---- +asdf plugin add envoy https://github.com/hyperpolymath/asdf-envoy-plugin.git +---- + +envoy: + +[source,bash] +---- +# Show all installable versions +asdf list-all envoy + +# Install specific version +asdf install envoy latest + +# Set a version globally (in your ~/.tool-versions file) +asdf global envoy latest + +# Now envoy commands are available +envoy --version +---- + +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. + +=== Usage + +[source,bash] +---- +# List installed versions +asdf list envoy + +# Set local version for current directory +asdf local envoy + +# Uninstall a version +asdf uninstall envoy +---- + +=== Contributing + +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License + +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. + +''''' + +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/envoy/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/envoy/README.md deleted file mode 100644 index c294b14f..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/envoy/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-envoy - -[![Build](https://github.com/hyperpolymath/asdf-envoy-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-envoy-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-envoy-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-envoy-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Envoy Proxy](https://www.envoyproxy.io). - -Cloud-native proxy. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add envoy https://github.com/hyperpolymath/asdf-envoy-plugin.git -``` - -envoy: - -```bash -# Show all installable versions -asdf list-all envoy - -# Install specific version -asdf install envoy latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global envoy latest - -# Now envoy commands are available -envoy --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list envoy - -# Set local version for current directory -asdf local envoy - -# Uninstall a version -asdf uninstall envoy -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/envoy/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/envoy/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/envoy/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/envoy/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/envoy/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/envoy/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/fornax/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/fornax/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/fornax/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/fornax/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/fornax/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/fornax/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/fornax/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/fornax/CONTRIBUTING.adoc index d18532b5..16fd4e4f 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/fornax/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/fornax/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-fornax-plugin.git cd +asdf-fornax-plugin -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-fornax-plugin-dev toolbox enter +asdf-fornax-plugin-dev # Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-fornax-plugin/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-fornax-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-fornax-plugin/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-fornax-plugin/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-fornax-plugin/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/fornax/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/fornax/CONTRIBUTING.md deleted file mode 100644 index 3a40ee9c..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/fornax/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-fornax-plugin.git -cd asdf-fornax-plugin - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-fornax-plugin-dev -toolbox enter asdf-fornax-plugin-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-fornax-plugin/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-fornax-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-fornax-plugin/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-fornax-plugin/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-fornax-plugin/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/fornax/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/fornax/README.adoc new file mode 100644 index 00000000..5bf382d3 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/fornax/README.adoc @@ -0,0 +1,83 @@ +== asdf-fornax + +https://github.com/hyperpolymath/asdf-fornax-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-fornax-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-fornax-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-fornax-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] + +https://asdf-vm.com[asdf] plugin for +https://github.com/katef/fornax[Fornax]. + +Static site generator. + +=== Contents + +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] + +=== Dependencies + +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] + +=== Install + +Plugin: + +[source,bash] +---- +asdf plugin add fornax https://github.com/hyperpolymath/asdf-fornax-plugin.git +---- + +fornax: + +[source,bash] +---- +# Show all installable versions +asdf list-all fornax + +# Install specific version +asdf install fornax latest + +# Set a version globally (in your ~/.tool-versions file) +asdf global fornax latest + +# Now fornax commands are available +fornax --version +---- + +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. + +=== Usage + +[source,bash] +---- +# List installed versions +asdf list fornax + +# Set local version for current directory +asdf local fornax + +# Uninstall a version +asdf uninstall fornax +---- + +=== Contributing + +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License + +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. + +''''' + +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/fornax/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/fornax/README.md deleted file mode 100644 index 407fc39e..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/fornax/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-fornax - -[![Build](https://github.com/hyperpolymath/asdf-fornax-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-fornax-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-fornax-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-fornax-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Fornax](https://github.com/katef/fornax). - -Static site generator. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add fornax https://github.com/hyperpolymath/asdf-fornax-plugin.git -``` - -fornax: - -```bash -# Show all installable versions -asdf list-all fornax - -# Install specific version -asdf install fornax latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global fornax latest - -# Now fornax commands are available -fornax --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list fornax - -# Set local version for current directory -asdf local fornax - -# Uninstall a version -asdf uninstall fornax -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/fornax/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/fornax/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/fornax/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/fornax/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/fornax/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/fornax/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/fortran/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/fortran/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/fortran/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/fortran/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/fortran/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/fortran/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/fortran/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/fortran/CONTRIBUTING.adoc index d18532b5..c1d537f7 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/fortran/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/fortran/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-fortran-plugin.git cd +asdf-fortran-plugin -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-fortran-plugin-dev toolbox enter +asdf-fortran-plugin-dev # Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-fortran-plugin/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-fortran-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-fortran-plugin/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-fortran-plugin/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-fortran-plugin/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/fortran/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/fortran/CONTRIBUTING.md deleted file mode 100644 index d6943f4a..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/fortran/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-fortran-plugin.git -cd asdf-fortran-plugin - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-fortran-plugin-dev -toolbox enter asdf-fortran-plugin-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-fortran-plugin/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-fortran-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-fortran-plugin/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-fortran-plugin/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-fortran-plugin/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/fortran/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/fortran/README.adoc new file mode 100644 index 00000000..a297d1ad --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/fortran/README.adoc @@ -0,0 +1,83 @@ +== asdf-fortran + +https://github.com/hyperpolymath/asdf-fortran-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-fortran-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-fortran-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-fortran-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] + +https://asdf-vm.com[asdf] plugin for +https://gcc.gnu.org/fortran[GFortran]. + +GNU Fortran compiler. + +=== Contents + +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] + +=== Dependencies + +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] + +=== Install + +Plugin: + +[source,bash] +---- +asdf plugin add fortran https://github.com/hyperpolymath/asdf-fortran-plugin.git +---- + +fortran: + +[source,bash] +---- +# Show all installable versions +asdf list-all fortran + +# Install specific version +asdf install fortran latest + +# Set a version globally (in your ~/.tool-versions file) +asdf global fortran latest + +# Now fortran commands are available +fortran --version +---- + +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. + +=== Usage + +[source,bash] +---- +# List installed versions +asdf list fortran + +# Set local version for current directory +asdf local fortran + +# Uninstall a version +asdf uninstall fortran +---- + +=== Contributing + +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License + +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. + +''''' + +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/fortran/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/fortran/README.md deleted file mode 100644 index 78c8c1d8..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/fortran/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-fortran - -[![Build](https://github.com/hyperpolymath/asdf-fortran-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-fortran-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-fortran-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-fortran-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [GFortran](https://gcc.gnu.org/fortran). - -GNU Fortran compiler. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add fortran https://github.com/hyperpolymath/asdf-fortran-plugin.git -``` - -fortran: - -```bash -# Show all installable versions -asdf list-all fortran - -# Install specific version -asdf install fortran latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global fortran latest - -# Now fortran commands are available -fortran --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list fortran - -# Set local version for current directory -asdf local fortran - -# Uninstall a version -asdf uninstall fortran -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/fortran/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/fortran/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/fortran/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/fortran/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/fortran/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/fortran/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/franklin/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/franklin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/franklin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/franklin/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/franklin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/franklin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/franklin/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/franklin/CONTRIBUTING.adoc index d18532b5..3e266b5e 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/franklin/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/franklin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-franklin-plugin.git cd +asdf-franklin-plugin -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-franklin-plugin-dev toolbox enter +asdf-franklin-plugin-dev # Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-franklin-plugin/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-franklin-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-franklin-plugin/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-franklin-plugin/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-franklin-plugin/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/franklin/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/franklin/CONTRIBUTING.md deleted file mode 100644 index 9c51f54a..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/franklin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-franklin-plugin.git -cd asdf-franklin-plugin - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-franklin-plugin-dev -toolbox enter asdf-franklin-plugin-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-franklin-plugin/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-franklin-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-franklin-plugin/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-franklin-plugin/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-franklin-plugin/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/franklin/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/franklin/README.adoc new file mode 100644 index 00000000..f1f882c6 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/franklin/README.adoc @@ -0,0 +1,83 @@ +== asdf-franklin + +https://github.com/hyperpolymath/asdf-franklin-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-franklin-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-franklin-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-franklin-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] + +https://asdf-vm.com[asdf] plugin for +https://franklinjl.org[Franklin.jl]. + +Julia static site generator. + +=== Contents + +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] + +=== Dependencies + +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] + +=== Install + +Plugin: + +[source,bash] +---- +asdf plugin add franklin https://github.com/hyperpolymath/asdf-franklin-plugin.git +---- + +franklin: + +[source,bash] +---- +# Show all installable versions +asdf list-all franklin + +# Install specific version +asdf install franklin latest + +# Set a version globally (in your ~/.tool-versions file) +asdf global franklin latest + +# Now franklin commands are available +franklin --version +---- + +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. + +=== Usage + +[source,bash] +---- +# List installed versions +asdf list franklin + +# Set local version for current directory +asdf local franklin + +# Uninstall a version +asdf uninstall franklin +---- + +=== Contributing + +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License + +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. + +''''' + +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/franklin/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/franklin/README.md deleted file mode 100644 index 72876015..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/franklin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-franklin - -[![Build](https://github.com/hyperpolymath/asdf-franklin-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-franklin-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-franklin-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-franklin-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Franklin.jl](https://franklinjl.org). - -Julia static site generator. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add franklin https://github.com/hyperpolymath/asdf-franklin-plugin.git -``` - -franklin: - -```bash -# Show all installable versions -asdf list-all franklin - -# Install specific version -asdf install franklin latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global franklin latest - -# Now franklin commands are available -franklin --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list franklin - -# Set local version for current directory -asdf local franklin - -# Uninstall a version -asdf uninstall franklin -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/franklin/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/franklin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/franklin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/franklin/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/franklin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/franklin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/fulcio/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/fulcio/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/fulcio/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/fulcio/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/fulcio/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/fulcio/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/fulcio/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/fulcio/CONTRIBUTING.adoc index d18532b5..1d015055 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/fulcio/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/fulcio/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-fulcio-plugin.git cd +asdf-fulcio-plugin -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-fulcio-plugin-dev toolbox enter +asdf-fulcio-plugin-dev # Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-fulcio-plugin/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-fulcio-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-fulcio-plugin/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-fulcio-plugin/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-fulcio-plugin/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/fulcio/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/fulcio/CONTRIBUTING.md deleted file mode 100644 index c61ac639..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/fulcio/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-fulcio-plugin.git -cd asdf-fulcio-plugin - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-fulcio-plugin-dev -toolbox enter asdf-fulcio-plugin-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-fulcio-plugin/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-fulcio-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-fulcio-plugin/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-fulcio-plugin/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-fulcio-plugin/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/fulcio/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/fulcio/README.adoc new file mode 100644 index 00000000..b81f375d --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/fulcio/README.adoc @@ -0,0 +1,82 @@ +== asdf-fulcio + +https://github.com/hyperpolymath/asdf-fulcio-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-fulcio-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-fulcio-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-fulcio-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] + +https://asdf-vm.com[asdf] plugin for https://sigstore.dev[Fulcio]. + +Sigstore certificate authority. + +=== Contents + +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] + +=== Dependencies + +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] + +=== Install + +Plugin: + +[source,bash] +---- +asdf plugin add fulcio https://github.com/hyperpolymath/asdf-fulcio-plugin.git +---- + +fulcio: + +[source,bash] +---- +# Show all installable versions +asdf list-all fulcio + +# Install specific version +asdf install fulcio latest + +# Set a version globally (in your ~/.tool-versions file) +asdf global fulcio latest + +# Now fulcio commands are available +fulcio --version +---- + +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. + +=== Usage + +[source,bash] +---- +# List installed versions +asdf list fulcio + +# Set local version for current directory +asdf local fulcio + +# Uninstall a version +asdf uninstall fulcio +---- + +=== Contributing + +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License + +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. + +''''' + +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/fulcio/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/fulcio/README.md deleted file mode 100644 index 7779116b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/fulcio/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-fulcio - -[![Build](https://github.com/hyperpolymath/asdf-fulcio-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-fulcio-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-fulcio-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-fulcio-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Fulcio](https://sigstore.dev). - -Sigstore certificate authority. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add fulcio https://github.com/hyperpolymath/asdf-fulcio-plugin.git -``` - -fulcio: - -```bash -# Show all installable versions -asdf list-all fulcio - -# Install specific version -asdf install fulcio latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global fulcio latest - -# Now fulcio commands are available -fulcio --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list fulcio - -# Set local version for current directory -asdf local fulcio - -# Uninstall a version -asdf uninstall fulcio -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/fulcio/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/fulcio/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/fulcio/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/fulcio/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/fulcio/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/fulcio/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/git-crypt/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/git-crypt/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/git-crypt/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/git-crypt/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/git-crypt/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/git-crypt/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/git-crypt/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/git-crypt/CONTRIBUTING.adoc index d18532b5..9a66b532 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/git-crypt/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/git-crypt/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-git-crypt-plugin.git cd +asdf-git-crypt-plugin -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-git-crypt-plugin-dev toolbox enter +asdf-git-crypt-plugin-dev # Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-git-crypt-plugin/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-git-crypt-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-git-crypt-plugin/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-git-crypt-plugin/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-git-crypt-plugin/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/git-crypt/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/git-crypt/CONTRIBUTING.md deleted file mode 100644 index 0e6907aa..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/git-crypt/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-git-crypt-plugin.git -cd asdf-git-crypt-plugin - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-git-crypt-plugin-dev -toolbox enter asdf-git-crypt-plugin-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-git-crypt-plugin/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-git-crypt-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-git-crypt-plugin/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-git-crypt-plugin/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-git-crypt-plugin/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/git-crypt/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/git-crypt/README.adoc new file mode 100644 index 00000000..8d477498 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/git-crypt/README.adoc @@ -0,0 +1,83 @@ +== asdf-git-crypt + +https://github.com/hyperpolymath/asdf-git-crypt-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-git-crypt-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-git-crypt-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-git-crypt-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] + +https://asdf-vm.com[asdf] plugin for +https://www.agwa.name/projects/git-crypt[git-crypt]. + +Transparent git encryption. + +=== Contents + +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] + +=== Dependencies + +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] + +=== Install + +Plugin: + +[source,bash] +---- +asdf plugin add git-crypt https://github.com/hyperpolymath/asdf-git-crypt-plugin.git +---- + +git-crypt: + +[source,bash] +---- +# Show all installable versions +asdf list-all git-crypt + +# Install specific version +asdf install git-crypt latest + +# Set a version globally (in your ~/.tool-versions file) +asdf global git-crypt latest + +# Now git-crypt commands are available +git-crypt --version +---- + +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. + +=== Usage + +[source,bash] +---- +# List installed versions +asdf list git-crypt + +# Set local version for current directory +asdf local git-crypt + +# Uninstall a version +asdf uninstall git-crypt +---- + +=== Contributing + +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License + +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. + +''''' + +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/git-crypt/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/git-crypt/README.md deleted file mode 100644 index 1ee1fac7..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/git-crypt/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-git-crypt - -[![Build](https://github.com/hyperpolymath/asdf-git-crypt-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-git-crypt-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-git-crypt-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-git-crypt-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [git-crypt](https://www.agwa.name/projects/git-crypt). - -Transparent git encryption. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add git-crypt https://github.com/hyperpolymath/asdf-git-crypt-plugin.git -``` - -git-crypt: - -```bash -# Show all installable versions -asdf list-all git-crypt - -# Install specific version -asdf install git-crypt latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global git-crypt latest - -# Now git-crypt commands are available -git-crypt --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list git-crypt - -# Set local version for current directory -asdf local git-crypt - -# Uninstall a version -asdf uninstall git-crypt -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/git-crypt/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/git-crypt/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/git-crypt/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/git-crypt/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/git-crypt/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/git-crypt/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/gitleaks/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/gitleaks/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/gitleaks/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/gitleaks/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/gitleaks/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/gitleaks/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/gitleaks/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/gitleaks/CONTRIBUTING.adoc index d18532b5..9b949070 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/gitleaks/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/gitleaks/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-gitleaks-plugin.git cd +asdf-gitleaks-plugin -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-gitleaks-plugin-dev toolbox enter +asdf-gitleaks-plugin-dev # Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-gitleaks-plugin/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-gitleaks-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-gitleaks-plugin/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-gitleaks-plugin/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-gitleaks-plugin/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/gitleaks/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/gitleaks/CONTRIBUTING.md deleted file mode 100644 index 8f0b9ebf..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/gitleaks/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-gitleaks-plugin.git -cd asdf-gitleaks-plugin - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-gitleaks-plugin-dev -toolbox enter asdf-gitleaks-plugin-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-gitleaks-plugin/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-gitleaks-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-gitleaks-plugin/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-gitleaks-plugin/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-gitleaks-plugin/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/gitleaks/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/gitleaks/README.adoc new file mode 100644 index 00000000..7ec85981 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/gitleaks/README.adoc @@ -0,0 +1,82 @@ +== asdf-gitleaks + +https://github.com/hyperpolymath/asdf-gitleaks-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-gitleaks-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-gitleaks-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-gitleaks-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] + +https://asdf-vm.com[asdf] plugin for https://gitleaks.io[Gitleaks]. + +Git secret scanner. + +=== Contents + +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] + +=== Dependencies + +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] + +=== Install + +Plugin: + +[source,bash] +---- +asdf plugin add gitleaks https://github.com/hyperpolymath/asdf-gitleaks-plugin.git +---- + +gitleaks: + +[source,bash] +---- +# Show all installable versions +asdf list-all gitleaks + +# Install specific version +asdf install gitleaks latest + +# Set a version globally (in your ~/.tool-versions file) +asdf global gitleaks latest + +# Now gitleaks commands are available +gitleaks --version +---- + +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. + +=== Usage + +[source,bash] +---- +# List installed versions +asdf list gitleaks + +# Set local version for current directory +asdf local gitleaks + +# Uninstall a version +asdf uninstall gitleaks +---- + +=== Contributing + +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License + +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. + +''''' + +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/gitleaks/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/gitleaks/README.md deleted file mode 100644 index 946db3a6..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/gitleaks/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-gitleaks - -[![Build](https://github.com/hyperpolymath/asdf-gitleaks-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-gitleaks-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-gitleaks-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-gitleaks-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Gitleaks](https://gitleaks.io). - -Git secret scanner. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add gitleaks https://github.com/hyperpolymath/asdf-gitleaks-plugin.git -``` - -gitleaks: - -```bash -# Show all installable versions -asdf list-all gitleaks - -# Install specific version -asdf install gitleaks latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global gitleaks latest - -# Now gitleaks commands are available -gitleaks --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list gitleaks - -# Set local version for current directory -asdf local gitleaks - -# Uninstall a version -asdf uninstall gitleaks -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/gitleaks/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/gitleaks/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/gitleaks/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/gitleaks/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/gitleaks/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/gitleaks/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/grype/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/grype/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/grype/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/grype/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/grype/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/grype/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/grype/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/grype/CONTRIBUTING.adoc index d18532b5..a4cb53c3 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/grype/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/grype/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-grype-plugin.git cd +asdf-grype-plugin -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-grype-plugin-dev toolbox enter asdf-grype-plugin-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-grype-plugin/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-grype-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-grype-plugin/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-grype-plugin/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-grype-plugin/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/grype/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/grype/CONTRIBUTING.md deleted file mode 100644 index f0263d08..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/grype/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-grype-plugin.git -cd asdf-grype-plugin - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-grype-plugin-dev -toolbox enter asdf-grype-plugin-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-grype-plugin/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-grype-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-grype-plugin/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-grype-plugin/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-grype-plugin/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/grype/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/grype/README.adoc new file mode 100644 index 00000000..3db2f688 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/grype/README.adoc @@ -0,0 +1,82 @@ +== asdf-grype + +https://github.com/hyperpolymath/asdf-grype-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-grype-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-grype-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-grype-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] + +https://asdf-vm.com[asdf] plugin for https://anchore.com/grype[Grype]. + +Container vulnerability scanner. + +=== Contents + +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] + +=== Dependencies + +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] + +=== Install + +Plugin: + +[source,bash] +---- +asdf plugin add grype https://github.com/hyperpolymath/asdf-grype-plugin.git +---- + +grype: + +[source,bash] +---- +# Show all installable versions +asdf list-all grype + +# Install specific version +asdf install grype latest + +# Set a version globally (in your ~/.tool-versions file) +asdf global grype latest + +# Now grype commands are available +grype --version +---- + +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. + +=== Usage + +[source,bash] +---- +# List installed versions +asdf list grype + +# Set local version for current directory +asdf local grype + +# Uninstall a version +asdf uninstall grype +---- + +=== Contributing + +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License + +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. + +''''' + +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/grype/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/grype/README.md deleted file mode 100644 index 087a519a..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/grype/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-grype - -[![Build](https://github.com/hyperpolymath/asdf-grype-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-grype-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-grype-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-grype-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Grype](https://anchore.com/grype). - -Container vulnerability scanner. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add grype https://github.com/hyperpolymath/asdf-grype-plugin.git -``` - -grype: - -```bash -# Show all installable versions -asdf list-all grype - -# Install specific version -asdf install grype latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global grype latest - -# Now grype commands are available -grype --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list grype - -# Set local version for current directory -asdf local grype - -# Uninstall a version -asdf uninstall grype -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/grype/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/grype/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/grype/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/grype/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/grype/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/grype/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/haproxy/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/haproxy/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/haproxy/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/haproxy/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/haproxy/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/haproxy/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/haproxy/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/haproxy/CONTRIBUTING.adoc index d18532b5..cac873a9 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/haproxy/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/haproxy/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-haproxy-plugin.git cd +asdf-haproxy-plugin -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-haproxy-plugin-dev toolbox enter +asdf-haproxy-plugin-dev # Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-haproxy-plugin/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-haproxy-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-haproxy-plugin/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-haproxy-plugin/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-haproxy-plugin/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/haproxy/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/haproxy/CONTRIBUTING.md deleted file mode 100644 index 42989f74..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/haproxy/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-haproxy-plugin.git -cd asdf-haproxy-plugin - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-haproxy-plugin-dev -toolbox enter asdf-haproxy-plugin-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-haproxy-plugin/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-haproxy-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-haproxy-plugin/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-haproxy-plugin/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-haproxy-plugin/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/haproxy/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/haproxy/README.adoc new file mode 100644 index 00000000..7d6612ef --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/haproxy/README.adoc @@ -0,0 +1,82 @@ +== asdf-haproxy + +https://github.com/hyperpolymath/asdf-haproxy-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-haproxy-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-haproxy-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-haproxy-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] + +https://asdf-vm.com[asdf] plugin for https://www.haproxy.org[HAProxy]. + +High-availability load balancer. + +=== Contents + +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] + +=== Dependencies + +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] + +=== Install + +Plugin: + +[source,bash] +---- +asdf plugin add haproxy https://github.com/hyperpolymath/asdf-haproxy-plugin.git +---- + +haproxy: + +[source,bash] +---- +# Show all installable versions +asdf list-all haproxy + +# Install specific version +asdf install haproxy latest + +# Set a version globally (in your ~/.tool-versions file) +asdf global haproxy latest + +# Now haproxy commands are available +haproxy --version +---- + +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. + +=== Usage + +[source,bash] +---- +# List installed versions +asdf list haproxy + +# Set local version for current directory +asdf local haproxy + +# Uninstall a version +asdf uninstall haproxy +---- + +=== Contributing + +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License + +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. + +''''' + +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/haproxy/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/haproxy/README.md deleted file mode 100644 index 3f311310..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/haproxy/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-haproxy - -[![Build](https://github.com/hyperpolymath/asdf-haproxy-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-haproxy-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-haproxy-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-haproxy-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [HAProxy](https://www.haproxy.org). - -High-availability load balancer. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add haproxy https://github.com/hyperpolymath/asdf-haproxy-plugin.git -``` - -haproxy: - -```bash -# Show all installable versions -asdf list-all haproxy - -# Install specific version -asdf install haproxy latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global haproxy latest - -# Now haproxy commands are available -haproxy --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list haproxy - -# Set local version for current directory -asdf local haproxy - -# Uninstall a version -asdf uninstall haproxy -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/haproxy/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/haproxy/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/haproxy/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/haproxy/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/haproxy/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/haproxy/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/hashicorp/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/hashicorp/ABI-FFI-README.adoc new file mode 100644 index 00000000..31ce416d --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/hashicorp/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== HASHICORP ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/hashicorp.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libhashicorp.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +hashicorp/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── hashicorp.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── hashicorp.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/hashicorp.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "hashicorp.h" + +int main() { + void* handle = hashicorp_init(); + if (!handle) return 1; + + int result = hashicorp_process(handle, 42); + if (result != 0) { + const char* err = hashicorp_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + hashicorp_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lhashicorp -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import HASHICORP.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "hashicorp")] +extern "C" { + fn hashicorp_init() -> *mut std::ffi::c_void; + fn hashicorp_free(handle: *mut std::ffi::c_void); + fn hashicorp_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = hashicorp_init(); + assert!(!handle.is_null()); + + let result = hashicorp_process(handle, 42); + assert_eq!(result, 0); + + hashicorp_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libhashicorp = "libhashicorp" + +function init() + handle = ccall((:hashicorp_init, libhashicorp), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:hashicorp_process, libhashicorp), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:hashicorp_free, libhashicorp), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/hashicorp.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/hashicorp/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/hashicorp/ABI-FFI-README.md deleted file mode 100644 index 34629ce4..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/hashicorp/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# HASHICORP ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/hashicorp.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libhashicorp.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -hashicorp/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── hashicorp.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── hashicorp.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/hashicorp.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "hashicorp.h" - -int main() { - void* handle = hashicorp_init(); - if (!handle) return 1; - - int result = hashicorp_process(handle, 42); - if (result != 0) { - const char* err = hashicorp_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - hashicorp_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lhashicorp -L./zig-out/lib -``` - -### From Idris2 - -```idris -import HASHICORP.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "hashicorp")] -extern "C" { - fn hashicorp_init() -> *mut std::ffi::c_void; - fn hashicorp_free(handle: *mut std::ffi::c_void); - fn hashicorp_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = hashicorp_init(); - assert!(!handle.is_null()); - - let result = hashicorp_process(handle, 42); - assert_eq!(result, 0); - - hashicorp_free(handle); - } -} -``` - -### From Julia - -```julia -const libhashicorp = "libhashicorp" - -function init() - handle = ccall((:hashicorp_init, libhashicorp), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:hashicorp_process, libhashicorp), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:hashicorp_free, libhashicorp), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/hashicorp.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/hashicorp/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/hashicorp/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/hashicorp/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/hashicorp/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/hashicorp/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/hashicorp/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/hashicorp/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/hashicorp/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/hashicorp/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/hashicorp/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/hashicorp/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/hashicorp/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/hashicorp/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/hashicorp/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/hashicorp/README.adoc index 47cca4cd..2b2871c6 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/hashicorp/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/hashicorp/README.adoc @@ -1,60 +1,83 @@ -= asdf-hashicorp +== asdf-hashicorp -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] -:author: hyperpolymath -:url-asdf: https://asdf-vm.com -:url-repo: https://github.com/hyperpolymath/asdf-hashicorp-plugin +https://github.com/hyperpolymath/asdf-hashicorp-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-hashicorp-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-hashicorp-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-hashicorp-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -image:https://img.shields.io/github/license/hyperpolymath/asdf-hashicorp-plugin?style=flat-square[License,link=LICENSE] -image:https://img.shields.io/github/actions/workflow/status/hyperpolymath/asdf-hashicorp-plugin/ci.yml?branch=main&style=flat-square[Build Status,link={url-repo}/actions] +https://asdf-vm.com[asdf] plugin for https://www.hashicorp.com[HashiCorp +Tools]. -An {url-asdf}[asdf] plugin to manage all HashiCorp tools. +Terraform, Vault, Consul. -== Supported Tools +=== Contents -* **vault** - Secrets management -* **terraform** - Infrastructure as Code -* **consul** - Service mesh -* **nomad** - Workload orchestration -* **packer** - Image builder -* **vagrant** - Development environments -* **boundary** - Secure remote access -* **waypoint** - Application deployment -* **sentinel** - Policy as Code -* **consul-template** - Template rendering -* **envconsul** - Environment variables from Consul +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -== Installation +=== Dependencies -Add the plugin for each tool you need: +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] + +=== Install + +Plugin: [source,bash] ---- -# Add individual tools -asdf plugin add vault https://github.com/hyperpolymath/asdf-hashicorp-plugin.git -asdf plugin add terraform https://github.com/hyperpolymath/asdf-hashicorp-plugin.git -asdf plugin add consul https://github.com/hyperpolymath/asdf-hashicorp-plugin.git -asdf plugin add nomad https://github.com/hyperpolymath/asdf-hashicorp-plugin.git -asdf plugin add packer https://github.com/hyperpolymath/asdf-hashicorp-plugin.git +asdf plugin add hashicorp https://github.com/hyperpolymath/asdf-hashicorp-plugin.git ---- -== Usage +hashicorp: [source,bash] ---- -# List all available versions -asdf list all vault +# Show all installable versions +asdf list-all hashicorp + +# Install specific version +asdf install hashicorp latest + +# Set a version globally (in your ~/.tool-versions file) +asdf global hashicorp latest + +# Now hashicorp commands are available +hashicorp --version +---- + +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -# Install a specific version -asdf install vault 1.15.0 +=== Usage -# Install latest -asdf install terraform latest +[source,bash] +---- +# List installed versions +asdf list hashicorp -# Set global default -asdf global vault 1.15.0 +# Set local version for current directory +asdf local hashicorp + +# Uninstall a version +asdf uninstall hashicorp ---- -== License +=== Contributing + +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License + +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. + +''''' -SPDX-License-Identifier: CC-BY-SA-4.0 +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/hashicorp/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/hashicorp/README.md deleted file mode 100644 index 74f93203..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/hashicorp/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-hashicorp - -[![Build](https://github.com/hyperpolymath/asdf-hashicorp-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-hashicorp-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-hashicorp-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-hashicorp-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [HashiCorp Tools](https://www.hashicorp.com). - -Terraform, Vault, Consul. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add hashicorp https://github.com/hyperpolymath/asdf-hashicorp-plugin.git -``` - -hashicorp: - -```bash -# Show all installable versions -asdf list-all hashicorp - -# Install specific version -asdf install hashicorp latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global hashicorp latest - -# Now hashicorp commands are available -hashicorp --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list hashicorp - -# Set local version for current directory -asdf local hashicorp - -# Uninstall a version -asdf uninstall hashicorp -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/hashicorp/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/hashicorp/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/hashicorp/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/hashicorp/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/hashicorp/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/hashicorp/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/httpd/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/httpd/ABI-FFI-README.adoc new file mode 100644 index 00000000..ed324584 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/httpd/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== HTTPD ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/httpd.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libhttpd.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +httpd/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── httpd.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── httpd.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/httpd.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "httpd.h" + +int main() { + void* handle = httpd_init(); + if (!handle) return 1; + + int result = httpd_process(handle, 42); + if (result != 0) { + const char* err = httpd_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + httpd_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lhttpd -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import HTTPD.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "httpd")] +extern "C" { + fn httpd_init() -> *mut std::ffi::c_void; + fn httpd_free(handle: *mut std::ffi::c_void); + fn httpd_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = httpd_init(); + assert!(!handle.is_null()); + + let result = httpd_process(handle, 42); + assert_eq!(result, 0); + + httpd_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libhttpd = "libhttpd" + +function init() + handle = ccall((:httpd_init, libhttpd), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:httpd_process, libhttpd), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:httpd_free, libhttpd), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/httpd.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/httpd/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/httpd/ABI-FFI-README.md deleted file mode 100644 index 1201c275..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/httpd/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# HTTPD ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/httpd.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libhttpd.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -httpd/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── httpd.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── httpd.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/httpd.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "httpd.h" - -int main() { - void* handle = httpd_init(); - if (!handle) return 1; - - int result = httpd_process(handle, 42); - if (result != 0) { - const char* err = httpd_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - httpd_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lhttpd -L./zig-out/lib -``` - -### From Idris2 - -```idris -import HTTPD.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "httpd")] -extern "C" { - fn httpd_init() -> *mut std::ffi::c_void; - fn httpd_free(handle: *mut std::ffi::c_void); - fn httpd_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = httpd_init(); - assert!(!handle.is_null()); - - let result = httpd_process(handle, 42); - assert_eq!(result, 0); - - httpd_free(handle); - } -} -``` - -### From Julia - -```julia -const libhttpd = "libhttpd" - -function init() - handle = ccall((:httpd_init, libhttpd), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:httpd_process, libhttpd), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:httpd_free, libhttpd), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/httpd.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/httpd/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/httpd/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/httpd/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/httpd/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/httpd/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/httpd/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/httpd/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/httpd/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/httpd/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/httpd/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/httpd/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/httpd/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/httpd/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/httpd/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/httpd/README.adoc index d08e1dd2..be6ffebb 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/httpd/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/httpd/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-httpd -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-httpd-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-httpd-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-httpd-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-httpd-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://httpd.apache.org[Apache +HTTP Server]. -**All repos with foreign function interfaces MUST follow this standard:** +Web server. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add httpd https://github.com/hyperpolymath/asdf-httpd-plugin.git +---- -=== Web Projects +httpd: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all httpd -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install httpd latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global httpd latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now httpd commands are available +httpd --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list httpd -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local httpd -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall httpd ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/httpd/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/httpd/README.md deleted file mode 100644 index 4fb07dda..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/httpd/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-httpd - -[![Build](https://github.com/hyperpolymath/asdf-httpd-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-httpd-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-httpd-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-httpd-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Apache HTTP Server](https://httpd.apache.org). - -Web server. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add httpd https://github.com/hyperpolymath/asdf-httpd-plugin.git -``` - -httpd: - -```bash -# Show all installable versions -asdf list-all httpd - -# Install specific version -asdf install httpd latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global httpd latest - -# Now httpd commands are available -httpd --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list httpd - -# Set local version for current directory -asdf local httpd - -# Uninstall a version -asdf uninstall httpd -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/httpd/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/httpd/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/httpd/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/httpd/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/httpd/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/httpd/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/influxdb/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/influxdb/ABI-FFI-README.adoc new file mode 100644 index 00000000..80f95c5c --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/influxdb/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== INFLUXDB ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/influxdb.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libinfluxdb.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +influxdb/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── influxdb.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── influxdb.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/influxdb.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "influxdb.h" + +int main() { + void* handle = influxdb_init(); + if (!handle) return 1; + + int result = influxdb_process(handle, 42); + if (result != 0) { + const char* err = influxdb_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + influxdb_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -linfluxdb -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import INFLUXDB.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "influxdb")] +extern "C" { + fn influxdb_init() -> *mut std::ffi::c_void; + fn influxdb_free(handle: *mut std::ffi::c_void); + fn influxdb_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = influxdb_init(); + assert!(!handle.is_null()); + + let result = influxdb_process(handle, 42); + assert_eq!(result, 0); + + influxdb_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libinfluxdb = "libinfluxdb" + +function init() + handle = ccall((:influxdb_init, libinfluxdb), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:influxdb_process, libinfluxdb), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:influxdb_free, libinfluxdb), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/influxdb.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/influxdb/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/influxdb/ABI-FFI-README.md deleted file mode 100644 index 776a116f..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/influxdb/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# INFLUXDB ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/influxdb.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libinfluxdb.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -influxdb/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── influxdb.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── influxdb.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/influxdb.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "influxdb.h" - -int main() { - void* handle = influxdb_init(); - if (!handle) return 1; - - int result = influxdb_process(handle, 42); - if (result != 0) { - const char* err = influxdb_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - influxdb_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -linfluxdb -L./zig-out/lib -``` - -### From Idris2 - -```idris -import INFLUXDB.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "influxdb")] -extern "C" { - fn influxdb_init() -> *mut std::ffi::c_void; - fn influxdb_free(handle: *mut std::ffi::c_void); - fn influxdb_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = influxdb_init(); - assert!(!handle.is_null()); - - let result = influxdb_process(handle, 42); - assert_eq!(result, 0); - - influxdb_free(handle); - } -} -``` - -### From Julia - -```julia -const libinfluxdb = "libinfluxdb" - -function init() - handle = ccall((:influxdb_init, libinfluxdb), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:influxdb_process, libinfluxdb), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:influxdb_free, libinfluxdb), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/influxdb.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/influxdb/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/influxdb/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/influxdb/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/influxdb/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/influxdb/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/influxdb/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/influxdb/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/influxdb/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/influxdb/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/influxdb/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/influxdb/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/influxdb/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/influxdb/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/influxdb/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/influxdb/README.adoc index d08e1dd2..cb85c8e4 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/influxdb/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/influxdb/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-influxdb -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-influxdb-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-influxdb-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-influxdb-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-influxdb-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://www.influxdata.com[InfluxDB]. -**All repos with foreign function interfaces MUST follow this standard:** +Time series database. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add influxdb https://github.com/hyperpolymath/asdf-influxdb-plugin.git +---- -=== Web Projects +influxdb: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all influxdb -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install influxdb latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global influxdb latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now influxdb commands are available +influxdb --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list influxdb -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local influxdb -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall influxdb ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/influxdb/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/influxdb/README.md deleted file mode 100644 index e85372e0..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/influxdb/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-influxdb - -[![Build](https://github.com/hyperpolymath/asdf-influxdb-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-influxdb-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-influxdb-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-influxdb-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [InfluxDB](https://www.influxdata.com). - -Time series database. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add influxdb https://github.com/hyperpolymath/asdf-influxdb-plugin.git -``` - -influxdb: - -```bash -# Show all installable versions -asdf list-all influxdb - -# Install specific version -asdf install influxdb latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global influxdb latest - -# Now influxdb commands are available -influxdb --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list influxdb - -# Set local version for current directory -asdf local influxdb - -# Uninstall a version -asdf uninstall influxdb -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/influxdb/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/influxdb/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/influxdb/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/influxdb/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/influxdb/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/influxdb/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/kdl-fmt/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/kdl-fmt/ABI-FFI-README.adoc new file mode 100644 index 00000000..0ddb18a7 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/kdl-fmt/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== KDL_FMT ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/kdl-fmt.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libkdl-fmt.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +kdl-fmt/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── kdl-fmt.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── kdl-fmt.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/kdl-fmt.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "kdl-fmt.h" + +int main() { + void* handle = kdl-fmt_init(); + if (!handle) return 1; + + int result = kdl-fmt_process(handle, 42); + if (result != 0) { + const char* err = kdl-fmt_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + kdl-fmt_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lkdl-fmt -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import KDL_FMT.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "kdl-fmt")] +extern "C" { + fn kdl-fmt_init() -> *mut std::ffi::c_void; + fn kdl-fmt_free(handle: *mut std::ffi::c_void); + fn kdl-fmt_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = kdl-fmt_init(); + assert!(!handle.is_null()); + + let result = kdl-fmt_process(handle, 42); + assert_eq!(result, 0); + + kdl-fmt_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libkdl-fmt = "libkdl-fmt" + +function init() + handle = ccall((:kdl-fmt_init, libkdl-fmt), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:kdl-fmt_process, libkdl-fmt), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:kdl-fmt_free, libkdl-fmt), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/kdl-fmt.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/kdl-fmt/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/kdl-fmt/ABI-FFI-README.md deleted file mode 100644 index ddfecda6..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/kdl-fmt/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# KDL_FMT ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/kdl-fmt.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libkdl-fmt.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -kdl-fmt/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── kdl-fmt.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── kdl-fmt.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/kdl-fmt.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "kdl-fmt.h" - -int main() { - void* handle = kdl-fmt_init(); - if (!handle) return 1; - - int result = kdl-fmt_process(handle, 42); - if (result != 0) { - const char* err = kdl-fmt_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - kdl-fmt_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lkdl-fmt -L./zig-out/lib -``` - -### From Idris2 - -```idris -import KDL_FMT.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "kdl-fmt")] -extern "C" { - fn kdl-fmt_init() -> *mut std::ffi::c_void; - fn kdl-fmt_free(handle: *mut std::ffi::c_void); - fn kdl-fmt_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = kdl-fmt_init(); - assert!(!handle.is_null()); - - let result = kdl-fmt_process(handle, 42); - assert_eq!(result, 0); - - kdl-fmt_free(handle); - } -} -``` - -### From Julia - -```julia -const libkdl-fmt = "libkdl-fmt" - -function init() - handle = ccall((:kdl-fmt_init, libkdl-fmt), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:kdl-fmt_process, libkdl-fmt), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:kdl-fmt_free, libkdl-fmt), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/kdl-fmt.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/kdl-fmt/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/kdl-fmt/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/kdl-fmt/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/kdl-fmt/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/kdl-fmt/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/kdl-fmt/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/kdl-fmt/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/kdl-fmt/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/kdl-fmt/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/kdl-fmt/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/kdl-fmt/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/kdl-fmt/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/kdl-fmt/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/kdl-fmt/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/kdl-fmt/README.adoc index d08e1dd2..1bf9cbc8 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/kdl-fmt/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/kdl-fmt/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-kdl-fmt -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-kdl-fmt-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-kdl-fmt-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-kdl-fmt-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-kdl-fmt-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://kdl.dev[kdl-fmt]. -**All repos with foreign function interfaces MUST follow this standard:** +KDL document formatter. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add kdl-fmt https://github.com/hyperpolymath/asdf-kdl-fmt-plugin.git +---- -=== Web Projects +kdl-fmt: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all kdl-fmt -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install kdl-fmt latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global kdl-fmt latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now kdl-fmt commands are available +kdl-fmt --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list kdl-fmt -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local kdl-fmt -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall kdl-fmt ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/kdl-fmt/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/kdl-fmt/README.md deleted file mode 100644 index 2e1285d5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/kdl-fmt/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-kdl-fmt - -[![Build](https://github.com/hyperpolymath/asdf-kdl-fmt-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-kdl-fmt-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-kdl-fmt-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-kdl-fmt-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [kdl-fmt](https://kdl.dev). - -KDL document formatter. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add kdl-fmt https://github.com/hyperpolymath/asdf-kdl-fmt-plugin.git -``` - -kdl-fmt: - -```bash -# Show all installable versions -asdf list-all kdl-fmt - -# Install specific version -asdf install kdl-fmt latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global kdl-fmt latest - -# Now kdl-fmt commands are available -kdl-fmt --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list kdl-fmt - -# Set local version for current directory -asdf local kdl-fmt - -# Uninstall a version -asdf uninstall kdl-fmt -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/kdl-fmt/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/kdl-fmt/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/kdl-fmt/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/kdl-fmt/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/kdl-fmt/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/kdl-fmt/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/lego/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/lego/ABI-FFI-README.adoc new file mode 100644 index 00000000..112425b2 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/lego/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== LEGO ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/lego.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to liblego.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +lego/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── lego.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── lego.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/lego.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "lego.h" + +int main() { + void* handle = lego_init(); + if (!handle) return 1; + + int result = lego_process(handle, 42); + if (result != 0) { + const char* err = lego_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + lego_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -llego -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import LEGO.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "lego")] +extern "C" { + fn lego_init() -> *mut std::ffi::c_void; + fn lego_free(handle: *mut std::ffi::c_void); + fn lego_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = lego_init(); + assert!(!handle.is_null()); + + let result = lego_process(handle, 42); + assert_eq!(result, 0); + + lego_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const liblego = "liblego" + +function init() + handle = ccall((:lego_init, liblego), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:lego_process, liblego), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:lego_free, liblego), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/lego.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/lego/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/lego/ABI-FFI-README.md deleted file mode 100644 index 376d5f24..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/lego/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# LEGO ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/lego.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to liblego.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -lego/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── lego.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── lego.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/lego.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "lego.h" - -int main() { - void* handle = lego_init(); - if (!handle) return 1; - - int result = lego_process(handle, 42); - if (result != 0) { - const char* err = lego_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - lego_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -llego -L./zig-out/lib -``` - -### From Idris2 - -```idris -import LEGO.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "lego")] -extern "C" { - fn lego_init() -> *mut std::ffi::c_void; - fn lego_free(handle: *mut std::ffi::c_void); - fn lego_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = lego_init(); - assert!(!handle.is_null()); - - let result = lego_process(handle, 42); - assert_eq!(result, 0); - - lego_free(handle); - } -} -``` - -### From Julia - -```julia -const liblego = "liblego" - -function init() - handle = ccall((:lego_init, liblego), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:lego_process, liblego), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:lego_free, liblego), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/lego.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/lego/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/lego/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/lego/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/lego/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/lego/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/lego/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/lego/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/lego/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/lego/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/lego/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/lego/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/lego/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/lego/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/lego/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/lego/README.adoc index d08e1dd2..d8e272b2 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/lego/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/lego/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-lego -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-lego-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-lego-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-lego-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-lego-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://go-acme.github.io/lego[LEGO]. -**All repos with foreign function interfaces MUST follow this standard:** +ACME client. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add lego https://github.com/hyperpolymath/asdf-lego-plugin.git +---- -=== Web Projects +lego: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all lego -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install lego latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global lego latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now lego commands are available +lego --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list lego -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local lego -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall lego ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/lego/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/lego/README.md deleted file mode 100644 index d7ce2aac..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/lego/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-lego - -[![Build](https://github.com/hyperpolymath/asdf-lego-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-lego-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-lego-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-lego-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [LEGO](https://go-acme.github.io/lego). - -ACME client. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add lego https://github.com/hyperpolymath/asdf-lego-plugin.git -``` - -lego: - -```bash -# Show all installable versions -asdf list-all lego - -# Install specific version -asdf install lego latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global lego latest - -# Now lego commands are available -lego --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list lego - -# Set local version for current directory -asdf local lego - -# Uninstall a version -asdf uninstall lego -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/lego/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/lego/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/lego/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/lego/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/lego/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/lego/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/linkerd/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/linkerd/ABI-FFI-README.adoc new file mode 100644 index 00000000..d504aefc --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/linkerd/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== LINKERD ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/linkerd.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to liblinkerd.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +linkerd/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── linkerd.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── linkerd.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/linkerd.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "linkerd.h" + +int main() { + void* handle = linkerd_init(); + if (!handle) return 1; + + int result = linkerd_process(handle, 42); + if (result != 0) { + const char* err = linkerd_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + linkerd_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -llinkerd -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import LINKERD.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "linkerd")] +extern "C" { + fn linkerd_init() -> *mut std::ffi::c_void; + fn linkerd_free(handle: *mut std::ffi::c_void); + fn linkerd_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = linkerd_init(); + assert!(!handle.is_null()); + + let result = linkerd_process(handle, 42); + assert_eq!(result, 0); + + linkerd_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const liblinkerd = "liblinkerd" + +function init() + handle = ccall((:linkerd_init, liblinkerd), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:linkerd_process, liblinkerd), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:linkerd_free, liblinkerd), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/linkerd.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/linkerd/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/linkerd/ABI-FFI-README.md deleted file mode 100644 index 5e32aabe..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/linkerd/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# LINKERD ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/linkerd.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to liblinkerd.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -linkerd/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── linkerd.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── linkerd.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/linkerd.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "linkerd.h" - -int main() { - void* handle = linkerd_init(); - if (!handle) return 1; - - int result = linkerd_process(handle, 42); - if (result != 0) { - const char* err = linkerd_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - linkerd_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -llinkerd -L./zig-out/lib -``` - -### From Idris2 - -```idris -import LINKERD.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "linkerd")] -extern "C" { - fn linkerd_init() -> *mut std::ffi::c_void; - fn linkerd_free(handle: *mut std::ffi::c_void); - fn linkerd_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = linkerd_init(); - assert!(!handle.is_null()); - - let result = linkerd_process(handle, 42); - assert_eq!(result, 0); - - linkerd_free(handle); - } -} -``` - -### From Julia - -```julia -const liblinkerd = "liblinkerd" - -function init() - handle = ccall((:linkerd_init, liblinkerd), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:linkerd_process, liblinkerd), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:linkerd_free, liblinkerd), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/linkerd.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/linkerd/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/linkerd/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/linkerd/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/linkerd/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/linkerd/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/linkerd/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/linkerd/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/linkerd/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/linkerd/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/linkerd/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/linkerd/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/linkerd/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/linkerd/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/linkerd/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/linkerd/README.adoc index d08e1dd2..c4ba49db 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/linkerd/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/linkerd/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-linkerd -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-linkerd-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-linkerd-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-linkerd-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-linkerd-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://linkerd.io[Linkerd CLI]. -**All repos with foreign function interfaces MUST follow this standard:** +Service mesh CLI. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add linkerd https://github.com/hyperpolymath/asdf-linkerd-plugin.git +---- -=== Web Projects +linkerd: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all linkerd -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install linkerd latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global linkerd latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now linkerd commands are available +linkerd --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list linkerd -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local linkerd -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall linkerd ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/linkerd/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/linkerd/README.md deleted file mode 100644 index d715ecc8..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/linkerd/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-linkerd - -[![Build](https://github.com/hyperpolymath/asdf-linkerd-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-linkerd-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-linkerd-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-linkerd-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Linkerd CLI](https://linkerd.io). - -Service mesh CLI. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add linkerd https://github.com/hyperpolymath/asdf-linkerd-plugin.git -``` - -linkerd: - -```bash -# Show all installable versions -asdf list-all linkerd - -# Install specific version -asdf install linkerd latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global linkerd latest - -# Now linkerd commands are available -linkerd --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list linkerd - -# Set local version for current directory -asdf local linkerd - -# Uninstall a version -asdf uninstall linkerd -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/linkerd/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/linkerd/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/linkerd/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/linkerd/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/linkerd/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/linkerd/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/mariadb/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/mariadb/ABI-FFI-README.adoc new file mode 100644 index 00000000..9247cd3c --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/mariadb/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== MARIADB ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/mariadb.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libmariadb.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +mariadb/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── mariadb.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── mariadb.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/mariadb.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "mariadb.h" + +int main() { + void* handle = mariadb_init(); + if (!handle) return 1; + + int result = mariadb_process(handle, 42); + if (result != 0) { + const char* err = mariadb_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + mariadb_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lmariadb -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import MARIADB.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "mariadb")] +extern "C" { + fn mariadb_init() -> *mut std::ffi::c_void; + fn mariadb_free(handle: *mut std::ffi::c_void); + fn mariadb_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = mariadb_init(); + assert!(!handle.is_null()); + + let result = mariadb_process(handle, 42); + assert_eq!(result, 0); + + mariadb_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libmariadb = "libmariadb" + +function init() + handle = ccall((:mariadb_init, libmariadb), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:mariadb_process, libmariadb), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:mariadb_free, libmariadb), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/mariadb.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/mariadb/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/mariadb/ABI-FFI-README.md deleted file mode 100644 index 449dd815..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/mariadb/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# MARIADB ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/mariadb.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libmariadb.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -mariadb/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── mariadb.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── mariadb.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/mariadb.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "mariadb.h" - -int main() { - void* handle = mariadb_init(); - if (!handle) return 1; - - int result = mariadb_process(handle, 42); - if (result != 0) { - const char* err = mariadb_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - mariadb_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lmariadb -L./zig-out/lib -``` - -### From Idris2 - -```idris -import MARIADB.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "mariadb")] -extern "C" { - fn mariadb_init() -> *mut std::ffi::c_void; - fn mariadb_free(handle: *mut std::ffi::c_void); - fn mariadb_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = mariadb_init(); - assert!(!handle.is_null()); - - let result = mariadb_process(handle, 42); - assert_eq!(result, 0); - - mariadb_free(handle); - } -} -``` - -### From Julia - -```julia -const libmariadb = "libmariadb" - -function init() - handle = ccall((:mariadb_init, libmariadb), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:mariadb_process, libmariadb), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:mariadb_free, libmariadb), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/mariadb.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/mariadb/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/mariadb/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/mariadb/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/mariadb/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/mariadb/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/mariadb/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/mariadb/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/mariadb/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/mariadb/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/mariadb/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/mariadb/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/mariadb/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/mariadb/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/mariadb/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/mariadb/README.adoc index d08e1dd2..3ab37418 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/mariadb/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/mariadb/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-mariadb -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-mariadb-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-mariadb-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-mariadb-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-mariadb-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://mariadb.org[MariaDB]. -**All repos with foreign function interfaces MUST follow this standard:** +MySQL-compatible database. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add mariadb https://github.com/hyperpolymath/asdf-mariadb-plugin.git +---- -=== Web Projects +mariadb: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all mariadb -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install mariadb latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global mariadb latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now mariadb commands are available +mariadb --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list mariadb -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local mariadb -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall mariadb ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/mariadb/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/mariadb/README.md deleted file mode 100644 index 212ede30..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/mariadb/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-mariadb - -[![Build](https://github.com/hyperpolymath/asdf-mariadb-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-mariadb-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-mariadb-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-mariadb-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [MariaDB](https://mariadb.org). - -MySQL-compatible database. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add mariadb https://github.com/hyperpolymath/asdf-mariadb-plugin.git -``` - -mariadb: - -```bash -# Show all installable versions -asdf list-all mariadb - -# Install specific version -asdf install mariadb latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global mariadb latest - -# Now mariadb commands are available -mariadb --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list mariadb - -# Set local version for current directory -asdf local mariadb - -# Uninstall a version -asdf uninstall mariadb -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/mariadb/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/mariadb/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/mariadb/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/mariadb/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/mariadb/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/mariadb/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/mdbook/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/mdbook/ABI-FFI-README.adoc new file mode 100644 index 00000000..1cc92c39 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/mdbook/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== MDBOOK ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/mdbook.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libmdbook.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +mdbook/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── mdbook.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── mdbook.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/mdbook.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "mdbook.h" + +int main() { + void* handle = mdbook_init(); + if (!handle) return 1; + + int result = mdbook_process(handle, 42); + if (result != 0) { + const char* err = mdbook_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + mdbook_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lmdbook -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import MDBOOK.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "mdbook")] +extern "C" { + fn mdbook_init() -> *mut std::ffi::c_void; + fn mdbook_free(handle: *mut std::ffi::c_void); + fn mdbook_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = mdbook_init(); + assert!(!handle.is_null()); + + let result = mdbook_process(handle, 42); + assert_eq!(result, 0); + + mdbook_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libmdbook = "libmdbook" + +function init() + handle = ccall((:mdbook_init, libmdbook), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:mdbook_process, libmdbook), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:mdbook_free, libmdbook), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/mdbook.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/mdbook/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/mdbook/ABI-FFI-README.md deleted file mode 100644 index 0ec85b6b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/mdbook/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# MDBOOK ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/mdbook.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libmdbook.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -mdbook/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── mdbook.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── mdbook.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/mdbook.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "mdbook.h" - -int main() { - void* handle = mdbook_init(); - if (!handle) return 1; - - int result = mdbook_process(handle, 42); - if (result != 0) { - const char* err = mdbook_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - mdbook_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lmdbook -L./zig-out/lib -``` - -### From Idris2 - -```idris -import MDBOOK.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "mdbook")] -extern "C" { - fn mdbook_init() -> *mut std::ffi::c_void; - fn mdbook_free(handle: *mut std::ffi::c_void); - fn mdbook_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = mdbook_init(); - assert!(!handle.is_null()); - - let result = mdbook_process(handle, 42); - assert_eq!(result, 0); - - mdbook_free(handle); - } -} -``` - -### From Julia - -```julia -const libmdbook = "libmdbook" - -function init() - handle = ccall((:mdbook_init, libmdbook), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:mdbook_process, libmdbook), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:mdbook_free, libmdbook), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/mdbook.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/mdbook/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/mdbook/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/mdbook/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/mdbook/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/mdbook/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/mdbook/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/mdbook/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/mdbook/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/mdbook/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/mdbook/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/mdbook/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/mdbook/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/mdbook/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/mdbook/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/mdbook/README.adoc index d08e1dd2..ea6cde3e 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/mdbook/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/mdbook/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-mdbook -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-mdbook-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-mdbook-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-mdbook-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-mdbook-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://rust-lang.github.io/mdBook[mdBook]. -**All repos with foreign function interfaces MUST follow this standard:** +Rust documentation tool. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add mdbook https://github.com/hyperpolymath/asdf-mdbook-plugin.git +---- -=== Web Projects +mdbook: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all mdbook -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install mdbook latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global mdbook latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now mdbook commands are available +mdbook --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list mdbook -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local mdbook -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall mdbook ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/mdbook/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/mdbook/README.md deleted file mode 100644 index d30c58bb..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/mdbook/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-mdbook - -[![Build](https://github.com/hyperpolymath/asdf-mdbook-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-mdbook-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-mdbook-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-mdbook-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [mdBook](https://rust-lang.github.io/mdBook). - -Rust documentation tool. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add mdbook https://github.com/hyperpolymath/asdf-mdbook-plugin.git -``` - -mdbook: - -```bash -# Show all installable versions -asdf list-all mdbook - -# Install specific version -asdf install mdbook latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global mdbook latest - -# Now mdbook commands are available -mdbook --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list mdbook - -# Set local version for current directory -asdf local mdbook - -# Uninstall a version -asdf uninstall mdbook -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/mdbook/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/mdbook/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/mdbook/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/mdbook/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/mdbook/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/mdbook/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/melange/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/melange/ABI-FFI-README.adoc new file mode 100644 index 00000000..6d9dd689 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/melange/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== MELANGE ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/melange.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libmelange.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +melange/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── melange.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── melange.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/melange.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "melange.h" + +int main() { + void* handle = melange_init(); + if (!handle) return 1; + + int result = melange_process(handle, 42); + if (result != 0) { + const char* err = melange_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + melange_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lmelange -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import MELANGE.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "melange")] +extern "C" { + fn melange_init() -> *mut std::ffi::c_void; + fn melange_free(handle: *mut std::ffi::c_void); + fn melange_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = melange_init(); + assert!(!handle.is_null()); + + let result = melange_process(handle, 42); + assert_eq!(result, 0); + + melange_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libmelange = "libmelange" + +function init() + handle = ccall((:melange_init, libmelange), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:melange_process, libmelange), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:melange_free, libmelange), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/melange.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/melange/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/melange/ABI-FFI-README.md deleted file mode 100644 index 6a925a4d..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/melange/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# MELANGE ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/melange.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libmelange.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -melange/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── melange.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── melange.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/melange.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "melange.h" - -int main() { - void* handle = melange_init(); - if (!handle) return 1; - - int result = melange_process(handle, 42); - if (result != 0) { - const char* err = melange_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - melange_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lmelange -L./zig-out/lib -``` - -### From Idris2 - -```idris -import MELANGE.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "melange")] -extern "C" { - fn melange_init() -> *mut std::ffi::c_void; - fn melange_free(handle: *mut std::ffi::c_void); - fn melange_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = melange_init(); - assert!(!handle.is_null()); - - let result = melange_process(handle, 42); - assert_eq!(result, 0); - - melange_free(handle); - } -} -``` - -### From Julia - -```julia -const libmelange = "libmelange" - -function init() - handle = ccall((:melange_init, libmelange), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:melange_process, libmelange), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:melange_free, libmelange), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/melange.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/melange/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/melange/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/melange/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/melange/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/melange/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/melange/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/melange/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/melange/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/melange/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/melange/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/melange/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/melange/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/melange/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/melange/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/melange/README.adoc index d08e1dd2..f68195f2 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/melange/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/melange/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-melange -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-melange-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-melange-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-melange-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-melange-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://github.com/chainguard-dev/melange[Melange]. -**All repos with foreign function interfaces MUST follow this standard:** +APK package builder. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add melange https://github.com/hyperpolymath/asdf-melange-plugin.git +---- -=== Web Projects +melange: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all melange -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install melange latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global melange latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now melange commands are available +melange --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list melange -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local melange -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall melange ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/melange/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/melange/README.md deleted file mode 100644 index 5f6cc5aa..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/melange/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-melange - -[![Build](https://github.com/hyperpolymath/asdf-melange-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-melange-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-melange-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-melange-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Melange](https://github.com/chainguard-dev/melange). - -APK package builder. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add melange https://github.com/hyperpolymath/asdf-melange-plugin.git -``` - -melange: - -```bash -# Show all installable versions -asdf list-all melange - -# Install specific version -asdf install melange latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global melange latest - -# Now melange commands are available -melange --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list melange - -# Set local version for current directory -asdf local melange - -# Uninstall a version -asdf uninstall melange -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/melange/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/melange/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/melange/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/melange/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/melange/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/melange/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/metaiconic/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/metaiconic/ABI-FFI-README.adoc new file mode 100644 index 00000000..f3cd4789 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/metaiconic/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== METAICONIC ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/metaiconic.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libmetaiconic.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +metaiconic/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── metaiconic.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── metaiconic.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/metaiconic.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "metaiconic.h" + +int main() { + void* handle = metaiconic_init(); + if (!handle) return 1; + + int result = metaiconic_process(handle, 42); + if (result != 0) { + const char* err = metaiconic_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + metaiconic_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lmetaiconic -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import METAICONIC.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "metaiconic")] +extern "C" { + fn metaiconic_init() -> *mut std::ffi::c_void; + fn metaiconic_free(handle: *mut std::ffi::c_void); + fn metaiconic_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = metaiconic_init(); + assert!(!handle.is_null()); + + let result = metaiconic_process(handle, 42); + assert_eq!(result, 0); + + metaiconic_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libmetaiconic = "libmetaiconic" + +function init() + handle = ccall((:metaiconic_init, libmetaiconic), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:metaiconic_process, libmetaiconic), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:metaiconic_free, libmetaiconic), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/metaiconic.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/metaiconic/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/metaiconic/ABI-FFI-README.md deleted file mode 100644 index 55307ef9..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/metaiconic/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# METAICONIC ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/metaiconic.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libmetaiconic.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -metaiconic/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── metaiconic.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── metaiconic.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/metaiconic.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "metaiconic.h" - -int main() { - void* handle = metaiconic_init(); - if (!handle) return 1; - - int result = metaiconic_process(handle, 42); - if (result != 0) { - const char* err = metaiconic_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - metaiconic_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lmetaiconic -L./zig-out/lib -``` - -### From Idris2 - -```idris -import METAICONIC.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "metaiconic")] -extern "C" { - fn metaiconic_init() -> *mut std::ffi::c_void; - fn metaiconic_free(handle: *mut std::ffi::c_void); - fn metaiconic_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = metaiconic_init(); - assert!(!handle.is_null()); - - let result = metaiconic_process(handle, 42); - assert_eq!(result, 0); - - metaiconic_free(handle); - } -} -``` - -### From Julia - -```julia -const libmetaiconic = "libmetaiconic" - -function init() - handle = ccall((:metaiconic_init, libmetaiconic), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:metaiconic_process, libmetaiconic), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:metaiconic_free, libmetaiconic), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/metaiconic.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/metaiconic/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/metaiconic/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/metaiconic/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/metaiconic/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/metaiconic/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/metaiconic/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/metaiconic/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/metaiconic/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/metaiconic/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/metaiconic/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/metaiconic/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/metaiconic/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/metaiconic/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/metaiconic/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/metaiconic/README.adoc index b5c0dc4c..6edb4187 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/metaiconic/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/metaiconic/README.adoc @@ -1,114 +1,52 @@ -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] -image:https://img.shields.io/badge/Philosophy-Palimpsest-indigo.svg[Palimpsest,link="https://github.com/hyperpolymath/palimpsest-license"] +== asdf-metaiconic-plugin +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] +image:https://img.shields.io/badge/Philosophy-Palimpsest-indigo.svg[Palimpsest,link="`https://github.com/hyperpolymath/palimpsest-license`"] -// SPDX-License-Identifier: CC-BY-SA-4.0 -= asdf-metaiconic-plugin +Central metadata registry and discovery layer for the +https://asdf-vm.com[asdf] plugin ecosystem. -:toc: macro -:toc-title: Contents -:toclevels: 3 -:icons: font +=== Overview -Unified metadata index and discovery layer for the hyperpolymath asdf plugin ecosystem. +`+asdf-metaiconic-plugin+` serves as the unified metadata index for 65+ +hyperpolymath asdf plugins: -toc::[] +* *Plugin discovery* - Search and browse available plugins +* *Category organization* - Tag-based classification +* *Icon/branding consistency* - SVG icons for all plugins +* *Quality metrics* - CI status aggregation -== Overview +=== Plugin Categories -**asdf-metaiconic-plugin** is the central metadata registry for 68+ asdf plugins in the hyperpolymath ecosystem. It provides: - -* Standardized plugin metadata schema -* Category and tag-based organization -* Plugin discovery and search -* Icon and branding consistency -* Quality metrics aggregation - -== Status - -[cols="1,3"] +[cols=",",options="header",] |=== -| Component | Status - -| Specification -| ✓ link:SPECIFICATION.adoc[Complete] - -| Registry Schema -| ✓ link:registry/plugins.yaml[Implemented] - -| Category Definitions -| ✓ link:registry/categories.yaml[Implemented] - -| Search CLI -| ⏳ Phase 2 - -| Icons -| ⏳ Phase 2 +|Category |Plugins +|Security |trivy, grype, syft, cosign, age, gitleaks, sops +|Databases |mysql, mariadb, cassandra, couchdb, neo4j, arangodb +|Configuration |nickel, dhall, cue, taplo, kdl-fmt +|Static Sites |zola, cobalt, mdbook, franklin, serum, pollen +|Containers |apko, melange, envoy, linkerd |=== -== Quick Start - -[source,bash] ----- -# Search for security plugins -asdf metaiconic search "vulnerability" - -# List all plugins by category -asdf metaiconic list --category security +=== Related Projects -# Get plugin info -asdf metaiconic info trivy ----- - -== Registry Structure - ----- -registry/ -├── plugins.yaml # Master plugin list (68+ entries) -├── categories.yaml # Category definitions (9 categories) -└── schemas/ # Validation schemas ----- - -== Categories - -[cols="1,2"] +[width="100%",cols="40%,60%",options="header",] |=== -| Category | Plugins +|Project |Relationship +|https://github.com/hyperpolymath/asdf-ui-plugin[asdf-ui-plugin] |Visual +consumer -| security | trivy, grype, syft, cosign, gitleaks, age, opa -| database | arangodb, mariadb, neo4j, cassandra, surrealdb -| config | nickel, dhall, cue, yq, taplo, bebop -| network | coredns, envoy, pomerium, linkerd -| crypto | step-ca, cfssl, lego, rekor, fulcio -| build | apko, melange, restic, borg, hashicorp -| language | ada, fortran, affinescript, ocaml, vlang -| ssg | casket-ssg, zola, cobalt, mdbook -| webserver | httpd, varnish, openlitespeed +|https://github.com/hyperpolymath/asdf-security-plugin[asdf-security-plugin] +|Security layer |=== -== Ecosystem Integration - -This plugin is consumed by: - -* **asdf-plugin-configurator** - CLI tool uses registry for search -* **asdf-ui-plugin** - Visual interface uses icons and metadata -* **asdf-control-tower** - Dashboard aggregates plugin status - -See link:ECOSYSTEM.scm[ECOSYSTEM.scm] for full integration map. - -== Infrastructure - -* Multi-forge mirroring (GitHub → GitLab, Codeberg, Bitbucket) -* Instant sync propagation on push/release -* AI assistant configuration (`.claude/CLAUDE.md`) - -== Links +=== License -* link:SPECIFICATION.adoc[Full Specification] -* link:registry/plugins.yaml[Plugin Registry] -* https://github.com/hyperpolymath/asdf-control-tower[Control Tower] -* https://github.com/hyperpolymath/asdf-plugin-configurator[Configurator CLI] +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -== License +''''' -MPL-2.0 +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/metaiconic/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/metaiconic/README.md deleted file mode 100644 index ed9cd4cd..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/metaiconic/README.md +++ /dev/null @@ -1,40 +0,0 @@ -# asdf-metaiconic-plugin - -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] -image:https://img.shields.io/badge/Philosophy-Palimpsest-indigo.svg[Palimpsest,link="https://github.com/hyperpolymath/palimpsest-license"] - -Central metadata registry and discovery layer for the [asdf](https://asdf-vm.com) plugin ecosystem. - -## Overview - -`asdf-metaiconic-plugin` serves as the unified metadata index for 65+ hyperpolymath asdf plugins: - -- **Plugin discovery** - Search and browse available plugins -- **Category organization** - Tag-based classification -- **Icon/branding consistency** - SVG icons for all plugins -- **Quality metrics** - CI status aggregation - -## Plugin Categories - -| Category | Plugins | -|----------|---------| -| Security | trivy, grype, syft, cosign, age, gitleaks, sops | -| Databases | mysql, mariadb, cassandra, couchdb, neo4j, arangodb | -| Configuration | nickel, dhall, cue, taplo, kdl-fmt | -| Static Sites | zola, cobalt, mdbook, franklin, serum, pollen | -| Containers | apko, melange, envoy, linkerd | - -## Related Projects - -| Project | Relationship | -|---------|--------------| -| [asdf-ui-plugin](https://github.com/hyperpolymath/asdf-ui-plugin) | Visual consumer | -| [asdf-security-plugin](https://github.com/hyperpolymath/asdf-security-plugin) | Security layer | - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/metaiconic/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/metaiconic/SECURITY.adoc new file mode 100644 index 00000000..6833c545 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/metaiconic/SECURITY.adoc @@ -0,0 +1,378 @@ +Security Policy + +We take security seriously. We appreciate your efforts to responsibly +disclose vulnerabilities and will make every effort to acknowledge your +contributions. Table of Contents + +.... +Reporting a Vulnerability +What to Include +Response Timeline +Disclosure Policy +Scope +Safe Harbour +Recognition +Security Updates +Security Best Practices +.... + +Reporting a Vulnerability Preferred Method: GitHub Security Advisories + +The preferred method for reporting security vulnerabilities is through +GitHub’s Security Advisory feature: + +.... +Navigate to Report a Vulnerability +Click "Report a vulnerability" +Complete the form with as much detail as possible +Submit — we'll receive a private notification +.... + +This method ensures: + +.... +End-to-end encryption of your report +Private discussion space for collaboration +Coordinated disclosure tooling +Automatic credit when the advisory is published +.... + +Alternative: Encrypted Email + +If you cannot use GitHub Security Advisories, you may email us directly: + +Email security@hyperpolymath.org PGP Key Download Public Key Fingerprint +See GPG key + +== Import our PGP key + +curl -sSL https://hyperpolymath.org/gpg/security.asc | gpg –import + +== Verify fingerprint + +gpg –fingerprint security@hyperpolymath.org + +== Encrypt your report + +gpg –armor –encrypt –recipient security@hyperpolymath.org report.txt + +.... +⚠️ Important: Do not report security vulnerabilities through public GitHub issues, pull requests, discussions, or social media. +.... + +What to Include + +A good vulnerability report helps us understand and reproduce the issue +quickly. Required Information + +.... +Description: Clear explanation of the vulnerability +Impact: What an attacker could achieve (confidentiality, integrity, availability) +Affected versions: Which versions/commits are affected +Reproduction steps: Detailed steps to reproduce the issue +.... + +Helpful Additional Information + +.... +Proof of concept: Code, scripts, or screenshots demonstrating the vulnerability +Attack scenario: Realistic attack scenario showing exploitability +CVSS score: Your assessment of severity (use CVSS 3.1 Calculator) +CWE ID: Common Weakness Enumeration identifier if known +Suggested fix: If you have ideas for remediation +References: Links to related vulnerabilities, research, or advisories +.... + +Example Report Structure + +=== Summary + +{empty}[One-sentence description of the vulnerability] + +=== Vulnerability Type + +{empty}[e.g., SQL Injection, XSS, SSRF, Path Traversal, etc.] + +=== Affected Component + +{empty}[File path, function name, API endpoint, etc.] + +=== Affected Versions + +{empty}[Version range or specific commits] + +=== Severity Assessment + +* CVSS 3.1 Score: [X.X] +* CVSS Vector: [CVSS:3.1/AV:X/AC:X/PR:X/UI:X/S:X/C:X/I:X/A:X] + +=== Description + +{empty}[Detailed technical description] + +=== Steps to Reproduce + +[arabic] +. [First step] +. [Second step] +. […] + +=== Proof of Concept + +{empty}[Code, curl commands, screenshots, etc.] + +=== Impact + +{empty}[What can an attacker achieve?] + +=== Suggested Remediation + +{empty}[Optional: your ideas for fixing] + +=== References + +{empty}[Links to related issues, CVEs, research] + +Response Timeline + +We commit to the following response times: Stage Timeframe Description +Initial Response 48 hours We acknowledge receipt and confirm we’re +investigating Triage 7 days We assess severity, confirm the +vulnerability, and estimate timeline Status Update Every 7 days Regular +updates on remediation progress Resolution 90 days Target for fix +development and release (complex issues may take longer) Disclosure 90 +days Public disclosure after fix is available (coordinated with you) + +.... +Note: These are targets, not guarantees. Complex vulnerabilities may require more time. We'll communicate openly about any delays. +.... + +Disclosure Policy + +We follow coordinated disclosure (also known as responsible disclosure): + +.... +You report the vulnerability privately +We acknowledge and begin investigation +We develop a fix and prepare a release +We coordinate disclosure timing with you +We publish security advisory and fix simultaneously +You may publish your research after disclosure +.... + +Our Commitments + +.... +We will not take legal action against researchers who follow this policy +We will work with you to understand and resolve the issue +We will credit you in the security advisory (unless you prefer anonymity) +We will notify you before public disclosure +We will publish advisories with sufficient detail for users to assess risk +.... + +Your Commitments + +.... +Report vulnerabilities promptly after discovery +Give us reasonable time to address the issue before disclosure +Do not access, modify, or delete data beyond what's necessary to demonstrate the vulnerability +Do not degrade service availability (no DoS testing on production) +Do not share vulnerability details with others until coordinated disclosure +.... + +Disclosure Timeline + +Day 0 You report vulnerability Day 1-2 We acknowledge receipt Day 7 We +confirm vulnerability and share initial assessment Day 7-90 We develop +and test fix Day 90 Coordinated public disclosure (earlier if fix is +ready; later by mutual agreement) + +If we cannot reach agreement on disclosure timing, we default to 90 days +from your initial report. Scope In Scope ✅ + +The following are within scope for security research: + +.... +This repository (hyperpolymath/terrapin-ssg) and all its code +Official releases and packages published from this repository +Documentation that could lead to security issues +Build and deployment configurations in this repository +Dependencies (report here, we'll coordinate with upstream) +.... + +Out of Scope ❌ + +The following are not in scope: + +.... +Third-party services we integrate with (report directly to them) +Social engineering attacks against maintainers +Physical security +Denial of service attacks against production infrastructure +Spam, phishing, or other non-technical attacks +Issues already reported or publicly known +Theoretical vulnerabilities without proof of concept +.... + +Qualifying Vulnerabilities + +We’re particularly interested in: + +.... +Remote code execution +SQL injection, command injection, code injection +Authentication/authorisation bypass +Cross-site scripting (XSS) and cross-site request forgery (CSRF) +Server-side request forgery (SSRF) +Path traversal / local file inclusion +Information disclosure (credentials, PII, secrets) +Cryptographic weaknesses +Deserialisation vulnerabilities +Memory safety issues (buffer overflows, use-after-free, etc.) +Supply chain vulnerabilities (dependency confusion, etc.) +Significant logic flaws +.... + +Non-Qualifying Issues + +The following generally do not qualify as security vulnerabilities: + +.... +Missing security headers on non-sensitive pages +Clickjacking on pages without sensitive actions +Self-XSS (requires victim to paste code) +Missing rate limiting (unless it enables a specific attack) +Username/email enumeration (unless high-risk context) +Missing cookie flags on non-sensitive cookies +Software version disclosure +Verbose error messages (unless exposing secrets) +Best practice deviations without demonstrable impact +.... + +Safe Harbour + +We support security research conducted in good faith. Our Promise + +If you conduct security research in accordance with this policy: + +.... +✅ We will not initiate legal action against you +✅ We will not report your activity to law enforcement +✅ We will work with you in good faith to resolve issues +✅ We consider your research authorised under the Computer Fraud and Abuse Act (CFAA), UK Computer Misuse Act, and similar laws +✅ We waive any potential claim against you for circumvention of security controls +.... + +Good Faith Requirements + +To qualify for safe harbour, you must: + +.... +Comply with this security policy +Report vulnerabilities promptly +Avoid privacy violations (do not access others' data) +Avoid service degradation (no destructive testing) +Not exploit vulnerabilities beyond proof-of-concept +Not use vulnerabilities for profit (beyond bug bounties where offered) + +⚠️ Important: This safe harbour does not extend to third-party systems. Always check their policies before testing. +.... + +Recognition + +We believe in recognising security researchers who help us improve. Hall +of Fame + +Researchers who report valid vulnerabilities will be acknowledged in our +Security Acknowledgments (unless they prefer anonymity). + +Recognition includes: + +.... +Your name (or chosen alias) +Link to your website/profile (optional) +Brief description of the vulnerability class +Date of report +.... + +What We Offer + +.... +✅ Public credit in security advisories +✅ Acknowledgment in release notes +✅ Entry in our Hall of Fame +✅ Reference/recommendation letter upon request (for significant findings) +.... + +What We Don’t Currently Offer + +.... +❌ Monetary bug bounties +❌ Hardware or swag +❌ Paid security research contracts + +Note: We're a community project with limited resources. Your contributions help everyone who uses this software. +.... + +Security Updates Receiving Updates + +To stay informed about security updates: + +.... +Watch this repository: Click "Watch" → "Custom" → Select "Security alerts" +GitHub Security Advisories: Published at Security Advisories +Release notes: Security fixes noted in CHANGELOG +.... + +Update Policy Severity Response Critical/High Patch release as soon as +fix is ready Medium Included in next scheduled release (or earlier) Low +Included in next scheduled release Supported Versions Version Supported +Notes main branch ✅ Yes Latest development Latest release ✅ Yes +Current stable Previous minor release ✅ Yes Security fixes backported +Older versions ❌ No Please upgrade Security Best Practices + +When using terrapin-ssg, we recommend: General + +.... +Keep dependencies up to date +Use the latest stable release +Subscribe to security notifications +Review configuration against security documentation +Follow principle of least privilege +.... + +For Contributors + +.... +Never commit secrets, credentials, or API keys +Use signed commits (git config commit.gpgsign true) +Review dependencies before adding them +Run security linters locally before pushing +Report any concerns about existing code +.... + +Additional Resources + +.... +Our PGP Public Key +Security Advisories +Changelog +Contributing Guidelines +CVE Database +CVSS Calculator +.... + +Contact Purpose Contact Security issues Report via GitHub or +security@hyperpolymath.org General questions GitHub Discussions Other +enquiries See README for contact information Policy Changes + +This security policy may be updated from time to time. Significant +changes will be: + +.... +Committed to this repository with a clear commit message +Noted in the changelog +Announced via GitHub Discussions (for major changes) +.... + +Thank you for helping keep terrapin-ssg and its users safe. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/metaiconic/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/metaiconic/SECURITY.md deleted file mode 100644 index 5eb5e20d..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/metaiconic/SECURITY.md +++ /dev/null @@ -1,328 +0,0 @@ -Security Policy - -We take security seriously. We appreciate your efforts to responsibly disclose vulnerabilities and will make every effort to acknowledge your contributions. -Table of Contents - - Reporting a Vulnerability - What to Include - Response Timeline - Disclosure Policy - Scope - Safe Harbour - Recognition - Security Updates - Security Best Practices - -Reporting a Vulnerability -Preferred Method: GitHub Security Advisories - -The preferred method for reporting security vulnerabilities is through GitHub's Security Advisory feature: - - Navigate to Report a Vulnerability - Click "Report a vulnerability" - Complete the form with as much detail as possible - Submit — we'll receive a private notification - -This method ensures: - - End-to-end encryption of your report - Private discussion space for collaboration - Coordinated disclosure tooling - Automatic credit when the advisory is published - -Alternative: Encrypted Email - -If you cannot use GitHub Security Advisories, you may email us directly: - -Email security@hyperpolymath.org -PGP Key Download Public Key -Fingerprint See GPG key - -# Import our PGP key -curl -sSL https://hyperpolymath.org/gpg/security.asc | gpg --import - -# Verify fingerprint -gpg --fingerprint security@hyperpolymath.org - -# Encrypt your report -gpg --armor --encrypt --recipient security@hyperpolymath.org report.txt - - ⚠️ Important: Do not report security vulnerabilities through public GitHub issues, pull requests, discussions, or social media. - -What to Include - -A good vulnerability report helps us understand and reproduce the issue quickly. -Required Information - - Description: Clear explanation of the vulnerability - Impact: What an attacker could achieve (confidentiality, integrity, availability) - Affected versions: Which versions/commits are affected - Reproduction steps: Detailed steps to reproduce the issue - -Helpful Additional Information - - Proof of concept: Code, scripts, or screenshots demonstrating the vulnerability - Attack scenario: Realistic attack scenario showing exploitability - CVSS score: Your assessment of severity (use CVSS 3.1 Calculator) - CWE ID: Common Weakness Enumeration identifier if known - Suggested fix: If you have ideas for remediation - References: Links to related vulnerabilities, research, or advisories - -Example Report Structure - -## Summary -[One-sentence description of the vulnerability] - -## Vulnerability Type -[e.g., SQL Injection, XSS, SSRF, Path Traversal, etc.] - -## Affected Component -[File path, function name, API endpoint, etc.] - -## Affected Versions -[Version range or specific commits] - -## Severity Assessment -- CVSS 3.1 Score: [X.X] -- CVSS Vector: [CVSS:3.1/AV:X/AC:X/PR:X/UI:X/S:X/C:X/I:X/A:X] - -## Description -[Detailed technical description] - -## Steps to Reproduce -1. [First step] -2. [Second step] -3. [...] - -## Proof of Concept -[Code, curl commands, screenshots, etc.] - -## Impact -[What can an attacker achieve?] - -## Suggested Remediation -[Optional: your ideas for fixing] - -## References -[Links to related issues, CVEs, research] - -Response Timeline - -We commit to the following response times: -Stage Timeframe Description -Initial Response 48 hours We acknowledge receipt and confirm we're investigating -Triage 7 days We assess severity, confirm the vulnerability, and estimate timeline -Status Update Every 7 days Regular updates on remediation progress -Resolution 90 days Target for fix development and release (complex issues may take longer) -Disclosure 90 days Public disclosure after fix is available (coordinated with you) - - Note: These are targets, not guarantees. Complex vulnerabilities may require more time. We'll communicate openly about any delays. - -Disclosure Policy - -We follow coordinated disclosure (also known as responsible disclosure): - - You report the vulnerability privately - We acknowledge and begin investigation - We develop a fix and prepare a release - We coordinate disclosure timing with you - We publish security advisory and fix simultaneously - You may publish your research after disclosure - -Our Commitments - - We will not take legal action against researchers who follow this policy - We will work with you to understand and resolve the issue - We will credit you in the security advisory (unless you prefer anonymity) - We will notify you before public disclosure - We will publish advisories with sufficient detail for users to assess risk - -Your Commitments - - Report vulnerabilities promptly after discovery - Give us reasonable time to address the issue before disclosure - Do not access, modify, or delete data beyond what's necessary to demonstrate the vulnerability - Do not degrade service availability (no DoS testing on production) - Do not share vulnerability details with others until coordinated disclosure - -Disclosure Timeline - -Day 0 You report vulnerability -Day 1-2 We acknowledge receipt -Day 7 We confirm vulnerability and share initial assessment -Day 7-90 We develop and test fix -Day 90 Coordinated public disclosure - (earlier if fix is ready; later by mutual agreement) - -If we cannot reach agreement on disclosure timing, we default to 90 days from your initial report. -Scope -In Scope ✅ - -The following are within scope for security research: - - This repository (hyperpolymath/terrapin-ssg) and all its code - Official releases and packages published from this repository - Documentation that could lead to security issues - Build and deployment configurations in this repository - Dependencies (report here, we'll coordinate with upstream) - -Out of Scope ❌ - -The following are not in scope: - - Third-party services we integrate with (report directly to them) - Social engineering attacks against maintainers - Physical security - Denial of service attacks against production infrastructure - Spam, phishing, or other non-technical attacks - Issues already reported or publicly known - Theoretical vulnerabilities without proof of concept - -Qualifying Vulnerabilities - -We're particularly interested in: - - Remote code execution - SQL injection, command injection, code injection - Authentication/authorisation bypass - Cross-site scripting (XSS) and cross-site request forgery (CSRF) - Server-side request forgery (SSRF) - Path traversal / local file inclusion - Information disclosure (credentials, PII, secrets) - Cryptographic weaknesses - Deserialisation vulnerabilities - Memory safety issues (buffer overflows, use-after-free, etc.) - Supply chain vulnerabilities (dependency confusion, etc.) - Significant logic flaws - -Non-Qualifying Issues - -The following generally do not qualify as security vulnerabilities: - - Missing security headers on non-sensitive pages - Clickjacking on pages without sensitive actions - Self-XSS (requires victim to paste code) - Missing rate limiting (unless it enables a specific attack) - Username/email enumeration (unless high-risk context) - Missing cookie flags on non-sensitive cookies - Software version disclosure - Verbose error messages (unless exposing secrets) - Best practice deviations without demonstrable impact - -Safe Harbour - -We support security research conducted in good faith. -Our Promise - -If you conduct security research in accordance with this policy: - - ✅ We will not initiate legal action against you - ✅ We will not report your activity to law enforcement - ✅ We will work with you in good faith to resolve issues - ✅ We consider your research authorised under the Computer Fraud and Abuse Act (CFAA), UK Computer Misuse Act, and similar laws - ✅ We waive any potential claim against you for circumvention of security controls - -Good Faith Requirements - -To qualify for safe harbour, you must: - - Comply with this security policy - Report vulnerabilities promptly - Avoid privacy violations (do not access others' data) - Avoid service degradation (no destructive testing) - Not exploit vulnerabilities beyond proof-of-concept - Not use vulnerabilities for profit (beyond bug bounties where offered) - - ⚠️ Important: This safe harbour does not extend to third-party systems. Always check their policies before testing. - -Recognition - -We believe in recognising security researchers who help us improve. -Hall of Fame - -Researchers who report valid vulnerabilities will be acknowledged in our Security Acknowledgments (unless they prefer anonymity). - -Recognition includes: - - Your name (or chosen alias) - Link to your website/profile (optional) - Brief description of the vulnerability class - Date of report - -What We Offer - - ✅ Public credit in security advisories - ✅ Acknowledgment in release notes - ✅ Entry in our Hall of Fame - ✅ Reference/recommendation letter upon request (for significant findings) - -What We Don't Currently Offer - - ❌ Monetary bug bounties - ❌ Hardware or swag - ❌ Paid security research contracts - - Note: We're a community project with limited resources. Your contributions help everyone who uses this software. - -Security Updates -Receiving Updates - -To stay informed about security updates: - - Watch this repository: Click "Watch" → "Custom" → Select "Security alerts" - GitHub Security Advisories: Published at Security Advisories - Release notes: Security fixes noted in CHANGELOG - -Update Policy -Severity Response -Critical/High Patch release as soon as fix is ready -Medium Included in next scheduled release (or earlier) -Low Included in next scheduled release -Supported Versions -Version Supported Notes -main branch ✅ Yes Latest development -Latest release ✅ Yes Current stable -Previous minor release ✅ Yes Security fixes backported -Older versions ❌ No Please upgrade -Security Best Practices - -When using terrapin-ssg, we recommend: -General - - Keep dependencies up to date - Use the latest stable release - Subscribe to security notifications - Review configuration against security documentation - Follow principle of least privilege - -For Contributors - - Never commit secrets, credentials, or API keys - Use signed commits (git config commit.gpgsign true) - Review dependencies before adding them - Run security linters locally before pushing - Report any concerns about existing code - -Additional Resources - - Our PGP Public Key - Security Advisories - Changelog - Contributing Guidelines - CVE Database - CVSS Calculator - -Contact -Purpose Contact -Security issues Report via GitHub or security@hyperpolymath.org -General questions GitHub Discussions -Other enquiries See README for contact information -Policy Changes - -This security policy may be updated from time to time. Significant changes will be: - - Committed to this repository with a clear commit message - Noted in the changelog - Announced via GitHub Discussions (for major changes) - -Thank you for helping keep terrapin-ssg and its users safe. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/mysql/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/mysql/ABI-FFI-README.adoc new file mode 100644 index 00000000..3c44c4c3 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/mysql/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== MYSQL ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/mysql.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libmysql.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +mysql/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── mysql.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── mysql.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/mysql.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "mysql.h" + +int main() { + void* handle = mysql_init(); + if (!handle) return 1; + + int result = mysql_process(handle, 42); + if (result != 0) { + const char* err = mysql_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + mysql_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lmysql -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import MYSQL.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "mysql")] +extern "C" { + fn mysql_init() -> *mut std::ffi::c_void; + fn mysql_free(handle: *mut std::ffi::c_void); + fn mysql_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = mysql_init(); + assert!(!handle.is_null()); + + let result = mysql_process(handle, 42); + assert_eq!(result, 0); + + mysql_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libmysql = "libmysql" + +function init() + handle = ccall((:mysql_init, libmysql), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:mysql_process, libmysql), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:mysql_free, libmysql), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/mysql.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/mysql/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/mysql/ABI-FFI-README.md deleted file mode 100644 index 6b5cae94..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/mysql/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# MYSQL ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/mysql.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libmysql.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -mysql/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── mysql.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── mysql.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/mysql.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "mysql.h" - -int main() { - void* handle = mysql_init(); - if (!handle) return 1; - - int result = mysql_process(handle, 42); - if (result != 0) { - const char* err = mysql_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - mysql_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lmysql -L./zig-out/lib -``` - -### From Idris2 - -```idris -import MYSQL.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "mysql")] -extern "C" { - fn mysql_init() -> *mut std::ffi::c_void; - fn mysql_free(handle: *mut std::ffi::c_void); - fn mysql_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = mysql_init(); - assert!(!handle.is_null()); - - let result = mysql_process(handle, 42); - assert_eq!(result, 0); - - mysql_free(handle); - } -} -``` - -### From Julia - -```julia -const libmysql = "libmysql" - -function init() - handle = ccall((:mysql_init, libmysql), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:mysql_process, libmysql), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:mysql_free, libmysql), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/mysql.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/mysql/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/mysql/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/mysql/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/mysql/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/mysql/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/mysql/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/mysql/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/mysql/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/mysql/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/mysql/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/mysql/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/mysql/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/mysql/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/mysql/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/mysql/README.adoc index d08e1dd2..fada33ed 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/mysql/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/mysql/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-mysql -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-mysql-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-mysql-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-mysql-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-mysql-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://www.mysql.com[MySQL]. -**All repos with foreign function interfaces MUST follow this standard:** +Relational database. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add mysql https://github.com/hyperpolymath/asdf-mysql-plugin.git +---- -=== Web Projects +mysql: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all mysql -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install mysql latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global mysql latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now mysql commands are available +mysql --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list mysql -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local mysql -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall mysql ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/mysql/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/mysql/README.md deleted file mode 100644 index b23513f5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/mysql/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-mysql - -[![Build](https://github.com/hyperpolymath/asdf-mysql-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-mysql-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-mysql-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-mysql-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [MySQL](https://www.mysql.com). - -Relational database. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add mysql https://github.com/hyperpolymath/asdf-mysql-plugin.git -``` - -mysql: - -```bash -# Show all installable versions -asdf list-all mysql - -# Install specific version -asdf install mysql latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global mysql latest - -# Now mysql commands are available -mysql --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list mysql - -# Set local version for current directory -asdf local mysql - -# Uninstall a version -asdf uninstall mysql -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/mysql/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/mysql/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/mysql/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/mysql/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/mysql/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/mysql/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/neo4j/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/neo4j/ABI-FFI-README.adoc new file mode 100644 index 00000000..0767166f --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/neo4j/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== NEO4J ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/neo4j.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libneo4j.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +neo4j/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── neo4j.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── neo4j.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/neo4j.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "neo4j.h" + +int main() { + void* handle = neo4j_init(); + if (!handle) return 1; + + int result = neo4j_process(handle, 42); + if (result != 0) { + const char* err = neo4j_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + neo4j_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lneo4j -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import NEO4J.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "neo4j")] +extern "C" { + fn neo4j_init() -> *mut std::ffi::c_void; + fn neo4j_free(handle: *mut std::ffi::c_void); + fn neo4j_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = neo4j_init(); + assert!(!handle.is_null()); + + let result = neo4j_process(handle, 42); + assert_eq!(result, 0); + + neo4j_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libneo4j = "libneo4j" + +function init() + handle = ccall((:neo4j_init, libneo4j), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:neo4j_process, libneo4j), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:neo4j_free, libneo4j), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/neo4j.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/neo4j/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/neo4j/ABI-FFI-README.md deleted file mode 100644 index c5d9ed77..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/neo4j/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# NEO4J ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/neo4j.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libneo4j.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -neo4j/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── neo4j.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── neo4j.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/neo4j.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "neo4j.h" - -int main() { - void* handle = neo4j_init(); - if (!handle) return 1; - - int result = neo4j_process(handle, 42); - if (result != 0) { - const char* err = neo4j_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - neo4j_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lneo4j -L./zig-out/lib -``` - -### From Idris2 - -```idris -import NEO4J.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "neo4j")] -extern "C" { - fn neo4j_init() -> *mut std::ffi::c_void; - fn neo4j_free(handle: *mut std::ffi::c_void); - fn neo4j_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = neo4j_init(); - assert!(!handle.is_null()); - - let result = neo4j_process(handle, 42); - assert_eq!(result, 0); - - neo4j_free(handle); - } -} -``` - -### From Julia - -```julia -const libneo4j = "libneo4j" - -function init() - handle = ccall((:neo4j_init, libneo4j), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:neo4j_process, libneo4j), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:neo4j_free, libneo4j), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/neo4j.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/neo4j/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/neo4j/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/neo4j/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/neo4j/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/neo4j/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/neo4j/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/neo4j/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/neo4j/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/neo4j/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/neo4j/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/neo4j/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/neo4j/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/neo4j/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/neo4j/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/neo4j/README.adoc index d08e1dd2..4963e8ab 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/neo4j/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/neo4j/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-neo4j -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-neo4j-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-neo4j-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-neo4j-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-neo4j-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://neo4j.com[Neo4j]. -**All repos with foreign function interfaces MUST follow this standard:** +Graph database. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add neo4j https://github.com/hyperpolymath/asdf-neo4j-plugin.git +---- -=== Web Projects +neo4j: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all neo4j -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install neo4j latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global neo4j latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now neo4j commands are available +neo4j --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list neo4j -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local neo4j -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall neo4j ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/neo4j/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/neo4j/README.md deleted file mode 100644 index e2d18f20..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/neo4j/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-neo4j - -[![Build](https://github.com/hyperpolymath/asdf-neo4j-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-neo4j-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-neo4j-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-neo4j-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Neo4j](https://neo4j.com). - -Graph database. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add neo4j https://github.com/hyperpolymath/asdf-neo4j-plugin.git -``` - -neo4j: - -```bash -# Show all installable versions -asdf list-all neo4j - -# Install specific version -asdf install neo4j latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global neo4j latest - -# Now neo4j commands are available -neo4j --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list neo4j - -# Set local version for current directory -asdf local neo4j - -# Uninstall a version -asdf uninstall neo4j -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/neo4j/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/neo4j/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/neo4j/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/neo4j/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/neo4j/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/neo4j/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/nickel/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/nickel/ABI-FFI-README.adoc new file mode 100644 index 00000000..785d64d6 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/nickel/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== NICKEL ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/nickel.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libnickel.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +nickel/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── nickel.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── nickel.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/nickel.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "nickel.h" + +int main() { + void* handle = nickel_init(); + if (!handle) return 1; + + int result = nickel_process(handle, 42); + if (result != 0) { + const char* err = nickel_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + nickel_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lnickel -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import NICKEL.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "nickel")] +extern "C" { + fn nickel_init() -> *mut std::ffi::c_void; + fn nickel_free(handle: *mut std::ffi::c_void); + fn nickel_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = nickel_init(); + assert!(!handle.is_null()); + + let result = nickel_process(handle, 42); + assert_eq!(result, 0); + + nickel_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libnickel = "libnickel" + +function init() + handle = ccall((:nickel_init, libnickel), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:nickel_process, libnickel), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:nickel_free, libnickel), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/nickel.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/nickel/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/nickel/ABI-FFI-README.md deleted file mode 100644 index 8b3ac653..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/nickel/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# NICKEL ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/nickel.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libnickel.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -nickel/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── nickel.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── nickel.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/nickel.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "nickel.h" - -int main() { - void* handle = nickel_init(); - if (!handle) return 1; - - int result = nickel_process(handle, 42); - if (result != 0) { - const char* err = nickel_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - nickel_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lnickel -L./zig-out/lib -``` - -### From Idris2 - -```idris -import NICKEL.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "nickel")] -extern "C" { - fn nickel_init() -> *mut std::ffi::c_void; - fn nickel_free(handle: *mut std::ffi::c_void); - fn nickel_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = nickel_init(); - assert!(!handle.is_null()); - - let result = nickel_process(handle, 42); - assert_eq!(result, 0); - - nickel_free(handle); - } -} -``` - -### From Julia - -```julia -const libnickel = "libnickel" - -function init() - handle = ccall((:nickel_init, libnickel), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:nickel_process, libnickel), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:nickel_free, libnickel), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/nickel.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/nickel/CODE_OF_CONDUCT (1).adoc b/asdf-augmenters/asdf-plugin-collection/plugins/nickel/CODE_OF_CONDUCT (1).adoc new file mode 100644 index 00000000..6cc4271e --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/nickel/CODE_OF_CONDUCT (1).adoc @@ -0,0 +1,339 @@ +== Code of Conduct + +=== Our Pledge + +We as members, contributors, and leaders pledge to make participation in +Asdf Tool Plugins a harassment-free experience for everyone, regardless +of age, body size, visible or invisible disability, ethnicity, sex +characteristics, gender identity and expression, level of experience, +education, socio-economic status, nationality, personal appearance, +race, caste, colour, religion, or sexual identity and orientation. + +We pledge to act and interact in ways that contribute to an open, +welcoming, diverse, inclusive, and healthy community. + +We recognise that a thriving open source community requires +*psychological safety* — an environment where people can contribute, ask +questions, make mistakes, and learn without fear of ridicule or +retaliation. + +''''' + +=== Our Standards + +==== Expected Behaviour + +The following behaviours contribute to a positive environment: + +*Communication* - Using welcoming and inclusive language - Being +respectful of differing viewpoints and experiences - Giving and +gracefully accepting constructive feedback - Assuming good intent while +addressing impact - Communicating clearly and patiently, especially with +newcomers + +*Collaboration* - Focusing on what is best for the community - Showing +empathy and kindness toward other community members - Being +collaborative rather than competitive - Mentoring and supporting less +experienced contributors - Celebrating others’ contributions and +successes + +*Professionalism* - Accepting responsibility and apologising to those +affected by our mistakes - Learning from the experience and avoiding +repetition - Respecting others’ time and attention - Staying on topic in +project spaces - Following project guidelines and conventions + +*Accessibility* - Using plain language and avoiding unnecessary jargon - +Providing alt text for images and transcripts for audio/video - Being +patient with those using assistive technologies - Accommodating +different communication styles and needs - Recognising that not everyone +communicates the same way + +==== Unacceptable Behaviour + +The following behaviours are considered harassment and are unacceptable: + +*Harassment* - The use of sexualised language or imagery, and sexual +attention or advances of any kind - Trolling, insulting or derogatory +comments, and personal or political attacks - Public or private +harassment - Deliberate intimidation, stalking, or following (online or +in-person) - Unwelcome physical contact or simulated physical contact +(e.g., emoji) - Sustained disruption of talks, events, or online +discussions + +*Discrimination* - Discriminatory jokes and language - Posting or +threatening to post others’ personally identifying information +("`doxing`") - Advocating for, or encouraging, any of the above +behaviour - Microaggressions — subtle, often unintentional, +discriminatory comments or actions + +*Professional Misconduct* - Publishing others’ private information +without explicit permission - Misrepresenting affiliation or +contributions - Plagiarism or claiming credit for others’ work - +Retaliating against anyone who reports a Code of Conduct violation - +Other conduct which could reasonably be considered inappropriate in a +professional setting + +==== Grey Areas + +Some situations require judgement. When uncertain: + +* *Intent vs Impact*: Good intentions do not excuse harmful impact. +Focus on making things right. +* *Power Dynamics*: Those with more power (maintainers, employers, +experienced contributors) must be especially mindful of their impact. +* *Cultural Differences*: What’s acceptable varies by culture. When in +doubt, err on the side of caution and ask. +* *Humour*: Jokes at others’ expense are rarely funny to everyone. Punch +up, not down. + +''''' + +=== Scope + +This Code of Conduct applies within all community spaces, including: + +*Online Spaces* - Repository discussions, issues, and pull/merge +requests - Project chat channels (Matrix, Discord, Slack, IRC) - Mailing +lists and forums - Social media when representing the project - Video +calls and virtual meetings + +*In-Person Spaces* - Conferences, meetups, and events - Workshops and +training sessions - Any gathering where you represent the project + +*Representation* This Code of Conduct also applies when an individual is +officially representing the community in public spaces. Examples +include: + +* Using an official project email address +* Posting via an official social media account +* Acting as an appointed representative at an event +* Speaking on behalf of the project + +''''' + +=== Enforcement + +==== Reporting + +If you experience or witness unacceptable behaviour, or have any other +concerns, please report it as soon as possible. + +*How to Report* + +[width="99%",cols="30%,33%,37%",options="header",] +|=== +|Method |Details |Best For +|*Email* |j.d.a.jewell@open.ac.uk |Detailed reports, sensitive matters + +|*Private Message* |Contact any maintainer directly |Quick questions, +minor issues + +|*Anonymous Form* |[Link to form if available] |When you need anonymity +|=== + +*What to Include* + +* Your contact information (unless anonymous) +* Names/usernames of those involved +* Description of what happened +* When and where it occurred +* Any witnesses +* Any supporting evidence (screenshots, links) +* How you would like us to respond (if you have a preference) + +*What Happens Next* + +[arabic] +. You will receive acknowledgment within *\{\{RESPONSE_TIME}}* +. The \{\{CONDUCT_TEAM}} will review the report +. We may ask for additional information +. We will determine appropriate action +. We will inform you of the outcome (respecting others’ privacy) + +==== Confidentiality + +All reports will be handled with discretion: + +* Reporter identity is protected by default +* Details are shared only with those who need to know +* We will ask before naming you in any communication +* Anonymous reports are accepted and investigated + +==== Conflicts of Interest + +If a \{\{CONDUCT_TEAM}} member is involved in an incident: + +* They will recuse themselves from the process +* Another maintainer or external party will handle the report +* We will disclose any potential conflicts + +''''' + +=== Enforcement Guidelines + +The \{\{CONDUCT_TEAM}} will follow these guidelines in determining +consequences: + +==== 1. Correction + +*Community Impact*: Use of inappropriate language or other behaviour +deemed unprofessional or unwelcome. + +*Consequence*: A private, written warning providing clarity around the +nature of the violation and an explanation of why the behaviour was +inappropriate. A public apology may be requested. + +*Duration*: Immediate + +==== 2. Warning + +*Community Impact*: A violation through a single incident or series of +actions. + +*Consequence*: A warning with consequences for continued behaviour. No +interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, for a specified period. This +includes avoiding interactions in community spaces as well as external +channels like social media. Violating these terms may lead to a +temporary or permanent ban. + +*Duration*: 1-4 weeks + +==== 3. Temporary Ban + +*Community Impact*: A serious violation of community standards, +including sustained inappropriate behaviour. + +*Consequence*: A temporary ban from any sort of interaction or public +communication with the community for a specified period. No public or +private interaction with the people involved, including unsolicited +interaction with those enforcing the Code of Conduct, is allowed during +this period. Violating these terms may lead to a permanent ban. + +*Duration*: 1-6 months + +==== 4. Permanent Ban + +*Community Impact*: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behaviour, harassment of an +individual, or aggression toward or disparagement of classes of +individuals. + +*Consequence*: A permanent ban from any sort of public interaction +within the community. + +*Duration*: Permanent (with appeal rights after 12 months) + +==== Enforcement Across Perimeters + +For contributors with elevated access (Perimeter 2 or 1): + +[cols=",",options="header",] +|=== +|Level |Additional Consequence +|Correction |Noted in contributor record +|Warning |Access privileges may be temporarily reduced +|Temporary Ban |Access reduced to Perimeter 3 for ban duration +|Permanent Ban |All access revoked +|=== + +''''' + +=== Appeals + +If you believe an enforcement decision was made in error: + +[arabic] +. *Wait 7 days* after the decision (cooling-off period) +. *Email* j.d.a.jewell@open.ac.uk with subject line "`Appeal: [Original +Report ID]`" +. *Explain* why you believe the decision should be reconsidered +. *Provide* any new information not previously available + +*Appeals Process* + +* Appeals are reviewed by a different \{\{CONDUCT_TEAM}} member than the +original +* You will receive a response within 14 days +* The appeals decision is final +* You may only appeal once per incident + +*Grounds for Appeal* + +* Procedural errors in the original investigation +* New evidence not previously available +* Disproportionate response to the violation +* Misunderstanding of facts + +''''' + +=== Supporting Those Who Report + +We are committed to supporting those who report violations: + +*We Will* - Believe and take all reports seriously - Respect your +privacy and confidentiality preferences - Keep you informed of progress +(if you wish) - Take steps to protect you from retaliation - Provide +resources if you need support + +*We Will Not* - Require you to confront the person directly - Dismiss +reports without investigation - Reveal your identity without consent - +Tolerate retaliation against reporters - Rush you to make decisions + +''''' + +=== Prevention + +Beyond enforcement, we actively work to prevent issues: + +*Onboarding* - All contributors are expected to read this Code of +Conduct - Perimeter 2 applicants must confirm they’ve read and +understood it - Maintainers receive additional training on enforcement + +*Culture* - We model the behaviour we expect - We intervene early when +we see potential issues - We thank people for positive contributions - +We create opportunities for diverse voices + +*Review* - This Code of Conduct is reviewed annually - Community +feedback is welcomed - Changes are communicated clearly + +''''' + +=== Acknowledgments + +This Code of Conduct is adapted from: + +* https://www.contributor-covenant.org/[Contributor Covenant], version +2.1 +* https://www.djangoproject.com/conduct/[Django Code of Conduct] +* https://www.rust-lang.org/policies/code-of-conduct[Rust Code of +Conduct] +* https://www.python.org/psf/conduct/[Python Community Code of Conduct] + +We thank these communities for their leadership in creating welcoming +spaces. + +''''' + +=== Questions? + +If you have questions about this Code of Conduct: + +* Open a +https://github.com/hyperpolymath/asdf-tool-plugins/discussions[Discussion] +(for general questions) +* Email j.d.a.jewell@open.ac.uk (for private questions) +* Contact any maintainer directly + +''''' + +=== Summary + +*Be kind. Be respectful. Be collaborative.* + +We’re all here because we care about this project. Let’s make it a place +where everyone can do their best work. + +''''' + +Last updated: 2026 · Based on Contributor Covenant 2.1 diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/nickel/CODE_OF_CONDUCT (1).md b/asdf-augmenters/asdf-plugin-collection/plugins/nickel/CODE_OF_CONDUCT (1).md deleted file mode 100644 index d234420d..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/nickel/CODE_OF_CONDUCT (1).md +++ /dev/null @@ -1,327 +0,0 @@ -# Code of Conduct - - - -## Our Pledge - -We as members, contributors, and leaders pledge to make participation in Asdf Tool Plugins a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, colour, religion, or sexual identity and orientation. - -We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. - -We recognise that a thriving open source community requires **psychological safety** — an environment where people can contribute, ask questions, make mistakes, and learn without fear of ridicule or retaliation. - ---- - -## Our Standards - -### Expected Behaviour - -The following behaviours contribute to a positive environment: - -**Communication** -- Using welcoming and inclusive language -- Being respectful of differing viewpoints and experiences -- Giving and gracefully accepting constructive feedback -- Assuming good intent while addressing impact -- Communicating clearly and patiently, especially with newcomers - -**Collaboration** -- Focusing on what is best for the community -- Showing empathy and kindness toward other community members -- Being collaborative rather than competitive -- Mentoring and supporting less experienced contributors -- Celebrating others' contributions and successes - -**Professionalism** -- Accepting responsibility and apologising to those affected by our mistakes -- Learning from the experience and avoiding repetition -- Respecting others' time and attention -- Staying on topic in project spaces -- Following project guidelines and conventions - -**Accessibility** -- Using plain language and avoiding unnecessary jargon -- Providing alt text for images and transcripts for audio/video -- Being patient with those using assistive technologies -- Accommodating different communication styles and needs -- Recognising that not everyone communicates the same way - -### Unacceptable Behaviour - -The following behaviours are considered harassment and are unacceptable: - -**Harassment** -- The use of sexualised language or imagery, and sexual attention or advances of any kind -- Trolling, insulting or derogatory comments, and personal or political attacks -- Public or private harassment -- Deliberate intimidation, stalking, or following (online or in-person) -- Unwelcome physical contact or simulated physical contact (e.g., emoji) -- Sustained disruption of talks, events, or online discussions - -**Discrimination** -- Discriminatory jokes and language -- Posting or threatening to post others' personally identifying information ("doxing") -- Advocating for, or encouraging, any of the above behaviour -- Microaggressions — subtle, often unintentional, discriminatory comments or actions - -**Professional Misconduct** -- Publishing others' private information without explicit permission -- Misrepresenting affiliation or contributions -- Plagiarism or claiming credit for others' work -- Retaliating against anyone who reports a Code of Conduct violation -- Other conduct which could reasonably be considered inappropriate in a professional setting - -### Grey Areas - -Some situations require judgement. When uncertain: - -- **Intent vs Impact**: Good intentions do not excuse harmful impact. Focus on making things right. -- **Power Dynamics**: Those with more power (maintainers, employers, experienced contributors) must be especially mindful of their impact. -- **Cultural Differences**: What's acceptable varies by culture. When in doubt, err on the side of caution and ask. -- **Humour**: Jokes at others' expense are rarely funny to everyone. Punch up, not down. - ---- - -## Scope - -This Code of Conduct applies within all community spaces, including: - -**Online Spaces** -- Repository discussions, issues, and pull/merge requests -- Project chat channels (Matrix, Discord, Slack, IRC) -- Mailing lists and forums -- Social media when representing the project -- Video calls and virtual meetings - -**In-Person Spaces** -- Conferences, meetups, and events -- Workshops and training sessions -- Any gathering where you represent the project - -**Representation** -This Code of Conduct also applies when an individual is officially representing the community in public spaces. Examples include: - -- Using an official project email address -- Posting via an official social media account -- Acting as an appointed representative at an event -- Speaking on behalf of the project - ---- - -## Enforcement - -### Reporting - -If you experience or witness unacceptable behaviour, or have any other concerns, please report it as soon as possible. - -**How to Report** - -| Method | Details | Best For | -|--------|---------|----------| -| **Email** | j.d.a.jewell@open.ac.uk | Detailed reports, sensitive matters | -| **Private Message** | Contact any maintainer directly | Quick questions, minor issues | -| **Anonymous Form** | [Link to form if available] | When you need anonymity | - -**What to Include** - -- Your contact information (unless anonymous) -- Names/usernames of those involved -- Description of what happened -- When and where it occurred -- Any witnesses -- Any supporting evidence (screenshots, links) -- How you would like us to respond (if you have a preference) - -**What Happens Next** - -1. You will receive acknowledgment within **{{RESPONSE_TIME}}** -2. The {{CONDUCT_TEAM}} will review the report -3. We may ask for additional information -4. We will determine appropriate action -5. We will inform you of the outcome (respecting others' privacy) - -### Confidentiality - -All reports will be handled with discretion: - -- Reporter identity is protected by default -- Details are shared only with those who need to know -- We will ask before naming you in any communication -- Anonymous reports are accepted and investigated - -### Conflicts of Interest - -If a {{CONDUCT_TEAM}} member is involved in an incident: - -- They will recuse themselves from the process -- Another maintainer or external party will handle the report -- We will disclose any potential conflicts - ---- - -## Enforcement Guidelines - -The {{CONDUCT_TEAM}} will follow these guidelines in determining consequences: - -### 1. Correction - -**Community Impact**: Use of inappropriate language or other behaviour deemed unprofessional or unwelcome. - -**Consequence**: A private, written warning providing clarity around the nature of the violation and an explanation of why the behaviour was inappropriate. A public apology may be requested. - -**Duration**: Immediate - -### 2. Warning - -**Community Impact**: A violation through a single incident or series of actions. - -**Consequence**: A warning with consequences for continued behaviour. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. - -**Duration**: 1-4 weeks - -### 3. Temporary Ban - -**Community Impact**: A serious violation of community standards, including sustained inappropriate behaviour. - -**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. - -**Duration**: 1-6 months - -### 4. Permanent Ban - -**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behaviour, harassment of an individual, or aggression toward or disparagement of classes of individuals. - -**Consequence**: A permanent ban from any sort of public interaction within the community. - -**Duration**: Permanent (with appeal rights after 12 months) - -### Enforcement Across Perimeters - -For contributors with elevated access (Perimeter 2 or 1): - -| Level | Additional Consequence | -|-------|----------------------| -| Correction | Noted in contributor record | -| Warning | Access privileges may be temporarily reduced | -| Temporary Ban | Access reduced to Perimeter 3 for ban duration | -| Permanent Ban | All access revoked | - ---- - -## Appeals - -If you believe an enforcement decision was made in error: - -1. **Wait 7 days** after the decision (cooling-off period) -2. **Email** j.d.a.jewell@open.ac.uk with subject line "Appeal: [Original Report ID]" -3. **Explain** why you believe the decision should be reconsidered -4. **Provide** any new information not previously available - -**Appeals Process** - -- Appeals are reviewed by a different {{CONDUCT_TEAM}} member than the original -- You will receive a response within 14 days -- The appeals decision is final -- You may only appeal once per incident - -**Grounds for Appeal** - -- Procedural errors in the original investigation -- New evidence not previously available -- Disproportionate response to the violation -- Misunderstanding of facts - ---- - -## Supporting Those Who Report - -We are committed to supporting those who report violations: - -**We Will** -- Believe and take all reports seriously -- Respect your privacy and confidentiality preferences -- Keep you informed of progress (if you wish) -- Take steps to protect you from retaliation -- Provide resources if you need support - -**We Will Not** -- Require you to confront the person directly -- Dismiss reports without investigation -- Reveal your identity without consent -- Tolerate retaliation against reporters -- Rush you to make decisions - ---- - -## Prevention - -Beyond enforcement, we actively work to prevent issues: - -**Onboarding** -- All contributors are expected to read this Code of Conduct -- Perimeter 2 applicants must confirm they've read and understood it -- Maintainers receive additional training on enforcement - -**Culture** -- We model the behaviour we expect -- We intervene early when we see potential issues -- We thank people for positive contributions -- We create opportunities for diverse voices - -**Review** -- This Code of Conduct is reviewed annually -- Community feedback is welcomed -- Changes are communicated clearly - ---- - -## Acknowledgments - -This Code of Conduct is adapted from: - -- [Contributor Covenant](https://www.contributor-covenant.org/), version 2.1 -- [Django Code of Conduct](https://www.djangoproject.com/conduct/) -- [Rust Code of Conduct](https://www.rust-lang.org/policies/code-of-conduct) -- [Python Community Code of Conduct](https://www.python.org/psf/conduct/) - -We thank these communities for their leadership in creating welcoming spaces. - ---- - -## Questions? - -If you have questions about this Code of Conduct: - -- Open a [Discussion](https://github.com/hyperpolymath/asdf-tool-plugins/discussions) (for general questions) -- Email j.d.a.jewell@open.ac.uk (for private questions) -- Contact any maintainer directly - ---- - -## Summary - -**Be kind. Be respectful. Be collaborative.** - -We're all here because we care about this project. Let's make it a place where everyone can do their best work. - ---- - -Last updated: 2026 · Based on Contributor Covenant 2.1 diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/nickel/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/nickel/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/nickel/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/nickel/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/nickel/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/nickel/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/nickel/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/nickel/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/nickel/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/nickel/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/nickel/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/nickel/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/nickel/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/nickel/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/nickel/README.adoc index d08e1dd2..5c4ae9ec 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/nickel/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/nickel/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-nickel -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-nickel-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-nickel-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-nickel-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-nickel-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://nickel-lang.org[Nickel]. -**All repos with foreign function interfaces MUST follow this standard:** +Configuration language. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add nickel https://github.com/hyperpolymath/asdf-nickel-plugin.git +---- -=== Web Projects +nickel: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all nickel -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install nickel latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global nickel latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now nickel commands are available +nickel --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list nickel -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local nickel -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall nickel ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/nickel/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/nickel/README.md deleted file mode 100644 index e041b947..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/nickel/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-nickel - -[![Build](https://github.com/hyperpolymath/asdf-nickel-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-nickel-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-nickel-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-nickel-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Nickel](https://nickel-lang.org). - -Configuration language. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add nickel https://github.com/hyperpolymath/asdf-nickel-plugin.git -``` - -nickel: - -```bash -# Show all installable versions -asdf list-all nickel - -# Install specific version -asdf install nickel latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global nickel latest - -# Now nickel commands are available -nickel --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list nickel - -# Set local version for current directory -asdf local nickel - -# Uninstall a version -asdf uninstall nickel -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/nickel/SECURITY (1).adoc b/asdf-augmenters/asdf-plugin-collection/plugins/nickel/SECURITY (1).adoc new file mode 100644 index 00000000..a66ca685 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/nickel/SECURITY (1).adoc @@ -0,0 +1,452 @@ +== Security Policy + +We take security seriously. We appreciate your efforts to responsibly +disclose vulnerabilities and will make every effort to acknowledge your +contributions. + +=== Table of Contents + +* link:#reporting-a-vulnerability[Reporting a Vulnerability] +* link:#what-to-include[What to Include] +* link:#response-timeline[Response Timeline] +* link:#disclosure-policy[Disclosure Policy] +* link:#scope[Scope] +* link:#safe-harbour[Safe Harbour] +* link:#recognition[Recognition] +* link:#security-updates[Security Updates] +* link:#security-best-practices[Security Best Practices] + +''''' + +=== Reporting a Vulnerability + +==== Preferred Method: GitHub Security Advisories + +The preferred method for reporting security vulnerabilities is through +GitHub’s Security Advisory feature: + +[arabic] +. Navigate to +https://github.com/hyperpolymath/asdf-tool-plugins/security/advisories/new[Report +a Vulnerability] +. Click *"`Report a vulnerability`"* +. Complete the form with as much detail as possible +. Submit — we’ll receive a private notification + +This method ensures: + +* End-to-end encryption of your report +* Private discussion space for collaboration +* Coordinated disclosure tooling +* Automatic credit when the advisory is published + +==== Alternative: Encrypted Email + +If you cannot use GitHub Security Advisories, you may email us directly: + +[cols=",",] +|=== +|*Email* |6759885+hyperpolymath@users.noreply.github.com +|*PGP Key* |link:%7B%7BPGP_KEY_URL%7D%7D[Download Public Key] +|*Fingerprint* |`+{{PGP_FINGERPRINT}}+` +|=== + +[source,bash] +---- +# Import our PGP key +curl -sSL {{PGP_KEY_URL}} | gpg --import + +# Verify fingerprint +gpg --fingerprint 6759885+hyperpolymath@users.noreply.github.com + +# Encrypt your report +gpg --armor --encrypt --recipient 6759885+hyperpolymath@users.noreply.github.com report.txt +---- + +____ +*⚠️ Important:* Do not report security vulnerabilities through public +GitHub issues, pull requests, discussions, or social media. +____ + +''''' + +=== What to Include + +A good vulnerability report helps us understand and reproduce the issue +quickly. + +==== Required Information + +* *Description*: Clear explanation of the vulnerability +* *Impact*: What an attacker could achieve (confidentiality, integrity, +availability) +* *Affected versions*: Which versions/commits are affected +* *Reproduction steps*: Detailed steps to reproduce the issue + +==== Helpful Additional Information + +* *Proof of concept*: Code, scripts, or screenshots demonstrating the +vulnerability +* *Attack scenario*: Realistic attack scenario showing exploitability +* *CVSS score*: Your assessment of severity (use +https://www.first.org/cvss/calculator/3.1[CVSS 3.1 Calculator]) +* *CWE ID*: Common Weakness Enumeration identifier if known +* *Suggested fix*: If you have ideas for remediation +* *References*: Links to related vulnerabilities, research, or +advisories + +==== Example Report Structure + +[source,markdown] +---- +## Summary +[One-sentence description of the vulnerability] + +## Vulnerability Type +[e.g., SQL Injection, XSS, SSRF, Path Traversal, etc.] + +## Affected Component +[File path, function name, API endpoint, etc.] + +## Affected Versions +[Version range or specific commits] + +## Severity Assessment +- CVSS 3.1 Score: [X.X] +- CVSS Vector: [CVSS:3.1/AV:X/AC:X/PR:X/UI:X/S:X/C:X/I:X/A:X] + +## Description +[Detailed technical description] + +## Steps to Reproduce +1. [First step] +2. [Second step] +3. [...] + +## Proof of Concept +[Code, curl commands, screenshots, etc.] + +## Impact +[What can an attacker achieve?] + +## Suggested Remediation +[Optional: your ideas for fixing] + +## References +[Links to related issues, CVEs, research] +---- + +''''' + +=== Response Timeline + +We commit to the following response times: + +[width="100%",cols="24%,35%,41%",options="header",] +|=== +|Stage |Timeframe |Description +|*Initial Response* |48 hours |We acknowledge receipt and confirm we’re +investigating + +|*Triage* |7 days |We assess severity, confirm the vulnerability, and +estimate timeline + +|*Status Update* |Every 7 days |Regular updates on remediation progress + +|*Resolution* |90 days |Target for fix development and release (complex +issues may take longer) + +|*Disclosure* |90 days |Public disclosure after fix is available +(coordinated with you) +|=== + +____ +*Note:* These are targets, not guarantees. Complex vulnerabilities may +require more time. We’ll communicate openly about any delays. +____ + +''''' + +=== Disclosure Policy + +We follow *coordinated disclosure* (also known as responsible +disclosure): + +[arabic] +. *You report* the vulnerability privately +. *We acknowledge* and begin investigation +. *We develop* a fix and prepare a release +. *We coordinate* disclosure timing with you +. *We publish* security advisory and fix simultaneously +. *You may publish* your research after disclosure + +==== Our Commitments + +* We will not take legal action against researchers who follow this +policy +* We will work with you to understand and resolve the issue +* We will credit you in the security advisory (unless you prefer +anonymity) +* We will notify you before public disclosure +* We will publish advisories with sufficient detail for users to assess +risk + +==== Your Commitments + +* Report vulnerabilities promptly after discovery +* Give us reasonable time to address the issue before disclosure +* Do not access, modify, or delete data beyond what’s necessary to +demonstrate the vulnerability +* Do not degrade service availability (no DoS testing on production) +* Do not share vulnerability details with others until coordinated +disclosure + +==== Disclosure Timeline + +.... +Day 0 You report vulnerability +Day 1-2 We acknowledge receipt +Day 7 We confirm vulnerability and share initial assessment +Day 7-90 We develop and test fix +Day 90 Coordinated public disclosure + (earlier if fix is ready; later by mutual agreement) +.... + +If we cannot reach agreement on disclosure timing, we default to 90 days +from your initial report. + +''''' + +=== Scope + +==== In Scope ✅ + +The following are within scope for security research: + +* This repository (`+hyperpolymath/asdf-tool-plugins+`) and all its code +* Official releases and packages published from this repository +* Documentation that could lead to security issues +* Build and deployment configurations in this repository +* Dependencies (report here, we’ll coordinate with upstream) + +==== Out of Scope ❌ + +The following are *not* in scope: + +* Third-party services we integrate with (report directly to them) +* Social engineering attacks against maintainers +* Physical security +* Denial of service attacks against production infrastructure +* Spam, phishing, or other non-technical attacks +* Issues already reported or publicly known +* Theoretical vulnerabilities without proof of concept + +==== Qualifying Vulnerabilities + +We’re particularly interested in: + +* Remote code execution +* SQL injection, command injection, code injection +* Authentication/authorisation bypass +* Cross-site scripting (XSS) and cross-site request forgery (CSRF) +* Server-side request forgery (SSRF) +* Path traversal / local file inclusion +* Information disclosure (credentials, PII, secrets) +* Cryptographic weaknesses +* Deserialisation vulnerabilities +* Memory safety issues (buffer overflows, use-after-free, etc.) +* Supply chain vulnerabilities (dependency confusion, etc.) +* Significant logic flaws + +==== Non-Qualifying Issues + +The following generally do not qualify as security vulnerabilities: + +* Missing security headers on non-sensitive pages +* Clickjacking on pages without sensitive actions +* Self-XSS (requires victim to paste code) +* Missing rate limiting (unless it enables a specific attack) +* Username/email enumeration (unless high-risk context) +* Missing cookie flags on non-sensitive cookies +* Software version disclosure +* Verbose error messages (unless exposing secrets) +* Best practice deviations without demonstrable impact + +''''' + +=== Safe Harbour + +We support security research conducted in good faith. + +==== Our Promise + +If you conduct security research in accordance with this policy: + +* ✅ We will not initiate legal action against you +* ✅ We will not report your activity to law enforcement +* ✅ We will work with you in good faith to resolve issues +* ✅ We consider your research authorised under the Computer Fraud and +Abuse Act (CFAA), UK Computer Misuse Act, and similar laws +* ✅ We waive any potential claim against you for circumvention of +security controls + +==== Good Faith Requirements + +To qualify for safe harbour, you must: + +* Comply with this security policy +* Report vulnerabilities promptly +* Avoid privacy violations (do not access others’ data) +* Avoid service degradation (no destructive testing) +* Not exploit vulnerabilities beyond proof-of-concept +* Not use vulnerabilities for profit (beyond bug bounties where offered) + +____ +*⚠️ Important:* This safe harbour does not extend to third-party +systems. Always check their policies before testing. +____ + +''''' + +=== Recognition + +We believe in recognising security researchers who help us improve. + +==== Hall of Fame + +Researchers who report valid vulnerabilities will be acknowledged in our +link:SECURITY-ACKNOWLEDGMENTS.md[Security Acknowledgments] (unless they +prefer anonymity). + +Recognition includes: + +* Your name (or chosen alias) +* Link to your website/profile (optional) +* Brief description of the vulnerability class +* Date of report + +==== What We Offer + +* ✅ Public credit in security advisories +* ✅ Acknowledgment in release notes +* ✅ Entry in our Hall of Fame +* ✅ Reference/recommendation letter upon request (for significant +findings) + +==== What We Don’t Currently Offer + +* ❌ Monetary bug bounties +* ❌ Hardware or swag +* ❌ Paid security research contracts + +____ +*Note:* We’re a community project with limited resources. Your +contributions help everyone who uses this software. +____ + +''''' + +=== Security Updates + +==== Receiving Updates + +To stay informed about security updates: + +* *Watch this repository*: Click "`Watch`" → "`Custom`" → Select +"`Security alerts`" +* *GitHub Security Advisories*: Published at +https://github.com/hyperpolymath/asdf-tool-plugins/security/advisories[Security +Advisories] +* *Release notes*: Security fixes noted in link:CHANGELOG.md[CHANGELOG] + +==== Update Policy + +[cols=",",options="header",] +|=== +|Severity |Response +|*Critical/High* |Patch release as soon as fix is ready +|*Medium* |Included in next scheduled release (or earlier) +|*Low* |Included in next scheduled release +|=== + +==== Supported Versions + +[cols=",,",options="header",] +|=== +|Version |Supported |Notes +|`+main+` branch |✅ Yes |Latest development +|Latest release |✅ Yes |Current stable +|Previous minor release |✅ Yes |Security fixes backported +|Older versions |❌ No |Please upgrade +|=== + +''''' + +=== Security Best Practices + +When using Asdf Tool Plugins, we recommend: + +==== General + +* Keep dependencies up to date +* Use the latest stable release +* Subscribe to security notifications +* Review configuration against security documentation +* Follow principle of least privilege + +==== For Contributors + +* Never commit secrets, credentials, or API keys +* Use signed commits (`+git config commit.gpgsign true+`) +* Review dependencies before adding them +* Run security linters locally before pushing +* Report any concerns about existing code + +''''' + +=== Additional Resources + +* link:%7B%7BPGP_KEY_URL%7D%7D[Our PGP Public Key] +* https://github.com/hyperpolymath/asdf-tool-plugins/security/advisories[Security +Advisories] +* link:CHANGELOG.md[Changelog] +* link:CONTRIBUTING.md[Contributing Guidelines] +* https://cve.mitre.org/[CVE Database] +* https://www.first.org/cvss/calculator/3.1[CVSS Calculator] + +''''' + +=== Contact + +[width="100%",cols="50%,50%",options="header",] +|=== +|Purpose |Contact +|*Security issues* +|https://github.com/hyperpolymath/asdf-tool-plugins/security/advisories/new[Report +via GitHub] or 6759885+hyperpolymath@users.noreply.github.com + +|*General questions* +|https://github.com/hyperpolymath/asdf-tool-plugins/discussions[GitHub +Discussions] + +|*Other enquiries* |See link:README.md[README] for contact information +|=== + +''''' + +=== Policy Changes + +This security policy may be updated from time to time. Significant +changes will be: + +* Committed to this repository with a clear commit message +* Noted in the changelog +* Announced via GitHub Discussions (for major changes) + +''''' + +_Thank you for helping keep Asdf Tool Plugins and its users safe._ 🛡️ + +''''' + +Last updated: 2026 · Policy version: 1.0.0 diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/nickel/SECURITY (1).md b/asdf-augmenters/asdf-plugin-collection/plugins/nickel/SECURITY (1).md deleted file mode 100644 index f61f4ad7..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/nickel/SECURITY (1).md +++ /dev/null @@ -1,406 +0,0 @@ -# Security Policy - - - -We take security seriously. We appreciate your efforts to responsibly disclose vulnerabilities and will make every effort to acknowledge your contributions. - -## Table of Contents - -- [Reporting a Vulnerability](#reporting-a-vulnerability) -- [What to Include](#what-to-include) -- [Response Timeline](#response-timeline) -- [Disclosure Policy](#disclosure-policy) -- [Scope](#scope) -- [Safe Harbour](#safe-harbour) -- [Recognition](#recognition) -- [Security Updates](#security-updates) -- [Security Best Practices](#security-best-practices) - ---- - -## Reporting a Vulnerability - -### Preferred Method: GitHub Security Advisories - -The preferred method for reporting security vulnerabilities is through GitHub's Security Advisory feature: - -1. Navigate to [Report a Vulnerability](https://github.com/hyperpolymath/asdf-tool-plugins/security/advisories/new) -2. Click **"Report a vulnerability"** -3. Complete the form with as much detail as possible -4. Submit — we'll receive a private notification - -This method ensures: - -- End-to-end encryption of your report -- Private discussion space for collaboration -- Coordinated disclosure tooling -- Automatic credit when the advisory is published - -### Alternative: Encrypted Email - -If you cannot use GitHub Security Advisories, you may email us directly: - -| | | -|---|---| -| **Email** | 6759885+hyperpolymath@users.noreply.github.com | -| **PGP Key** | [Download Public Key]({{PGP_KEY_URL}}) | -| **Fingerprint** | `{{PGP_FINGERPRINT}}` | - -```bash -# Import our PGP key -curl -sSL {{PGP_KEY_URL}} | gpg --import - -# Verify fingerprint -gpg --fingerprint 6759885+hyperpolymath@users.noreply.github.com - -# Encrypt your report -gpg --armor --encrypt --recipient 6759885+hyperpolymath@users.noreply.github.com report.txt -``` - -> **⚠️ Important:** Do not report security vulnerabilities through public GitHub issues, pull requests, discussions, or social media. - ---- - -## What to Include - -A good vulnerability report helps us understand and reproduce the issue quickly. - -### Required Information - -- **Description**: Clear explanation of the vulnerability -- **Impact**: What an attacker could achieve (confidentiality, integrity, availability) -- **Affected versions**: Which versions/commits are affected -- **Reproduction steps**: Detailed steps to reproduce the issue - -### Helpful Additional Information - -- **Proof of concept**: Code, scripts, or screenshots demonstrating the vulnerability -- **Attack scenario**: Realistic attack scenario showing exploitability -- **CVSS score**: Your assessment of severity (use [CVSS 3.1 Calculator](https://www.first.org/cvss/calculator/3.1)) -- **CWE ID**: Common Weakness Enumeration identifier if known -- **Suggested fix**: If you have ideas for remediation -- **References**: Links to related vulnerabilities, research, or advisories - -### Example Report Structure - -```markdown -## Summary -[One-sentence description of the vulnerability] - -## Vulnerability Type -[e.g., SQL Injection, XSS, SSRF, Path Traversal, etc.] - -## Affected Component -[File path, function name, API endpoint, etc.] - -## Affected Versions -[Version range or specific commits] - -## Severity Assessment -- CVSS 3.1 Score: [X.X] -- CVSS Vector: [CVSS:3.1/AV:X/AC:X/PR:X/UI:X/S:X/C:X/I:X/A:X] - -## Description -[Detailed technical description] - -## Steps to Reproduce -1. [First step] -2. [Second step] -3. [...] - -## Proof of Concept -[Code, curl commands, screenshots, etc.] - -## Impact -[What can an attacker achieve?] - -## Suggested Remediation -[Optional: your ideas for fixing] - -## References -[Links to related issues, CVEs, research] -``` - ---- - -## Response Timeline - -We commit to the following response times: - -| Stage | Timeframe | Description | -|-------|-----------|-------------| -| **Initial Response** | 48 hours | We acknowledge receipt and confirm we're investigating | -| **Triage** | 7 days | We assess severity, confirm the vulnerability, and estimate timeline | -| **Status Update** | Every 7 days | Regular updates on remediation progress | -| **Resolution** | 90 days | Target for fix development and release (complex issues may take longer) | -| **Disclosure** | 90 days | Public disclosure after fix is available (coordinated with you) | - -> **Note:** These are targets, not guarantees. Complex vulnerabilities may require more time. We'll communicate openly about any delays. - ---- - -## Disclosure Policy - -We follow **coordinated disclosure** (also known as responsible disclosure): - -1. **You report** the vulnerability privately -2. **We acknowledge** and begin investigation -3. **We develop** a fix and prepare a release -4. **We coordinate** disclosure timing with you -5. **We publish** security advisory and fix simultaneously -6. **You may publish** your research after disclosure - -### Our Commitments - -- We will not take legal action against researchers who follow this policy -- We will work with you to understand and resolve the issue -- We will credit you in the security advisory (unless you prefer anonymity) -- We will notify you before public disclosure -- We will publish advisories with sufficient detail for users to assess risk - -### Your Commitments - -- Report vulnerabilities promptly after discovery -- Give us reasonable time to address the issue before disclosure -- Do not access, modify, or delete data beyond what's necessary to demonstrate the vulnerability -- Do not degrade service availability (no DoS testing on production) -- Do not share vulnerability details with others until coordinated disclosure - -### Disclosure Timeline - -``` -Day 0 You report vulnerability -Day 1-2 We acknowledge receipt -Day 7 We confirm vulnerability and share initial assessment -Day 7-90 We develop and test fix -Day 90 Coordinated public disclosure - (earlier if fix is ready; later by mutual agreement) -``` - -If we cannot reach agreement on disclosure timing, we default to 90 days from your initial report. - ---- - -## Scope - -### In Scope ✅ - -The following are within scope for security research: - -- This repository (`hyperpolymath/asdf-tool-plugins`) and all its code -- Official releases and packages published from this repository -- Documentation that could lead to security issues -- Build and deployment configurations in this repository -- Dependencies (report here, we'll coordinate with upstream) - -### Out of Scope ❌ - -The following are **not** in scope: - -- Third-party services we integrate with (report directly to them) -- Social engineering attacks against maintainers -- Physical security -- Denial of service attacks against production infrastructure -- Spam, phishing, or other non-technical attacks -- Issues already reported or publicly known -- Theoretical vulnerabilities without proof of concept - -### Qualifying Vulnerabilities - -We're particularly interested in: - -- Remote code execution -- SQL injection, command injection, code injection -- Authentication/authorisation bypass -- Cross-site scripting (XSS) and cross-site request forgery (CSRF) -- Server-side request forgery (SSRF) -- Path traversal / local file inclusion -- Information disclosure (credentials, PII, secrets) -- Cryptographic weaknesses -- Deserialisation vulnerabilities -- Memory safety issues (buffer overflows, use-after-free, etc.) -- Supply chain vulnerabilities (dependency confusion, etc.) -- Significant logic flaws - -### Non-Qualifying Issues - -The following generally do not qualify as security vulnerabilities: - -- Missing security headers on non-sensitive pages -- Clickjacking on pages without sensitive actions -- Self-XSS (requires victim to paste code) -- Missing rate limiting (unless it enables a specific attack) -- Username/email enumeration (unless high-risk context) -- Missing cookie flags on non-sensitive cookies -- Software version disclosure -- Verbose error messages (unless exposing secrets) -- Best practice deviations without demonstrable impact - ---- - -## Safe Harbour - -We support security research conducted in good faith. - -### Our Promise - -If you conduct security research in accordance with this policy: - -- ✅ We will not initiate legal action against you -- ✅ We will not report your activity to law enforcement -- ✅ We will work with you in good faith to resolve issues -- ✅ We consider your research authorised under the Computer Fraud and Abuse Act (CFAA), UK Computer Misuse Act, and similar laws -- ✅ We waive any potential claim against you for circumvention of security controls - -### Good Faith Requirements - -To qualify for safe harbour, you must: - -- Comply with this security policy -- Report vulnerabilities promptly -- Avoid privacy violations (do not access others' data) -- Avoid service degradation (no destructive testing) -- Not exploit vulnerabilities beyond proof-of-concept -- Not use vulnerabilities for profit (beyond bug bounties where offered) - -> **⚠️ Important:** This safe harbour does not extend to third-party systems. Always check their policies before testing. - ---- - -## Recognition - -We believe in recognising security researchers who help us improve. - -### Hall of Fame - -Researchers who report valid vulnerabilities will be acknowledged in our [Security Acknowledgments](SECURITY-ACKNOWLEDGMENTS.md) (unless they prefer anonymity). - -Recognition includes: - -- Your name (or chosen alias) -- Link to your website/profile (optional) -- Brief description of the vulnerability class -- Date of report - -### What We Offer - -- ✅ Public credit in security advisories -- ✅ Acknowledgment in release notes -- ✅ Entry in our Hall of Fame -- ✅ Reference/recommendation letter upon request (for significant findings) - -### What We Don't Currently Offer - -- ❌ Monetary bug bounties -- ❌ Hardware or swag -- ❌ Paid security research contracts - -> **Note:** We're a community project with limited resources. Your contributions help everyone who uses this software. - ---- - -## Security Updates - -### Receiving Updates - -To stay informed about security updates: - -- **Watch this repository**: Click "Watch" → "Custom" → Select "Security alerts" -- **GitHub Security Advisories**: Published at [Security Advisories](https://github.com/hyperpolymath/asdf-tool-plugins/security/advisories) -- **Release notes**: Security fixes noted in [CHANGELOG](CHANGELOG.md) - -### Update Policy - -| Severity | Response | -|----------|----------| -| **Critical/High** | Patch release as soon as fix is ready | -| **Medium** | Included in next scheduled release (or earlier) | -| **Low** | Included in next scheduled release | - -### Supported Versions - - - -| Version | Supported | Notes | -|---------|-----------|-------| -| `main` branch | ✅ Yes | Latest development | -| Latest release | ✅ Yes | Current stable | -| Previous minor release | ✅ Yes | Security fixes backported | -| Older versions | ❌ No | Please upgrade | - ---- - -## Security Best Practices - -When using Asdf Tool Plugins, we recommend: - -### General - -- Keep dependencies up to date -- Use the latest stable release -- Subscribe to security notifications -- Review configuration against security documentation -- Follow principle of least privilege - -### For Contributors - -- Never commit secrets, credentials, or API keys -- Use signed commits (`git config commit.gpgsign true`) -- Review dependencies before adding them -- Run security linters locally before pushing -- Report any concerns about existing code - ---- - -## Additional Resources - -- [Our PGP Public Key]({{PGP_KEY_URL}}) -- [Security Advisories](https://github.com/hyperpolymath/asdf-tool-plugins/security/advisories) -- [Changelog](CHANGELOG.md) -- [Contributing Guidelines](CONTRIBUTING.md) -- [CVE Database](https://cve.mitre.org/) -- [CVSS Calculator](https://www.first.org/cvss/calculator/3.1) - ---- - -## Contact - -| Purpose | Contact | -|---------|---------| -| **Security issues** | [Report via GitHub](https://github.com/hyperpolymath/asdf-tool-plugins/security/advisories/new) or 6759885+hyperpolymath@users.noreply.github.com | -| **General questions** | [GitHub Discussions](https://github.com/hyperpolymath/asdf-tool-plugins/discussions) | -| **Other enquiries** | See [README](README.md) for contact information | - ---- - -## Policy Changes - -This security policy may be updated from time to time. Significant changes will be: - -- Committed to this repository with a clear commit message -- Noted in the changelog -- Announced via GitHub Discussions (for major changes) - ---- - -*Thank you for helping keep Asdf Tool Plugins and its users safe.* 🛡️ - ---- - -Last updated: 2026 · Policy version: 1.0.0 diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/nickel/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/nickel/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/nickel/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/nickel/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/nickel/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/nickel/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/ocaml/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/ocaml/ABI-FFI-README.adoc new file mode 100644 index 00000000..ab805e19 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/ocaml/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== OCAML ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/ocaml.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libocaml.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +ocaml/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── ocaml.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── ocaml.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/ocaml.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "ocaml.h" + +int main() { + void* handle = ocaml_init(); + if (!handle) return 1; + + int result = ocaml_process(handle, 42); + if (result != 0) { + const char* err = ocaml_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + ocaml_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -locaml -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import OCAML.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "ocaml")] +extern "C" { + fn ocaml_init() -> *mut std::ffi::c_void; + fn ocaml_free(handle: *mut std::ffi::c_void); + fn ocaml_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = ocaml_init(); + assert!(!handle.is_null()); + + let result = ocaml_process(handle, 42); + assert_eq!(result, 0); + + ocaml_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libocaml = "libocaml" + +function init() + handle = ccall((:ocaml_init, libocaml), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:ocaml_process, libocaml), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:ocaml_free, libocaml), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/ocaml.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/ocaml/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/ocaml/ABI-FFI-README.md deleted file mode 100644 index 50d6c260..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/ocaml/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# OCAML ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/ocaml.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libocaml.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -ocaml/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── ocaml.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── ocaml.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/ocaml.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "ocaml.h" - -int main() { - void* handle = ocaml_init(); - if (!handle) return 1; - - int result = ocaml_process(handle, 42); - if (result != 0) { - const char* err = ocaml_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - ocaml_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -locaml -L./zig-out/lib -``` - -### From Idris2 - -```idris -import OCAML.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "ocaml")] -extern "C" { - fn ocaml_init() -> *mut std::ffi::c_void; - fn ocaml_free(handle: *mut std::ffi::c_void); - fn ocaml_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = ocaml_init(); - assert!(!handle.is_null()); - - let result = ocaml_process(handle, 42); - assert_eq!(result, 0); - - ocaml_free(handle); - } -} -``` - -### From Julia - -```julia -const libocaml = "libocaml" - -function init() - handle = ccall((:ocaml_init, libocaml), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:ocaml_process, libocaml), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:ocaml_free, libocaml), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/ocaml.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/ocaml/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/ocaml/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/ocaml/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/ocaml/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/ocaml/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/ocaml/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/ocaml/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/ocaml/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/ocaml/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/ocaml/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/ocaml/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/ocaml/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/ocaml/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/ocaml/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/ocaml/README.adoc index d08e1dd2..434b0833 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/ocaml/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/ocaml/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-ocaml -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-ocaml-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-ocaml-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-ocaml-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-ocaml-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://ocaml.org[OCaml]. -**All repos with foreign function interfaces MUST follow this standard:** +Functional programming language. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add ocaml https://github.com/hyperpolymath/asdf-ocaml-plugin.git +---- -=== Web Projects +ocaml: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all ocaml -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install ocaml latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global ocaml latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now ocaml commands are available +ocaml --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list ocaml -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local ocaml -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall ocaml ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/ocaml/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/ocaml/README.md deleted file mode 100644 index 5ad2c9bd..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/ocaml/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-ocaml - -[![Build](https://github.com/hyperpolymath/asdf-ocaml-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-ocaml-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-ocaml-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-ocaml-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [OCaml](https://ocaml.org). - -Functional programming language. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add ocaml https://github.com/hyperpolymath/asdf-ocaml-plugin.git -``` - -ocaml: - -```bash -# Show all installable versions -asdf list-all ocaml - -# Install specific version -asdf install ocaml latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global ocaml latest - -# Now ocaml commands are available -ocaml --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list ocaml - -# Set local version for current directory -asdf local ocaml - -# Uninstall a version -asdf uninstall ocaml -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/ocaml/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/ocaml/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/ocaml/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/ocaml/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/ocaml/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/ocaml/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/opa/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/opa/ABI-FFI-README.adoc new file mode 100644 index 00000000..b78e8453 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/opa/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== OPA ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/opa.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libopa.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +opa/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── opa.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── opa.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/opa.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "opa.h" + +int main() { + void* handle = opa_init(); + if (!handle) return 1; + + int result = opa_process(handle, 42); + if (result != 0) { + const char* err = opa_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + opa_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lopa -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import OPA.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "opa")] +extern "C" { + fn opa_init() -> *mut std::ffi::c_void; + fn opa_free(handle: *mut std::ffi::c_void); + fn opa_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = opa_init(); + assert!(!handle.is_null()); + + let result = opa_process(handle, 42); + assert_eq!(result, 0); + + opa_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libopa = "libopa" + +function init() + handle = ccall((:opa_init, libopa), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:opa_process, libopa), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:opa_free, libopa), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/opa.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/opa/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/opa/ABI-FFI-README.md deleted file mode 100644 index 0bafe4a2..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/opa/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# OPA ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/opa.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libopa.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -opa/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── opa.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── opa.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/opa.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "opa.h" - -int main() { - void* handle = opa_init(); - if (!handle) return 1; - - int result = opa_process(handle, 42); - if (result != 0) { - const char* err = opa_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - opa_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lopa -L./zig-out/lib -``` - -### From Idris2 - -```idris -import OPA.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "opa")] -extern "C" { - fn opa_init() -> *mut std::ffi::c_void; - fn opa_free(handle: *mut std::ffi::c_void); - fn opa_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = opa_init(); - assert!(!handle.is_null()); - - let result = opa_process(handle, 42); - assert_eq!(result, 0); - - opa_free(handle); - } -} -``` - -### From Julia - -```julia -const libopa = "libopa" - -function init() - handle = ccall((:opa_init, libopa), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:opa_process, libopa), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:opa_free, libopa), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/opa.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/opa/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/opa/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/opa/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/opa/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/opa/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/opa/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/opa/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/opa/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/opa/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/opa/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/opa/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/opa/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/opa/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/opa/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/opa/README.adoc index d08e1dd2..1c1f19b4 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/opa/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/opa/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-opa -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-opa-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-opa-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-opa-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-opa-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://www.openpolicyagent.org[Open Policy Agent]. -**All repos with foreign function interfaces MUST follow this standard:** +Policy engine. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add opa https://github.com/hyperpolymath/asdf-opa-plugin.git +---- -=== Web Projects +opa: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all opa -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install opa latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global opa latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now opa commands are available +opa --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list opa -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local opa -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall opa ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/opa/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/opa/README.md deleted file mode 100644 index de54dba8..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/opa/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-opa - -[![Build](https://github.com/hyperpolymath/asdf-opa-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-opa-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-opa-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-opa-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Open Policy Agent](https://www.openpolicyagent.org). - -Policy engine. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add opa https://github.com/hyperpolymath/asdf-opa-plugin.git -``` - -opa: - -```bash -# Show all installable versions -asdf list-all opa - -# Install specific version -asdf install opa latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global opa latest - -# Now opa commands are available -opa --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list opa - -# Set local version for current directory -asdf local opa - -# Uninstall a version -asdf uninstall opa -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/opa/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/opa/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/opa/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/opa/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/opa/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/opa/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/openlitespeed/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/openlitespeed/ABI-FFI-README.adoc new file mode 100644 index 00000000..43898c94 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/openlitespeed/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== OPENLITESPEED ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/openlitespeed.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libopenlitespeed.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +openlitespeed/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── openlitespeed.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── openlitespeed.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/openlitespeed.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "openlitespeed.h" + +int main() { + void* handle = openlitespeed_init(); + if (!handle) return 1; + + int result = openlitespeed_process(handle, 42); + if (result != 0) { + const char* err = openlitespeed_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + openlitespeed_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lopenlitespeed -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import OPENLITESPEED.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "openlitespeed")] +extern "C" { + fn openlitespeed_init() -> *mut std::ffi::c_void; + fn openlitespeed_free(handle: *mut std::ffi::c_void); + fn openlitespeed_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = openlitespeed_init(); + assert!(!handle.is_null()); + + let result = openlitespeed_process(handle, 42); + assert_eq!(result, 0); + + openlitespeed_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libopenlitespeed = "libopenlitespeed" + +function init() + handle = ccall((:openlitespeed_init, libopenlitespeed), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:openlitespeed_process, libopenlitespeed), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:openlitespeed_free, libopenlitespeed), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/openlitespeed.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/openlitespeed/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/openlitespeed/ABI-FFI-README.md deleted file mode 100644 index c3f2c832..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/openlitespeed/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# OPENLITESPEED ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/openlitespeed.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libopenlitespeed.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -openlitespeed/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── openlitespeed.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── openlitespeed.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/openlitespeed.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "openlitespeed.h" - -int main() { - void* handle = openlitespeed_init(); - if (!handle) return 1; - - int result = openlitespeed_process(handle, 42); - if (result != 0) { - const char* err = openlitespeed_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - openlitespeed_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lopenlitespeed -L./zig-out/lib -``` - -### From Idris2 - -```idris -import OPENLITESPEED.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "openlitespeed")] -extern "C" { - fn openlitespeed_init() -> *mut std::ffi::c_void; - fn openlitespeed_free(handle: *mut std::ffi::c_void); - fn openlitespeed_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = openlitespeed_init(); - assert!(!handle.is_null()); - - let result = openlitespeed_process(handle, 42); - assert_eq!(result, 0); - - openlitespeed_free(handle); - } -} -``` - -### From Julia - -```julia -const libopenlitespeed = "libopenlitespeed" - -function init() - handle = ccall((:openlitespeed_init, libopenlitespeed), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:openlitespeed_process, libopenlitespeed), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:openlitespeed_free, libopenlitespeed), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/openlitespeed.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/openlitespeed/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/openlitespeed/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/openlitespeed/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/openlitespeed/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/openlitespeed/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/openlitespeed/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/openlitespeed/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/openlitespeed/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/openlitespeed/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/openlitespeed/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/openlitespeed/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/openlitespeed/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/openlitespeed/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/openlitespeed/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/openlitespeed/README.adoc index d08e1dd2..4ec2b20f 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/openlitespeed/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/openlitespeed/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-openlitespeed -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-openlitespeed-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-openlitespeed-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-openlitespeed-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-openlitespeed-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://openlitespeed.org[OpenLiteSpeed]. -**All repos with foreign function interfaces MUST follow this standard:** +High-performance web server. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add openlitespeed https://github.com/hyperpolymath/asdf-openlitespeed-plugin.git +---- -=== Web Projects +openlitespeed: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all openlitespeed -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install openlitespeed latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global openlitespeed latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now openlitespeed commands are available +openlitespeed --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list openlitespeed -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local openlitespeed -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall openlitespeed ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/openlitespeed/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/openlitespeed/README.md deleted file mode 100644 index 967acbf5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/openlitespeed/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-openlitespeed - -[![Build](https://github.com/hyperpolymath/asdf-openlitespeed-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-openlitespeed-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-openlitespeed-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-openlitespeed-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [OpenLiteSpeed](https://openlitespeed.org). - -High-performance web server. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add openlitespeed https://github.com/hyperpolymath/asdf-openlitespeed-plugin.git -``` - -openlitespeed: - -```bash -# Show all installable versions -asdf list-all openlitespeed - -# Install specific version -asdf install openlitespeed latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global openlitespeed latest - -# Now openlitespeed commands are available -openlitespeed --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list openlitespeed - -# Set local version for current directory -asdf local openlitespeed - -# Uninstall a version -asdf uninstall openlitespeed -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/openlitespeed/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/openlitespeed/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/openlitespeed/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/openlitespeed/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/openlitespeed/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/openlitespeed/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/openssh/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/openssh/ABI-FFI-README.adoc new file mode 100644 index 00000000..36317683 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/openssh/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== OPENSSH ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/openssh.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libopenssh.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +openssh/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── openssh.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── openssh.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/openssh.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "openssh.h" + +int main() { + void* handle = openssh_init(); + if (!handle) return 1; + + int result = openssh_process(handle, 42); + if (result != 0) { + const char* err = openssh_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + openssh_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lopenssh -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import OPENSSH.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "openssh")] +extern "C" { + fn openssh_init() -> *mut std::ffi::c_void; + fn openssh_free(handle: *mut std::ffi::c_void); + fn openssh_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = openssh_init(); + assert!(!handle.is_null()); + + let result = openssh_process(handle, 42); + assert_eq!(result, 0); + + openssh_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libopenssh = "libopenssh" + +function init() + handle = ccall((:openssh_init, libopenssh), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:openssh_process, libopenssh), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:openssh_free, libopenssh), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/openssh.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/openssh/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/openssh/ABI-FFI-README.md deleted file mode 100644 index e6a77f77..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/openssh/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# OPENSSH ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/openssh.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libopenssh.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -openssh/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── openssh.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── openssh.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/openssh.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "openssh.h" - -int main() { - void* handle = openssh_init(); - if (!handle) return 1; - - int result = openssh_process(handle, 42); - if (result != 0) { - const char* err = openssh_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - openssh_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lopenssh -L./zig-out/lib -``` - -### From Idris2 - -```idris -import OPENSSH.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "openssh")] -extern "C" { - fn openssh_init() -> *mut std::ffi::c_void; - fn openssh_free(handle: *mut std::ffi::c_void); - fn openssh_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = openssh_init(); - assert!(!handle.is_null()); - - let result = openssh_process(handle, 42); - assert_eq!(result, 0); - - openssh_free(handle); - } -} -``` - -### From Julia - -```julia -const libopenssh = "libopenssh" - -function init() - handle = ccall((:openssh_init, libopenssh), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:openssh_process, libopenssh), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:openssh_free, libopenssh), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/openssh.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/openssh/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/openssh/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/openssh/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/openssh/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/openssh/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/openssh/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/openssh/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/openssh/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/openssh/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/openssh/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/openssh/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/openssh/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/openssh/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/openssh/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/openssh/README.adoc index d08e1dd2..6b5d8461 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/openssh/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/openssh/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-openssh -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-openssh-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-openssh-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-openssh-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-openssh-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://www.openssh.com[OpenSSH]. -**All repos with foreign function interfaces MUST follow this standard:** +SSH connectivity tools. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add openssh https://github.com/hyperpolymath/asdf-openssh-plugin.git +---- -=== Web Projects +openssh: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all openssh -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install openssh latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global openssh latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now openssh commands are available +openssh --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list openssh -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local openssh -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall openssh ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/openssh/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/openssh/README.md deleted file mode 100644 index 0d151fcd..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/openssh/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-openssh - -[![Build](https://github.com/hyperpolymath/asdf-openssh-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-openssh-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-openssh-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-openssh-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [OpenSSH](https://www.openssh.com). - -SSH connectivity tools. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add openssh https://github.com/hyperpolymath/asdf-openssh-plugin.git -``` - -openssh: - -```bash -# Show all installable versions -asdf list-all openssh - -# Install specific version -asdf install openssh latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global openssh latest - -# Now openssh commands are available -openssh --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list openssh - -# Set local version for current directory -asdf local openssh - -# Uninstall a version -asdf uninstall openssh -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/openssh/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/openssh/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/openssh/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/openssh/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/openssh/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/openssh/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/openssl/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/openssl/ABI-FFI-README.adoc new file mode 100644 index 00000000..279d3f42 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/openssl/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== OPENSSL ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/openssl.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libopenssl.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +openssl/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── openssl.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── openssl.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/openssl.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "openssl.h" + +int main() { + void* handle = openssl_init(); + if (!handle) return 1; + + int result = openssl_process(handle, 42); + if (result != 0) { + const char* err = openssl_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + openssl_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lopenssl -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import OPENSSL.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "openssl")] +extern "C" { + fn openssl_init() -> *mut std::ffi::c_void; + fn openssl_free(handle: *mut std::ffi::c_void); + fn openssl_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = openssl_init(); + assert!(!handle.is_null()); + + let result = openssl_process(handle, 42); + assert_eq!(result, 0); + + openssl_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libopenssl = "libopenssl" + +function init() + handle = ccall((:openssl_init, libopenssl), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:openssl_process, libopenssl), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:openssl_free, libopenssl), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/openssl.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/openssl/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/openssl/ABI-FFI-README.md deleted file mode 100644 index a541fd49..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/openssl/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# OPENSSL ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/openssl.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libopenssl.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -openssl/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── openssl.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── openssl.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/openssl.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "openssl.h" - -int main() { - void* handle = openssl_init(); - if (!handle) return 1; - - int result = openssl_process(handle, 42); - if (result != 0) { - const char* err = openssl_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - openssl_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lopenssl -L./zig-out/lib -``` - -### From Idris2 - -```idris -import OPENSSL.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "openssl")] -extern "C" { - fn openssl_init() -> *mut std::ffi::c_void; - fn openssl_free(handle: *mut std::ffi::c_void); - fn openssl_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = openssl_init(); - assert!(!handle.is_null()); - - let result = openssl_process(handle, 42); - assert_eq!(result, 0); - - openssl_free(handle); - } -} -``` - -### From Julia - -```julia -const libopenssl = "libopenssl" - -function init() - handle = ccall((:openssl_init, libopenssl), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:openssl_process, libopenssl), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:openssl_free, libopenssl), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/openssl.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/openssl/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/openssl/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/openssl/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/openssl/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/openssl/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/openssl/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/openssl/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/openssl/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/openssl/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/openssl/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/openssl/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/openssl/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/openssl/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/openssl/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/openssl/README.adoc index d08e1dd2..b121263d 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/openssl/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/openssl/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-openssl -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-openssl-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-openssl-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-openssl-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-openssl-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://www.openssl.org[OpenSSL]. -**All repos with foreign function interfaces MUST follow this standard:** +TLS/SSL cryptography. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add openssl https://github.com/hyperpolymath/asdf-openssl-plugin.git +---- -=== Web Projects +openssl: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all openssl -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install openssl latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global openssl latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now openssl commands are available +openssl --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list openssl -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local openssl -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall openssl ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/openssl/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/openssl/README.md deleted file mode 100644 index add8b9f4..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/openssl/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-openssl - -[![Build](https://github.com/hyperpolymath/asdf-openssl-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-openssl-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-openssl-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-openssl-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [OpenSSL](https://www.openssl.org). - -TLS/SSL cryptography. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add openssl https://github.com/hyperpolymath/asdf-openssl-plugin.git -``` - -openssl: - -```bash -# Show all installable versions -asdf list-all openssl - -# Install specific version -asdf install openssl latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global openssl latest - -# Now openssl commands are available -openssl --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list openssl - -# Set local version for current directory -asdf local openssl - -# Uninstall a version -asdf uninstall openssl -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/openssl/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/openssl/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/openssl/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/openssl/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/openssl/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/openssl/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/orchid/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/orchid/ABI-FFI-README.adoc new file mode 100644 index 00000000..37457c75 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/orchid/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== ORCHID ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/orchid.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to liborchid.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +orchid/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── orchid.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── orchid.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/orchid.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "orchid.h" + +int main() { + void* handle = orchid_init(); + if (!handle) return 1; + + int result = orchid_process(handle, 42); + if (result != 0) { + const char* err = orchid_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + orchid_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lorchid -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import ORCHID.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "orchid")] +extern "C" { + fn orchid_init() -> *mut std::ffi::c_void; + fn orchid_free(handle: *mut std::ffi::c_void); + fn orchid_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = orchid_init(); + assert!(!handle.is_null()); + + let result = orchid_process(handle, 42); + assert_eq!(result, 0); + + orchid_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const liborchid = "liborchid" + +function init() + handle = ccall((:orchid_init, liborchid), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:orchid_process, liborchid), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:orchid_free, liborchid), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/orchid.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/orchid/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/orchid/ABI-FFI-README.md deleted file mode 100644 index 8a8a6412..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/orchid/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# ORCHID ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/orchid.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to liborchid.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -orchid/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── orchid.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── orchid.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/orchid.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "orchid.h" - -int main() { - void* handle = orchid_init(); - if (!handle) return 1; - - int result = orchid_process(handle, 42); - if (result != 0) { - const char* err = orchid_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - orchid_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lorchid -L./zig-out/lib -``` - -### From Idris2 - -```idris -import ORCHID.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "orchid")] -extern "C" { - fn orchid_init() -> *mut std::ffi::c_void; - fn orchid_free(handle: *mut std::ffi::c_void); - fn orchid_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = orchid_init(); - assert!(!handle.is_null()); - - let result = orchid_process(handle, 42); - assert_eq!(result, 0); - - orchid_free(handle); - } -} -``` - -### From Julia - -```julia -const liborchid = "liborchid" - -function init() - handle = ccall((:orchid_init, liborchid), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:orchid_process, liborchid), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:orchid_free, liborchid), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/orchid.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/orchid/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/orchid/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/orchid/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/orchid/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/orchid/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/orchid/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/orchid/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/orchid/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/orchid/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/orchid/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/orchid/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/orchid/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/orchid/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/orchid/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/orchid/README.adoc index d08e1dd2..c91f2a58 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/orchid/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/orchid/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-orchid -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-orchid-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-orchid-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-orchid-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-orchid-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://orchid.software[Orchid]. -**All repos with foreign function interfaces MUST follow this standard:** +Static site generator. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add orchid https://github.com/hyperpolymath/asdf-orchid-plugin.git +---- -=== Web Projects +orchid: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all orchid -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install orchid latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global orchid latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now orchid commands are available +orchid --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list orchid -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local orchid -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall orchid ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/orchid/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/orchid/README.md deleted file mode 100644 index 8ea1b9e8..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/orchid/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-orchid - -[![Build](https://github.com/hyperpolymath/asdf-orchid-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-orchid-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-orchid-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-orchid-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Orchid](https://orchid.software). - -Static site generator. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add orchid https://github.com/hyperpolymath/asdf-orchid-plugin.git -``` - -orchid: - -```bash -# Show all installable versions -asdf list-all orchid - -# Install specific version -asdf install orchid latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global orchid latest - -# Now orchid commands are available -orchid --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list orchid - -# Set local version for current directory -asdf local orchid - -# Uninstall a version -asdf uninstall orchid -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/orchid/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/orchid/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/orchid/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/orchid/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/orchid/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/orchid/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/pollen/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/pollen/ABI-FFI-README.adoc new file mode 100644 index 00000000..b966efbf --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/pollen/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== POLLEN ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/pollen.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libpollen.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +pollen/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── pollen.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── pollen.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/pollen.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "pollen.h" + +int main() { + void* handle = pollen_init(); + if (!handle) return 1; + + int result = pollen_process(handle, 42); + if (result != 0) { + const char* err = pollen_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + pollen_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lpollen -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import POLLEN.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "pollen")] +extern "C" { + fn pollen_init() -> *mut std::ffi::c_void; + fn pollen_free(handle: *mut std::ffi::c_void); + fn pollen_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = pollen_init(); + assert!(!handle.is_null()); + + let result = pollen_process(handle, 42); + assert_eq!(result, 0); + + pollen_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libpollen = "libpollen" + +function init() + handle = ccall((:pollen_init, libpollen), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:pollen_process, libpollen), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:pollen_free, libpollen), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/pollen.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/pollen/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/pollen/ABI-FFI-README.md deleted file mode 100644 index bb2648b1..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/pollen/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# POLLEN ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/pollen.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libpollen.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -pollen/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── pollen.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── pollen.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/pollen.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "pollen.h" - -int main() { - void* handle = pollen_init(); - if (!handle) return 1; - - int result = pollen_process(handle, 42); - if (result != 0) { - const char* err = pollen_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - pollen_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lpollen -L./zig-out/lib -``` - -### From Idris2 - -```idris -import POLLEN.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "pollen")] -extern "C" { - fn pollen_init() -> *mut std::ffi::c_void; - fn pollen_free(handle: *mut std::ffi::c_void); - fn pollen_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = pollen_init(); - assert!(!handle.is_null()); - - let result = pollen_process(handle, 42); - assert_eq!(result, 0); - - pollen_free(handle); - } -} -``` - -### From Julia - -```julia -const libpollen = "libpollen" - -function init() - handle = ccall((:pollen_init, libpollen), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:pollen_process, libpollen), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:pollen_free, libpollen), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/pollen.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/pollen/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/pollen/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/pollen/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/pollen/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/pollen/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/pollen/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/pollen/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/pollen/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/pollen/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/pollen/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/pollen/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/pollen/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/pollen/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/pollen/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/pollen/README.adoc index d08e1dd2..bdea8c0c 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/pollen/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/pollen/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-pollen -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-pollen-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-pollen-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-pollen-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-pollen-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://docs.racket-lang.org/pollen[Pollen]. -**All repos with foreign function interfaces MUST follow this standard:** +Racket publishing system. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add pollen https://github.com/hyperpolymath/asdf-pollen-plugin.git +---- -=== Web Projects +pollen: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all pollen -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install pollen latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global pollen latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now pollen commands are available +pollen --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list pollen -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local pollen -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall pollen ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/pollen/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/pollen/README.md deleted file mode 100644 index 3c872089..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/pollen/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-pollen - -[![Build](https://github.com/hyperpolymath/asdf-pollen-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-pollen-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-pollen-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-pollen-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Pollen](https://docs.racket-lang.org/pollen). - -Racket publishing system. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add pollen https://github.com/hyperpolymath/asdf-pollen-plugin.git -``` - -pollen: - -```bash -# Show all installable versions -asdf list-all pollen - -# Install specific version -asdf install pollen latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global pollen latest - -# Now pollen commands are available -pollen --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list pollen - -# Set local version for current directory -asdf local pollen - -# Uninstall a version -asdf uninstall pollen -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/pollen/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/pollen/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/pollen/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/pollen/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/pollen/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/pollen/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/pomerium/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/pomerium/ABI-FFI-README.adoc new file mode 100644 index 00000000..9a11b87e --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/pomerium/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== POMERIUM ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/pomerium.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libpomerium.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +pomerium/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── pomerium.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── pomerium.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/pomerium.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "pomerium.h" + +int main() { + void* handle = pomerium_init(); + if (!handle) return 1; + + int result = pomerium_process(handle, 42); + if (result != 0) { + const char* err = pomerium_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + pomerium_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lpomerium -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import POMERIUM.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "pomerium")] +extern "C" { + fn pomerium_init() -> *mut std::ffi::c_void; + fn pomerium_free(handle: *mut std::ffi::c_void); + fn pomerium_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = pomerium_init(); + assert!(!handle.is_null()); + + let result = pomerium_process(handle, 42); + assert_eq!(result, 0); + + pomerium_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libpomerium = "libpomerium" + +function init() + handle = ccall((:pomerium_init, libpomerium), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:pomerium_process, libpomerium), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:pomerium_free, libpomerium), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/pomerium.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/pomerium/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/pomerium/ABI-FFI-README.md deleted file mode 100644 index 4cc404ec..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/pomerium/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# POMERIUM ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/pomerium.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libpomerium.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -pomerium/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── pomerium.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── pomerium.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/pomerium.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "pomerium.h" - -int main() { - void* handle = pomerium_init(); - if (!handle) return 1; - - int result = pomerium_process(handle, 42); - if (result != 0) { - const char* err = pomerium_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - pomerium_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lpomerium -L./zig-out/lib -``` - -### From Idris2 - -```idris -import POMERIUM.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "pomerium")] -extern "C" { - fn pomerium_init() -> *mut std::ffi::c_void; - fn pomerium_free(handle: *mut std::ffi::c_void); - fn pomerium_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = pomerium_init(); - assert!(!handle.is_null()); - - let result = pomerium_process(handle, 42); - assert_eq!(result, 0); - - pomerium_free(handle); - } -} -``` - -### From Julia - -```julia -const libpomerium = "libpomerium" - -function init() - handle = ccall((:pomerium_init, libpomerium), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:pomerium_process, libpomerium), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:pomerium_free, libpomerium), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/pomerium.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/pomerium/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/pomerium/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/pomerium/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/pomerium/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/pomerium/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/pomerium/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/pomerium/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/pomerium/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/pomerium/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/pomerium/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/pomerium/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/pomerium/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/pomerium/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/pomerium/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/pomerium/README.adoc index d08e1dd2..31f3305d 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/pomerium/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/pomerium/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-pomerium -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-pomerium-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-pomerium-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-pomerium-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-pomerium-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://www.pomerium.com[Pomerium]. -**All repos with foreign function interfaces MUST follow this standard:** +Identity-aware proxy. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add pomerium https://github.com/hyperpolymath/asdf-pomerium-plugin.git +---- -=== Web Projects +pomerium: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all pomerium -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install pomerium latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global pomerium latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now pomerium commands are available +pomerium --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list pomerium -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local pomerium -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall pomerium ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/pomerium/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/pomerium/README.md deleted file mode 100644 index 2da9d408..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/pomerium/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-pomerium - -[![Build](https://github.com/hyperpolymath/asdf-pomerium-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-pomerium-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-pomerium-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-pomerium-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Pomerium](https://www.pomerium.com). - -Identity-aware proxy. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add pomerium https://github.com/hyperpolymath/asdf-pomerium-plugin.git -``` - -pomerium: - -```bash -# Show all installable versions -asdf list-all pomerium - -# Install specific version -asdf install pomerium latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global pomerium latest - -# Now pomerium commands are available -pomerium --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list pomerium - -# Set local version for current directory -asdf local pomerium - -# Uninstall a version -asdf uninstall pomerium -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/pomerium/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/pomerium/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/pomerium/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/pomerium/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/pomerium/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/pomerium/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/rekor/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/rekor/ABI-FFI-README.adoc new file mode 100644 index 00000000..55ffa8ff --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/rekor/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== REKOR ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/rekor.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to librekor.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +rekor/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── rekor.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── rekor.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/rekor.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "rekor.h" + +int main() { + void* handle = rekor_init(); + if (!handle) return 1; + + int result = rekor_process(handle, 42); + if (result != 0) { + const char* err = rekor_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + rekor_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lrekor -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import REKOR.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "rekor")] +extern "C" { + fn rekor_init() -> *mut std::ffi::c_void; + fn rekor_free(handle: *mut std::ffi::c_void); + fn rekor_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = rekor_init(); + assert!(!handle.is_null()); + + let result = rekor_process(handle, 42); + assert_eq!(result, 0); + + rekor_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const librekor = "librekor" + +function init() + handle = ccall((:rekor_init, librekor), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:rekor_process, librekor), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:rekor_free, librekor), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/rekor.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/rekor/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/rekor/ABI-FFI-README.md deleted file mode 100644 index 0722435d..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/rekor/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# REKOR ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/rekor.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to librekor.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -rekor/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── rekor.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── rekor.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/rekor.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "rekor.h" - -int main() { - void* handle = rekor_init(); - if (!handle) return 1; - - int result = rekor_process(handle, 42); - if (result != 0) { - const char* err = rekor_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - rekor_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lrekor -L./zig-out/lib -``` - -### From Idris2 - -```idris -import REKOR.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "rekor")] -extern "C" { - fn rekor_init() -> *mut std::ffi::c_void; - fn rekor_free(handle: *mut std::ffi::c_void); - fn rekor_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = rekor_init(); - assert!(!handle.is_null()); - - let result = rekor_process(handle, 42); - assert_eq!(result, 0); - - rekor_free(handle); - } -} -``` - -### From Julia - -```julia -const librekor = "librekor" - -function init() - handle = ccall((:rekor_init, librekor), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:rekor_process, librekor), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:rekor_free, librekor), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/rekor.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/rekor/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/rekor/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/rekor/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/rekor/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/rekor/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/rekor/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/rekor/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/rekor/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/rekor/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/rekor/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/rekor/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/rekor/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/rekor/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/rekor/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/rekor/README.adoc index d08e1dd2..512c1faf 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/rekor/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/rekor/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-rekor -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-rekor-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-rekor-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-rekor-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-rekor-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://sigstore.dev[Rekor]. -**All repos with foreign function interfaces MUST follow this standard:** +Sigstore transparency log. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add rekor https://github.com/hyperpolymath/asdf-rekor-plugin.git +---- -=== Web Projects +rekor: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all rekor -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install rekor latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global rekor latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now rekor commands are available +rekor --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list rekor -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local rekor -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall rekor ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/rekor/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/rekor/README.md deleted file mode 100644 index b031657a..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/rekor/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-rekor - -[![Build](https://github.com/hyperpolymath/asdf-rekor-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-rekor-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-rekor-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-rekor-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Rekor](https://sigstore.dev). - -Sigstore transparency log. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add rekor https://github.com/hyperpolymath/asdf-rekor-plugin.git -``` - -rekor: - -```bash -# Show all installable versions -asdf list-all rekor - -# Install specific version -asdf install rekor latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global rekor latest - -# Now rekor commands are available -rekor --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list rekor - -# Set local version for current directory -asdf local rekor - -# Uninstall a version -asdf uninstall rekor -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/rekor/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/rekor/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/rekor/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/rekor/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/rekor/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/rekor/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/rescript/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/rescript/ABI-FFI-README.adoc new file mode 100644 index 00000000..d31a905e --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/rescript/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== AFFINESCRIPT ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/affinescript.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to librescript.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +affinescript/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── affinescript.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── affinescript.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/affinescript.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "affinescript.h" + +int main() { + void* handle = rescript_init(); + if (!handle) return 1; + + int result = rescript_process(handle, 42); + if (result != 0) { + const char* err = rescript_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + rescript_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lrescript -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import AFFINESCRIPT.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "affinescript")] +extern "C" { + fn rescript_init() -> *mut std::ffi::c_void; + fn rescript_free(handle: *mut std::ffi::c_void); + fn rescript_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = rescript_init(); + assert!(!handle.is_null()); + + let result = rescript_process(handle, 42); + assert_eq!(result, 0); + + rescript_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const librescript = "librescript" + +function init() + handle = ccall((:rescript_init, librescript), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:rescript_process, librescript), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:rescript_free, librescript), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/affinescript.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/rescript/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/rescript/ABI-FFI-README.md deleted file mode 100644 index 358c9ee2..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/rescript/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# AFFINESCRIPT ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/affinescript.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to librescript.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -affinescript/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── affinescript.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── affinescript.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/affinescript.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "affinescript.h" - -int main() { - void* handle = rescript_init(); - if (!handle) return 1; - - int result = rescript_process(handle, 42); - if (result != 0) { - const char* err = rescript_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - rescript_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lrescript -L./zig-out/lib -``` - -### From Idris2 - -```idris -import AFFINESCRIPT.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "affinescript")] -extern "C" { - fn rescript_init() -> *mut std::ffi::c_void; - fn rescript_free(handle: *mut std::ffi::c_void); - fn rescript_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = rescript_init(); - assert!(!handle.is_null()); - - let result = rescript_process(handle, 42); - assert_eq!(result, 0); - - rescript_free(handle); - } -} -``` - -### From Julia - -```julia -const librescript = "librescript" - -function init() - handle = ccall((:rescript_init, librescript), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:rescript_process, librescript), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:rescript_free, librescript), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/affinescript.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/rescript/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/rescript/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/rescript/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/rescript/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/rescript/CODE_OF_CONDUCT.md deleted file mode 100644 index 66a1ffed..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/rescript/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/rescript/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/rescript/CONTRIBUTING.adoc index 2a29fd14..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/rescript/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/rescript/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: MPL-2.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/rescript/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/rescript/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/rescript/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/rescript/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/rescript/README.adoc index d08e1dd2..84007da3 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/rescript/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/rescript/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-affinescript -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-affinescript-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-affinescript-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-affinescript-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-affinescript-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-PMPL–1.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://affinescript-lang.org[AffineScript]. -**All repos with foreign function interfaces MUST follow this standard:** +Type-safe JavaScript. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add affinescript https://github.com/hyperpolymath/asdf-affinescript-plugin.git +---- -=== Web Projects +affinescript: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all affinescript -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install affinescript latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global affinescript latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now affinescript commands are available +affinescript --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list affinescript -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local affinescript -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall affinescript ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/rescript/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/rescript/README.md deleted file mode 100644 index c30e28b1..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/rescript/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-affinescript - -[![Build](https://github.com/hyperpolymath/asdf-affinescript-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-affinescript-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-affinescript-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-affinescript-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-PMPL--1.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [AffineScript](https://affinescript-lang.org). - -Type-safe JavaScript. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add affinescript https://github.com/hyperpolymath/asdf-affinescript-plugin.git -``` - -affinescript: - -```bash -# Show all installable versions -asdf list-all affinescript - -# Install specific version -asdf install affinescript latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global affinescript latest - -# Now affinescript commands are available -affinescript --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list affinescript - -# Set local version for current directory -asdf local affinescript - -# Uninstall a version -asdf uninstall affinescript -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/rescript/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/rescript/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/rescript/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/rescript/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/rescript/SECURITY.md deleted file mode 100644 index f6df8cb5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/rescript/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/restic/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/restic/ABI-FFI-README.adoc new file mode 100644 index 00000000..f8a06f74 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/restic/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== RESTIC ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/restic.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to librestic.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +restic/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── restic.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── restic.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/restic.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "restic.h" + +int main() { + void* handle = restic_init(); + if (!handle) return 1; + + int result = restic_process(handle, 42); + if (result != 0) { + const char* err = restic_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + restic_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lrestic -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import RESTIC.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "restic")] +extern "C" { + fn restic_init() -> *mut std::ffi::c_void; + fn restic_free(handle: *mut std::ffi::c_void); + fn restic_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = restic_init(); + assert!(!handle.is_null()); + + let result = restic_process(handle, 42); + assert_eq!(result, 0); + + restic_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const librestic = "librestic" + +function init() + handle = ccall((:restic_init, librestic), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:restic_process, librestic), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:restic_free, librestic), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/restic.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/restic/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/restic/ABI-FFI-README.md deleted file mode 100644 index df6de0ef..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/restic/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# RESTIC ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/restic.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to librestic.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -restic/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── restic.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── restic.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/restic.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "restic.h" - -int main() { - void* handle = restic_init(); - if (!handle) return 1; - - int result = restic_process(handle, 42); - if (result != 0) { - const char* err = restic_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - restic_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lrestic -L./zig-out/lib -``` - -### From Idris2 - -```idris -import RESTIC.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "restic")] -extern "C" { - fn restic_init() -> *mut std::ffi::c_void; - fn restic_free(handle: *mut std::ffi::c_void); - fn restic_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = restic_init(); - assert!(!handle.is_null()); - - let result = restic_process(handle, 42); - assert_eq!(result, 0); - - restic_free(handle); - } -} -``` - -### From Julia - -```julia -const librestic = "librestic" - -function init() - handle = ccall((:restic_init, librestic), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:restic_process, librestic), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:restic_free, librestic), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/restic.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/restic/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/restic/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/restic/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/restic/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/restic/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/restic/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/restic/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/restic/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/restic/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/restic/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/restic/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/restic/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/restic/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/restic/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/restic/README.adoc index d08e1dd2..23d77c86 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/restic/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/restic/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-restic -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-restic-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-restic-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-restic-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-restic-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://restic.net[Restic]. -**All repos with foreign function interfaces MUST follow this standard:** +Fast secure backup. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add restic https://github.com/hyperpolymath/asdf-restic-plugin.git +---- -=== Web Projects +restic: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all restic -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install restic latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global restic latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now restic commands are available +restic --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list restic -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local restic -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall restic ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/restic/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/restic/README.md deleted file mode 100644 index 442f2bd1..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/restic/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-restic - -[![Build](https://github.com/hyperpolymath/asdf-restic-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-restic-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-restic-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-restic-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Restic](https://restic.net). - -Fast secure backup. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add restic https://github.com/hyperpolymath/asdf-restic-plugin.git -``` - -restic: - -```bash -# Show all installable versions -asdf list-all restic - -# Install specific version -asdf install restic latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global restic latest - -# Now restic commands are available -restic --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list restic - -# Set local version for current directory -asdf local restic - -# Uninstall a version -asdf uninstall restic -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/restic/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/restic/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/restic/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/restic/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/restic/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/restic/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/rethinkdb/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/rethinkdb/ABI-FFI-README.adoc new file mode 100644 index 00000000..75445ff6 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/rethinkdb/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== RETHINKDB ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/rethinkdb.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to librethinkdb.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +rethinkdb/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── rethinkdb.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── rethinkdb.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/rethinkdb.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "rethinkdb.h" + +int main() { + void* handle = rethinkdb_init(); + if (!handle) return 1; + + int result = rethinkdb_process(handle, 42); + if (result != 0) { + const char* err = rethinkdb_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + rethinkdb_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lrethinkdb -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import RETHINKDB.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "rethinkdb")] +extern "C" { + fn rethinkdb_init() -> *mut std::ffi::c_void; + fn rethinkdb_free(handle: *mut std::ffi::c_void); + fn rethinkdb_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = rethinkdb_init(); + assert!(!handle.is_null()); + + let result = rethinkdb_process(handle, 42); + assert_eq!(result, 0); + + rethinkdb_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const librethinkdb = "librethinkdb" + +function init() + handle = ccall((:rethinkdb_init, librethinkdb), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:rethinkdb_process, librethinkdb), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:rethinkdb_free, librethinkdb), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/rethinkdb.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/rethinkdb/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/rethinkdb/ABI-FFI-README.md deleted file mode 100644 index 3e1dca88..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/rethinkdb/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# RETHINKDB ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/rethinkdb.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to librethinkdb.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -rethinkdb/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── rethinkdb.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── rethinkdb.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/rethinkdb.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "rethinkdb.h" - -int main() { - void* handle = rethinkdb_init(); - if (!handle) return 1; - - int result = rethinkdb_process(handle, 42); - if (result != 0) { - const char* err = rethinkdb_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - rethinkdb_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lrethinkdb -L./zig-out/lib -``` - -### From Idris2 - -```idris -import RETHINKDB.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "rethinkdb")] -extern "C" { - fn rethinkdb_init() -> *mut std::ffi::c_void; - fn rethinkdb_free(handle: *mut std::ffi::c_void); - fn rethinkdb_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = rethinkdb_init(); - assert!(!handle.is_null()); - - let result = rethinkdb_process(handle, 42); - assert_eq!(result, 0); - - rethinkdb_free(handle); - } -} -``` - -### From Julia - -```julia -const librethinkdb = "librethinkdb" - -function init() - handle = ccall((:rethinkdb_init, librethinkdb), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:rethinkdb_process, librethinkdb), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:rethinkdb_free, librethinkdb), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/rethinkdb.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/rethinkdb/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/rethinkdb/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/rethinkdb/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/rethinkdb/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/rethinkdb/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/rethinkdb/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/rethinkdb/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/rethinkdb/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/rethinkdb/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/rethinkdb/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/rethinkdb/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/rethinkdb/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/rethinkdb/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/rethinkdb/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/rethinkdb/README.adoc index d08e1dd2..b110a454 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/rethinkdb/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/rethinkdb/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-rethinkdb -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-rethinkdb-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-rethinkdb-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-rethinkdb-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-rethinkdb-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://rethinkdb.com[RethinkDB]. -**All repos with foreign function interfaces MUST follow this standard:** +Real-time document database. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add rethinkdb https://github.com/hyperpolymath/asdf-rethinkdb-plugin.git +---- -=== Web Projects +rethinkdb: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all rethinkdb -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install rethinkdb latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global rethinkdb latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now rethinkdb commands are available +rethinkdb --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list rethinkdb -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local rethinkdb -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall rethinkdb ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/rethinkdb/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/rethinkdb/README.md deleted file mode 100644 index b2ad7d5d..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/rethinkdb/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-rethinkdb - -[![Build](https://github.com/hyperpolymath/asdf-rethinkdb-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-rethinkdb-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-rethinkdb-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-rethinkdb-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [RethinkDB](https://rethinkdb.com). - -Real-time document database. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add rethinkdb https://github.com/hyperpolymath/asdf-rethinkdb-plugin.git -``` - -rethinkdb: - -```bash -# Show all installable versions -asdf list-all rethinkdb - -# Install specific version -asdf install rethinkdb latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global rethinkdb latest - -# Now rethinkdb commands are available -rethinkdb --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list rethinkdb - -# Set local version for current directory -asdf local rethinkdb - -# Uninstall a version -asdf uninstall rethinkdb -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/rethinkdb/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/rethinkdb/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/rethinkdb/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/rethinkdb/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/rethinkdb/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/rethinkdb/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/security/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/security/ABI-FFI-README.adoc new file mode 100644 index 00000000..a80ffdfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/security/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== SECURITY ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/security.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libsecurity.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +security/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── security.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── security.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/security.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "security.h" + +int main() { + void* handle = security_init(); + if (!handle) return 1; + + int result = security_process(handle, 42); + if (result != 0) { + const char* err = security_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + security_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lsecurity -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import SECURITY.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "security")] +extern "C" { + fn security_init() -> *mut std::ffi::c_void; + fn security_free(handle: *mut std::ffi::c_void); + fn security_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = security_init(); + assert!(!handle.is_null()); + + let result = security_process(handle, 42); + assert_eq!(result, 0); + + security_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libsecurity = "libsecurity" + +function init() + handle = ccall((:security_init, libsecurity), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:security_process, libsecurity), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:security_free, libsecurity), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/security.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/security/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/security/ABI-FFI-README.md deleted file mode 100644 index 28dfe6f4..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/security/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# SECURITY ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/security.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libsecurity.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -security/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── security.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── security.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/security.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "security.h" - -int main() { - void* handle = security_init(); - if (!handle) return 1; - - int result = security_process(handle, 42); - if (result != 0) { - const char* err = security_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - security_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lsecurity -L./zig-out/lib -``` - -### From Idris2 - -```idris -import SECURITY.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "security")] -extern "C" { - fn security_init() -> *mut std::ffi::c_void; - fn security_free(handle: *mut std::ffi::c_void); - fn security_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = security_init(); - assert!(!handle.is_null()); - - let result = security_process(handle, 42); - assert_eq!(result, 0); - - security_free(handle); - } -} -``` - -### From Julia - -```julia -const libsecurity = "libsecurity" - -function init() - handle = ccall((:security_init, libsecurity), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:security_process, libsecurity), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:security_free, libsecurity), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/security.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/security/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/security/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/security/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/security/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/security/CODE_OF_CONDUCT.md deleted file mode 100644 index caeda1c6..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/security/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,27 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. - diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/security/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/security/CONTRIBUTING.adoc index eb045d61..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/security/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/security/CONTRIBUTING.adoc @@ -1,20 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/security/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/security/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/security/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/security/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/security/README.adoc index acbc80f7..92df847a 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/security/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/security/README.adoc @@ -1,122 +1,54 @@ -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] -image:https://img.shields.io/badge/Philosophy-Palimpsest-indigo.svg[Palimpsest,link="https://github.com/hyperpolymath/palimpsest-license"] +== asdf-security-plugin +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] +image:https://img.shields.io/badge/Philosophy-Palimpsest-indigo.svg[Palimpsest,link="`https://github.com/hyperpolymath/palimpsest-license`"] -// SPDX-License-Identifier: CC-BY-SA-4.0 -= asdf-security-plugin +Security-focused extensions and policies for the +https://asdf-vm.com[asdf] version manager ecosystem. -:toc: macro -:toc-title: Contents -:toclevels: 2 +=== Status -**Security scanning plugin for asdf version manager** +____ +*Note:* This repository is currently a project skeleton. Implementation +is pending. +____ -toc::[] +=== Overview -== Status +`+asdf-security-plugin+` provides security tooling and policies for the +asdf plugin ecosystem: -[NOTE] -==== -This plugin is *fully functional* at version 1.0.0. -==== +* *Security scanning* - Vulnerability detection for installed tools +* *Policy enforcement* - Ensure only approved versions are installed +* *Audit logging* - Track version changes and installations +* *Signature verification* - Validate tool authenticity -== Overview +=== Planned Features -`asdf-security-plugin` is a security-focused plugin for the https://asdf-vm.com/[asdf version manager]. It provides security scanning capabilities for asdf installations, including plugin auditing, signature verification, and vulnerability reporting. +* Integration with Trivy, Grype, and Syft for scanning +* Policy-as-code support via OPA/Rego +* SBOM generation for installed tool chains +* Supply chain attestation via Sigstore -== Installation +=== Related Projects -[source,bash] ----- -asdf plugin add asdf-security https://github.com/hyperpolymath/asdf-security-plugin.git -asdf install asdf-security 1.0.0 -asdf global asdf-security 1.0.0 ----- - -== Usage - -[source,bash] ----- -asdf-security [args...] ----- - -=== Commands - -[cols="2,3",options="header"] +[width="100%",cols="40%,60%",options="header",] |=== -| Command | Description - -| `audit` -| Audit all installed asdf plugins for known vulnerabilities - -| `verify ` -| Verify GPG signatures and SHA256 checksums of a plugin - -| `report` -| Generate a comprehensive security report of all plugins +|Project |Relationship +|https://github.com/hyperpolymath/asdf-metaiconic-plugin[asdf-metaiconic-plugin] +|Metadata registry -| `update-db` -| Update the local vulnerability database +|https://github.com/hyperpolymath/asdf-ui-plugin[asdf-ui-plugin] |Visual +interface |=== -=== Examples - -[source,bash] ----- -# Audit all plugins -asdf-security audit - -# Verify a specific plugin -asdf-security verify nodejs - -# Generate security report -asdf-security report - -# Update vulnerability database -asdf-security update-db ----- - -== Components - -[cols="2,3",options="header"] -|=== -| Component | Description - -| `bin/list-all` -| Lists available versions of asdf-security - -| `bin/download` -| Downloads the specified version - -| `bin/install` -| Installs asdf-security to the specified path - -| `lib/utils.bash` -| Shared utility functions - -| `.github/workflows/` -| CI/CD infrastructure including security scanning - -| `hooks/` -| Pre-commit validation hooks for security standards -|=== - -== Security Features - -* *Plugin Auditing*: Scans installed plugins against known vulnerability databases -* *Signature Verification*: Validates GPG signatures on plugin releases -* *Checksum Validation*: SHA256 integrity verification for downloads -* *Security Reports*: Comprehensive JSON/text reports of security posture - -== Development Standards - -Per the Hyperpolymath Language Policy: +=== License -* **Primary languages**: Bash/POSIX Shell (for asdf plugin scripts) -* **Package management**: Guix (primary), Guix (fallback) -* **Security**: SHA256+ hashing, HTTPS only, no hardcoded secrets, SHA-pinned dependencies -* **Code quality**: ShellCheck linting, SPDX license headers +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -== License +''''' -MPL-2.0 +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/security/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/security/README.md deleted file mode 100644 index 9ee2db44..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/security/README.md +++ /dev/null @@ -1,41 +0,0 @@ -# asdf-security-plugin - -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] -image:https://img.shields.io/badge/Philosophy-Palimpsest-indigo.svg[Palimpsest,link="https://github.com/hyperpolymath/palimpsest-license"] - -Security-focused extensions and policies for the [asdf](https://asdf-vm.com) version manager ecosystem. - -## Status - -> **Note:** This repository is currently a project skeleton. Implementation is pending. - -## Overview - -`asdf-security-plugin` provides security tooling and policies for the asdf plugin ecosystem: - -- **Security scanning** - Vulnerability detection for installed tools -- **Policy enforcement** - Ensure only approved versions are installed -- **Audit logging** - Track version changes and installations -- **Signature verification** - Validate tool authenticity - -## Planned Features - -- Integration with Trivy, Grype, and Syft for scanning -- Policy-as-code support via OPA/Rego -- SBOM generation for installed tool chains -- Supply chain attestation via Sigstore - -## Related Projects - -| Project | Relationship | -|---------|--------------| -| [asdf-metaiconic-plugin](https://github.com/hyperpolymath/asdf-metaiconic-plugin) | Metadata registry | -| [asdf-ui-plugin](https://github.com/hyperpolymath/asdf-ui-plugin) | Visual interface | - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/security/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/security/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/security/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/security/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/security/SECURITY.md deleted file mode 100644 index 159a0b7a..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/security/SECURITY.md +++ /dev/null @@ -1,25 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection - diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/serum/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/serum/ABI-FFI-README.adoc new file mode 100644 index 00000000..324cdd6c --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/serum/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== SERUM ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/serum.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libserum.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +serum/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── serum.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── serum.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/serum.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "serum.h" + +int main() { + void* handle = serum_init(); + if (!handle) return 1; + + int result = serum_process(handle, 42); + if (result != 0) { + const char* err = serum_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + serum_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lserum -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import SERUM.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "serum")] +extern "C" { + fn serum_init() -> *mut std::ffi::c_void; + fn serum_free(handle: *mut std::ffi::c_void); + fn serum_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = serum_init(); + assert!(!handle.is_null()); + + let result = serum_process(handle, 42); + assert_eq!(result, 0); + + serum_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libserum = "libserum" + +function init() + handle = ccall((:serum_init, libserum), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:serum_process, libserum), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:serum_free, libserum), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/serum.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/serum/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/serum/ABI-FFI-README.md deleted file mode 100644 index 55ed6746..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/serum/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# SERUM ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/serum.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libserum.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -serum/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── serum.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── serum.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/serum.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "serum.h" - -int main() { - void* handle = serum_init(); - if (!handle) return 1; - - int result = serum_process(handle, 42); - if (result != 0) { - const char* err = serum_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - serum_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lserum -L./zig-out/lib -``` - -### From Idris2 - -```idris -import SERUM.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "serum")] -extern "C" { - fn serum_init() -> *mut std::ffi::c_void; - fn serum_free(handle: *mut std::ffi::c_void); - fn serum_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = serum_init(); - assert!(!handle.is_null()); - - let result = serum_process(handle, 42); - assert_eq!(result, 0); - - serum_free(handle); - } -} -``` - -### From Julia - -```julia -const libserum = "libserum" - -function init() - handle = ccall((:serum_init, libserum), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:serum_process, libserum), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:serum_free, libserum), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/serum.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/serum/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/serum/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/serum/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/serum/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/serum/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/serum/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/serum/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/serum/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/serum/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/serum/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/serum/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/serum/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/serum/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/serum/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/serum/README.adoc index d08e1dd2..8de14fa8 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/serum/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/serum/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-serum -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-serum-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-serum-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-serum-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-serum-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://dalgona.github.io/Serum[Serum]. -**All repos with foreign function interfaces MUST follow this standard:** +Elixir static site generator. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add serum https://github.com/hyperpolymath/asdf-serum-plugin.git +---- -=== Web Projects +serum: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all serum -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install serum latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global serum latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now serum commands are available +serum --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list serum -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local serum -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall serum ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/serum/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/serum/README.md deleted file mode 100644 index f325d7f4..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/serum/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-serum - -[![Build](https://github.com/hyperpolymath/asdf-serum-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-serum-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-serum-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-serum-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Serum](https://dalgona.github.io/Serum). - -Elixir static site generator. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add serum https://github.com/hyperpolymath/asdf-serum-plugin.git -``` - -serum: - -```bash -# Show all installable versions -asdf list-all serum - -# Install specific version -asdf install serum latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global serum latest - -# Now serum commands are available -serum --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list serum - -# Set local version for current directory -asdf local serum - -# Uninstall a version -asdf uninstall serum -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/serum/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/serum/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/serum/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/serum/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/serum/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/serum/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/sops/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/sops/ABI-FFI-README.adoc new file mode 100644 index 00000000..172c85b4 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/sops/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== SOPS ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/sops.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libsops.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +sops/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── sops.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── sops.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/sops.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "sops.h" + +int main() { + void* handle = sops_init(); + if (!handle) return 1; + + int result = sops_process(handle, 42); + if (result != 0) { + const char* err = sops_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + sops_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lsops -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import SOPS.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "sops")] +extern "C" { + fn sops_init() -> *mut std::ffi::c_void; + fn sops_free(handle: *mut std::ffi::c_void); + fn sops_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = sops_init(); + assert!(!handle.is_null()); + + let result = sops_process(handle, 42); + assert_eq!(result, 0); + + sops_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libsops = "libsops" + +function init() + handle = ccall((:sops_init, libsops), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:sops_process, libsops), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:sops_free, libsops), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/sops.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/sops/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/sops/ABI-FFI-README.md deleted file mode 100644 index 94692b76..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/sops/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# SOPS ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/sops.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libsops.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -sops/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── sops.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── sops.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/sops.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "sops.h" - -int main() { - void* handle = sops_init(); - if (!handle) return 1; - - int result = sops_process(handle, 42); - if (result != 0) { - const char* err = sops_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - sops_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lsops -L./zig-out/lib -``` - -### From Idris2 - -```idris -import SOPS.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "sops")] -extern "C" { - fn sops_init() -> *mut std::ffi::c_void; - fn sops_free(handle: *mut std::ffi::c_void); - fn sops_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = sops_init(); - assert!(!handle.is_null()); - - let result = sops_process(handle, 42); - assert_eq!(result, 0); - - sops_free(handle); - } -} -``` - -### From Julia - -```julia -const libsops = "libsops" - -function init() - handle = ccall((:sops_init, libsops), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:sops_process, libsops), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:sops_free, libsops), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/sops.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/sops/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/sops/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/sops/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/sops/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/sops/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/sops/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/sops/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/sops/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/sops/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/sops/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/sops/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/sops/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/sops/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/sops/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/sops/README.adoc index 72f888e1..59bf0404 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/sops/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/sops/README.adoc @@ -1,26 +1,83 @@ -= asdf-sops +== asdf-sops -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] -:url-asdf: https://asdf-vm.com +https://github.com/hyperpolymath/asdf-sops-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-sops-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-sops-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-sops-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -An {url-asdf}[asdf] plugin for https://github.com/getsops/sops[SOPS] - Secrets OPerationS. +https://asdf-vm.com[asdf] plugin for +https://github.com/getsops/sops[SOPS]. -== Installation +Secrets editor. + +=== Contents + +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] + +=== Dependencies + +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] + +=== Install + +Plugin: [source,bash] ---- asdf plugin add sops https://github.com/hyperpolymath/asdf-sops-plugin.git ---- -== Usage +sops: [source,bash] ---- -asdf list all sops +# Show all installable versions +asdf list-all sops + +# Install specific version asdf install sops latest + +# Set a version globally (in your ~/.tool-versions file) asdf global sops latest + +# Now sops commands are available +sops --version ---- -== License +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. + +=== Usage + +[source,bash] +---- +# List installed versions +asdf list sops + +# Set local version for current directory +asdf local sops + +# Uninstall a version +asdf uninstall sops +---- + +=== Contributing + +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License + +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. + +''''' -SPDX-License-Identifier: CC-BY-SA-4.0 +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/sops/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/sops/README.md deleted file mode 100644 index 64c9008d..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/sops/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-sops - -[![Build](https://github.com/hyperpolymath/asdf-sops-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-sops-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-sops-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-sops-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [SOPS](https://github.com/getsops/sops). - -Secrets editor. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add sops https://github.com/hyperpolymath/asdf-sops-plugin.git -``` - -sops: - -```bash -# Show all installable versions -asdf list-all sops - -# Install specific version -asdf install sops latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global sops latest - -# Now sops commands are available -sops --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list sops - -# Set local version for current directory -asdf local sops - -# Uninstall a version -asdf uninstall sops -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/sops/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/sops/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/sops/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/sops/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/sops/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/sops/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/step-ca/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/step-ca/ABI-FFI-README.adoc new file mode 100644 index 00000000..48e73b27 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/step-ca/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== STEP_CA ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/step-ca.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libstep-ca.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +step-ca/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── step-ca.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── step-ca.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/step-ca.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "step-ca.h" + +int main() { + void* handle = step-ca_init(); + if (!handle) return 1; + + int result = step-ca_process(handle, 42); + if (result != 0) { + const char* err = step-ca_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + step-ca_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lstep-ca -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import STEP_CA.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "step-ca")] +extern "C" { + fn step-ca_init() -> *mut std::ffi::c_void; + fn step-ca_free(handle: *mut std::ffi::c_void); + fn step-ca_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = step-ca_init(); + assert!(!handle.is_null()); + + let result = step-ca_process(handle, 42); + assert_eq!(result, 0); + + step-ca_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libstep-ca = "libstep-ca" + +function init() + handle = ccall((:step-ca_init, libstep-ca), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:step-ca_process, libstep-ca), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:step-ca_free, libstep-ca), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/step-ca.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/step-ca/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/step-ca/ABI-FFI-README.md deleted file mode 100644 index 3a8993d5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/step-ca/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# STEP_CA ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/step-ca.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libstep-ca.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -step-ca/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── step-ca.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── step-ca.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/step-ca.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "step-ca.h" - -int main() { - void* handle = step-ca_init(); - if (!handle) return 1; - - int result = step-ca_process(handle, 42); - if (result != 0) { - const char* err = step-ca_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - step-ca_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lstep-ca -L./zig-out/lib -``` - -### From Idris2 - -```idris -import STEP_CA.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "step-ca")] -extern "C" { - fn step-ca_init() -> *mut std::ffi::c_void; - fn step-ca_free(handle: *mut std::ffi::c_void); - fn step-ca_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = step-ca_init(); - assert!(!handle.is_null()); - - let result = step-ca_process(handle, 42); - assert_eq!(result, 0); - - step-ca_free(handle); - } -} -``` - -### From Julia - -```julia -const libstep-ca = "libstep-ca" - -function init() - handle = ccall((:step-ca_init, libstep-ca), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:step-ca_process, libstep-ca), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:step-ca_free, libstep-ca), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/step-ca.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/step-ca/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/step-ca/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/step-ca/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/step-ca/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/step-ca/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/step-ca/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/step-ca/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/step-ca/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/step-ca/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/step-ca/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/step-ca/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/step-ca/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/step-ca/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/step-ca/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/step-ca/README.adoc index d08e1dd2..6fe8354d 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/step-ca/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/step-ca/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-step-ca -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-step-ca-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-step-ca-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-step-ca-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-step-ca-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://smallstep.com/certificates[step-ca]. -**All repos with foreign function interfaces MUST follow this standard:** +Private CA. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add step-ca https://github.com/hyperpolymath/asdf-step-ca-plugin.git +---- -=== Web Projects +step-ca: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all step-ca -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install step-ca latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global step-ca latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now step-ca commands are available +step-ca --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list step-ca -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local step-ca -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall step-ca ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/step-ca/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/step-ca/README.md deleted file mode 100644 index b7069748..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/step-ca/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-step-ca - -[![Build](https://github.com/hyperpolymath/asdf-step-ca-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-step-ca-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-step-ca-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-step-ca-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [step-ca](https://smallstep.com/certificates). - -Private CA. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add step-ca https://github.com/hyperpolymath/asdf-step-ca-plugin.git -``` - -step-ca: - -```bash -# Show all installable versions -asdf list-all step-ca - -# Install specific version -asdf install step-ca latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global step-ca latest - -# Now step-ca commands are available -step-ca --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list step-ca - -# Set local version for current directory -asdf local step-ca - -# Uninstall a version -asdf uninstall step-ca -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/step-ca/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/step-ca/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/step-ca/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/step-ca/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/step-ca/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/step-ca/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/surrealdb/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/surrealdb/ABI-FFI-README.adoc new file mode 100644 index 00000000..193bfa2a --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/surrealdb/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== SURREALDB ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/surrealdb.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libsurrealdb.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +surrealdb/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── surrealdb.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── surrealdb.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/surrealdb.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "surrealdb.h" + +int main() { + void* handle = surrealdb_init(); + if (!handle) return 1; + + int result = surrealdb_process(handle, 42); + if (result != 0) { + const char* err = surrealdb_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + surrealdb_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lsurrealdb -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import SURREALDB.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "surrealdb")] +extern "C" { + fn surrealdb_init() -> *mut std::ffi::c_void; + fn surrealdb_free(handle: *mut std::ffi::c_void); + fn surrealdb_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = surrealdb_init(); + assert!(!handle.is_null()); + + let result = surrealdb_process(handle, 42); + assert_eq!(result, 0); + + surrealdb_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libsurrealdb = "libsurrealdb" + +function init() + handle = ccall((:surrealdb_init, libsurrealdb), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:surrealdb_process, libsurrealdb), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:surrealdb_free, libsurrealdb), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/surrealdb.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/surrealdb/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/surrealdb/ABI-FFI-README.md deleted file mode 100644 index 49f768ff..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/surrealdb/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# SURREALDB ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/surrealdb.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libsurrealdb.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -surrealdb/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── surrealdb.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── surrealdb.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/surrealdb.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "surrealdb.h" - -int main() { - void* handle = surrealdb_init(); - if (!handle) return 1; - - int result = surrealdb_process(handle, 42); - if (result != 0) { - const char* err = surrealdb_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - surrealdb_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lsurrealdb -L./zig-out/lib -``` - -### From Idris2 - -```idris -import SURREALDB.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "surrealdb")] -extern "C" { - fn surrealdb_init() -> *mut std::ffi::c_void; - fn surrealdb_free(handle: *mut std::ffi::c_void); - fn surrealdb_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = surrealdb_init(); - assert!(!handle.is_null()); - - let result = surrealdb_process(handle, 42); - assert_eq!(result, 0); - - surrealdb_free(handle); - } -} -``` - -### From Julia - -```julia -const libsurrealdb = "libsurrealdb" - -function init() - handle = ccall((:surrealdb_init, libsurrealdb), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:surrealdb_process, libsurrealdb), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:surrealdb_free, libsurrealdb), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/surrealdb.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/surrealdb/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/surrealdb/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/surrealdb/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/surrealdb/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/surrealdb/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/surrealdb/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/surrealdb/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/surrealdb/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/surrealdb/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/surrealdb/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/surrealdb/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/surrealdb/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/surrealdb/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/surrealdb/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/surrealdb/README.adoc index d08e1dd2..c2f57df6 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/surrealdb/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/surrealdb/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-surrealdb -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-surrealdb-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-surrealdb-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-surrealdb-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-surrealdb-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://surrealdb.com[SurrealDB]. -**All repos with foreign function interfaces MUST follow this standard:** +Multi-model database. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add surrealdb https://github.com/hyperpolymath/asdf-surrealdb-plugin.git +---- -=== Web Projects +surrealdb: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all surrealdb -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install surrealdb latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global surrealdb latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now surrealdb commands are available +surrealdb --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list surrealdb -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local surrealdb -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall surrealdb ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/surrealdb/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/surrealdb/README.md deleted file mode 100644 index 4f493d5e..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/surrealdb/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-surrealdb - -[![Build](https://github.com/hyperpolymath/asdf-surrealdb-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-surrealdb-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-surrealdb-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-surrealdb-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [SurrealDB](https://surrealdb.com). - -Multi-model database. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add surrealdb https://github.com/hyperpolymath/asdf-surrealdb-plugin.git -``` - -surrealdb: - -```bash -# Show all installable versions -asdf list-all surrealdb - -# Install specific version -asdf install surrealdb latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global surrealdb latest - -# Now surrealdb commands are available -surrealdb --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list surrealdb - -# Set local version for current directory -asdf local surrealdb - -# Uninstall a version -asdf uninstall surrealdb -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/surrealdb/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/surrealdb/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/surrealdb/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/surrealdb/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/surrealdb/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/surrealdb/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/syft/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/syft/ABI-FFI-README.adoc new file mode 100644 index 00000000..4bb11341 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/syft/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== SYFT ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/syft.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libsyft.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +syft/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── syft.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── syft.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/syft.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "syft.h" + +int main() { + void* handle = syft_init(); + if (!handle) return 1; + + int result = syft_process(handle, 42); + if (result != 0) { + const char* err = syft_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + syft_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lsyft -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import SYFT.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "syft")] +extern "C" { + fn syft_init() -> *mut std::ffi::c_void; + fn syft_free(handle: *mut std::ffi::c_void); + fn syft_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = syft_init(); + assert!(!handle.is_null()); + + let result = syft_process(handle, 42); + assert_eq!(result, 0); + + syft_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libsyft = "libsyft" + +function init() + handle = ccall((:syft_init, libsyft), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:syft_process, libsyft), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:syft_free, libsyft), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/syft.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/syft/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/syft/ABI-FFI-README.md deleted file mode 100644 index 8cebba02..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/syft/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# SYFT ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/syft.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libsyft.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -syft/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── syft.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── syft.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/syft.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "syft.h" - -int main() { - void* handle = syft_init(); - if (!handle) return 1; - - int result = syft_process(handle, 42); - if (result != 0) { - const char* err = syft_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - syft_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lsyft -L./zig-out/lib -``` - -### From Idris2 - -```idris -import SYFT.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "syft")] -extern "C" { - fn syft_init() -> *mut std::ffi::c_void; - fn syft_free(handle: *mut std::ffi::c_void); - fn syft_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = syft_init(); - assert!(!handle.is_null()); - - let result = syft_process(handle, 42); - assert_eq!(result, 0); - - syft_free(handle); - } -} -``` - -### From Julia - -```julia -const libsyft = "libsyft" - -function init() - handle = ccall((:syft_init, libsyft), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:syft_process, libsyft), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:syft_free, libsyft), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/syft.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/syft/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/syft/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/syft/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/syft/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/syft/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/syft/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/syft/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/syft/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/syft/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/syft/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/syft/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/syft/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/syft/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/syft/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/syft/README.adoc index d08e1dd2..7be1d677 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/syft/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/syft/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-syft -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-syft-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-syft-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-syft-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-syft-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://anchore.com/syft[Syft]. -**All repos with foreign function interfaces MUST follow this standard:** +SBOM generator. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add syft https://github.com/hyperpolymath/asdf-syft-plugin.git +---- -=== Web Projects +syft: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all syft -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install syft latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global syft latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now syft commands are available +syft --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list syft -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local syft -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall syft ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/syft/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/syft/README.md deleted file mode 100644 index 3edd1438..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/syft/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-syft - -[![Build](https://github.com/hyperpolymath/asdf-syft-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-syft-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-syft-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-syft-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Syft](https://anchore.com/syft). - -SBOM generator. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add syft https://github.com/hyperpolymath/asdf-syft-plugin.git -``` - -syft: - -```bash -# Show all installable versions -asdf list-all syft - -# Install specific version -asdf install syft latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global syft latest - -# Now syft commands are available -syft --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list syft - -# Set local version for current directory -asdf local syft - -# Uninstall a version -asdf uninstall syft -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/syft/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/syft/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/syft/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/syft/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/syft/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/syft/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/taplo/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/taplo/ABI-FFI-README.adoc new file mode 100644 index 00000000..3c49729d --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/taplo/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== TAPLO ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/taplo.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libtaplo.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +taplo/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── taplo.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── taplo.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/taplo.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "taplo.h" + +int main() { + void* handle = taplo_init(); + if (!handle) return 1; + + int result = taplo_process(handle, 42); + if (result != 0) { + const char* err = taplo_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + taplo_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -ltaplo -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import TAPLO.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "taplo")] +extern "C" { + fn taplo_init() -> *mut std::ffi::c_void; + fn taplo_free(handle: *mut std::ffi::c_void); + fn taplo_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = taplo_init(); + assert!(!handle.is_null()); + + let result = taplo_process(handle, 42); + assert_eq!(result, 0); + + taplo_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libtaplo = "libtaplo" + +function init() + handle = ccall((:taplo_init, libtaplo), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:taplo_process, libtaplo), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:taplo_free, libtaplo), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/taplo.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/taplo/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/taplo/ABI-FFI-README.md deleted file mode 100644 index 121d0824..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/taplo/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# TAPLO ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/taplo.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libtaplo.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -taplo/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── taplo.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── taplo.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/taplo.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "taplo.h" - -int main() { - void* handle = taplo_init(); - if (!handle) return 1; - - int result = taplo_process(handle, 42); - if (result != 0) { - const char* err = taplo_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - taplo_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -ltaplo -L./zig-out/lib -``` - -### From Idris2 - -```idris -import TAPLO.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "taplo")] -extern "C" { - fn taplo_init() -> *mut std::ffi::c_void; - fn taplo_free(handle: *mut std::ffi::c_void); - fn taplo_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = taplo_init(); - assert!(!handle.is_null()); - - let result = taplo_process(handle, 42); - assert_eq!(result, 0); - - taplo_free(handle); - } -} -``` - -### From Julia - -```julia -const libtaplo = "libtaplo" - -function init() - handle = ccall((:taplo_init, libtaplo), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:taplo_process, libtaplo), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:taplo_free, libtaplo), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/taplo.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/taplo/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/taplo/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/taplo/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/taplo/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/taplo/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/taplo/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/taplo/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/taplo/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/taplo/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/taplo/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/taplo/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/taplo/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/taplo/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/taplo/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/taplo/README.adoc index d08e1dd2..4eb4acb2 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/taplo/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/taplo/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-taplo -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-taplo-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-taplo-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-taplo-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-taplo-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://taplo.tamasfe.dev[Taplo]. -**All repos with foreign function interfaces MUST follow this standard:** +TOML toolkit. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add taplo https://github.com/hyperpolymath/asdf-taplo-plugin.git +---- -=== Web Projects +taplo: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all taplo -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install taplo latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global taplo latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now taplo commands are available +taplo --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list taplo -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local taplo -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall taplo ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/taplo/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/taplo/README.md deleted file mode 100644 index 68239dab..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/taplo/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-taplo - -[![Build](https://github.com/hyperpolymath/asdf-taplo-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-taplo-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-taplo-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-taplo-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Taplo](https://taplo.tamasfe.dev). - -TOML toolkit. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add taplo https://github.com/hyperpolymath/asdf-taplo-plugin.git -``` - -taplo: - -```bash -# Show all installable versions -asdf list-all taplo - -# Install specific version -asdf install taplo latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global taplo latest - -# Now taplo commands are available -taplo --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list taplo - -# Set local version for current directory -asdf local taplo - -# Uninstall a version -asdf uninstall taplo -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/taplo/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/taplo/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/taplo/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/taplo/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/taplo/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/taplo/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/trivy/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/trivy/ABI-FFI-README.adoc new file mode 100644 index 00000000..291621ba --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/trivy/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== TRIVY ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/trivy.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libtrivy.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +trivy/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── trivy.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── trivy.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/trivy.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "trivy.h" + +int main() { + void* handle = trivy_init(); + if (!handle) return 1; + + int result = trivy_process(handle, 42); + if (result != 0) { + const char* err = trivy_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + trivy_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -ltrivy -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import TRIVY.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "trivy")] +extern "C" { + fn trivy_init() -> *mut std::ffi::c_void; + fn trivy_free(handle: *mut std::ffi::c_void); + fn trivy_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = trivy_init(); + assert!(!handle.is_null()); + + let result = trivy_process(handle, 42); + assert_eq!(result, 0); + + trivy_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libtrivy = "libtrivy" + +function init() + handle = ccall((:trivy_init, libtrivy), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:trivy_process, libtrivy), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:trivy_free, libtrivy), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/trivy.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/trivy/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/trivy/ABI-FFI-README.md deleted file mode 100644 index 3c2bf6e4..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/trivy/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# TRIVY ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/trivy.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libtrivy.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -trivy/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── trivy.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── trivy.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/trivy.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "trivy.h" - -int main() { - void* handle = trivy_init(); - if (!handle) return 1; - - int result = trivy_process(handle, 42); - if (result != 0) { - const char* err = trivy_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - trivy_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -ltrivy -L./zig-out/lib -``` - -### From Idris2 - -```idris -import TRIVY.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "trivy")] -extern "C" { - fn trivy_init() -> *mut std::ffi::c_void; - fn trivy_free(handle: *mut std::ffi::c_void); - fn trivy_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = trivy_init(); - assert!(!handle.is_null()); - - let result = trivy_process(handle, 42); - assert_eq!(result, 0); - - trivy_free(handle); - } -} -``` - -### From Julia - -```julia -const libtrivy = "libtrivy" - -function init() - handle = ccall((:trivy_init, libtrivy), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:trivy_process, libtrivy), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:trivy_free, libtrivy), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/trivy.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/trivy/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/trivy/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/trivy/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/trivy/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/trivy/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/trivy/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/trivy/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/trivy/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/trivy/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/trivy/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/trivy/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/trivy/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/trivy/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/trivy/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/trivy/README.adoc index d08e1dd2..ec6dab41 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/trivy/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/trivy/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-trivy -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-trivy-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-trivy-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-trivy-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-trivy-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://trivy.dev[Trivy]. -**All repos with foreign function interfaces MUST follow this standard:** +Security scanner. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add trivy https://github.com/hyperpolymath/asdf-trivy-plugin.git +---- -=== Web Projects +trivy: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all trivy -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install trivy latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global trivy latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now trivy commands are available +trivy --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list trivy -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local trivy -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall trivy ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/trivy/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/trivy/README.md deleted file mode 100644 index 4084e013..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/trivy/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-trivy - -[![Build](https://github.com/hyperpolymath/asdf-trivy-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-trivy-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-trivy-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-trivy-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Trivy](https://trivy.dev). - -Security scanner. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add trivy https://github.com/hyperpolymath/asdf-trivy-plugin.git -``` - -trivy: - -```bash -# Show all installable versions -asdf list-all trivy - -# Install specific version -asdf install trivy latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global trivy latest - -# Now trivy commands are available -trivy --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list trivy - -# Set local version for current directory -asdf local trivy - -# Uninstall a version -asdf uninstall trivy -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/trivy/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/trivy/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/trivy/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/trivy/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/trivy/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/trivy/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/ui/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/ui/ABI-FFI-README.adoc new file mode 100644 index 00000000..62673536 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/ui/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== UI ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/ui.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libui.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +ui/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── ui.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── ui.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/ui.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "ui.h" + +int main() { + void* handle = ui_init(); + if (!handle) return 1; + + int result = ui_process(handle, 42); + if (result != 0) { + const char* err = ui_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + ui_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lui -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import UI.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "ui")] +extern "C" { + fn ui_init() -> *mut std::ffi::c_void; + fn ui_free(handle: *mut std::ffi::c_void); + fn ui_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = ui_init(); + assert!(!handle.is_null()); + + let result = ui_process(handle, 42); + assert_eq!(result, 0); + + ui_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libui = "libui" + +function init() + handle = ccall((:ui_init, libui), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:ui_process, libui), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:ui_free, libui), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/ui.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/ui/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/ui/ABI-FFI-README.md deleted file mode 100644 index 42a9d25c..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/ui/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# UI ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/ui.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libui.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -ui/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── ui.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── ui.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/ui.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "ui.h" - -int main() { - void* handle = ui_init(); - if (!handle) return 1; - - int result = ui_process(handle, 42); - if (result != 0) { - const char* err = ui_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - ui_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lui -L./zig-out/lib -``` - -### From Idris2 - -```idris -import UI.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "ui")] -extern "C" { - fn ui_init() -> *mut std::ffi::c_void; - fn ui_free(handle: *mut std::ffi::c_void); - fn ui_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = ui_init(); - assert!(!handle.is_null()); - - let result = ui_process(handle, 42); - assert_eq!(result, 0); - - ui_free(handle); - } -} -``` - -### From Julia - -```julia -const libui = "libui" - -function init() - handle = ccall((:ui_init, libui), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:ui_process, libui), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:ui_free, libui), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/ui.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/ui/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/ui/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/ui/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/ui/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/ui/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/ui/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/ui/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/ui/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/ui/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/ui/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/ui/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/ui/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/ui/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/ui/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/ui/README.adoc index 8c19e39d..f52f4ce3 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/ui/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/ui/README.adoc @@ -1,101 +1,53 @@ -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] -image:https://img.shields.io/badge/Philosophy-Palimpsest-indigo.svg[Palimpsest,link="https://github.com/hyperpolymath/palimpsest-license"] +== asdf-ui-plugin +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] +image:https://img.shields.io/badge/Philosophy-Palimpsest-indigo.svg[Palimpsest,link="`https://github.com/hyperpolymath/palimpsest-license`"] -// SPDX-License-Identifier: CC-BY-SA-4.0 -= asdf-ui-plugin +Visual user interface for the https://asdf-vm.com[asdf] version manager +ecosystem. -:toc: macro -:toc-title: Contents -:toclevels: 2 +=== Status -A fully functional **asdf plugin** providing a terminal user interface for managing asdf plugins and versions. +____ +*Note:* This repository is currently a placeholder. Implementation is +pending. +____ -== Status +=== Overview -[NOTE] -==== -**Implementation Complete** - Core plugin functionality is fully working. -==== +`+asdf-ui-plugin+` will provide a graphical interface for managing asdf +plugins and tool versions: -== Features +* *Plugin browser* - Visual discovery of available plugins +* *Version manager* - GUI for installing/switching versions +* *Status dashboard* - Overview of installed tools +* *Update notifications* - Track available updates -* **Version Management**: List, install, and switch between versions -* **Interactive TUI**: Terminal user interface for easy navigation -* **Dashboard View**: Overview of installed plugins and versions -* **Version Selector**: Interactive picker for version switching +=== Technology Stack -== Installation +* *UI Framework*: Tauri 2.0+ (Rust backend + web frontend) +* *Frontend*: AffineScript (type-safe JavaScript) +* *Styling*: TailwindCSS -[source,bash] ----- -asdf plugin add asdf-ui https://github.com/hyperpolymath/asdf-ui-plugin.git -asdf install asdf-ui 1.0.0 -asdf global asdf-ui 1.0.0 ----- +=== Related Projects -== Usage - -[source,bash] ----- -# Launch interactive TUI -asdf-ui - -# Show plugin dashboard -asdf-ui dashboard - -# Interactive version selector -asdf-ui versions - -# Display help -asdf-ui help ----- - -== Components - -[cols="1,3"] +[width="100%",cols="40%,60%",options="header",] |=== -| Component | Description - -| `bin/list-all` -| Lists all available versions - -| `bin/download` -| Downloads specified version +|Project |Relationship +|https://github.com/hyperpolymath/asdf-metaiconic-plugin[asdf-metaiconic-plugin] +|Metadata provider -| `bin/install` -| Installs version and creates asdf-ui binary - -| `lib/utils.bash` -| Core utility functions and TUI implementation - -| `.github/workflows/ci.yml` -| Continuous integration with ShellCheck - -| `.github/workflows/mirror.yml` -| Hub-and-spoke mirroring to GitLab, Codeberg, Bitbucket - -| `.github/workflows/instant-sync.yml` -| Automatic forge propagation on push/release - -| `.claude/CLAUDE.md` -| Hyperpolymath development standards (language policy) +|https://github.com/hyperpolymath/asdf-security-plugin[asdf-security-plugin] +|Security layer |=== -See link:ROADMAP.adoc[ROADMAP.adoc] for development history and future plans. - -== Development Standards - -This project follows the **Hyperpolymath Language Policy**: - -* *Primary*: AffineScript, Rust, Deno -* *Mobile*: Tauri 2.0+ or Dioxus (no Kotlin/Swift) -* *Backend*: Gleam (BEAM or JS target) -* *Config*: Nickel, Guile Scheme -* *Package Management*: Guix (primary), Guix (fallback) +=== License -See `.claude/CLAUDE.md` for full policy details. +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -== License +''''' -MPL-2.0 +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/ui/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/ui/README.md deleted file mode 100644 index 77018b32..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/ui/README.md +++ /dev/null @@ -1,40 +0,0 @@ -# asdf-ui-plugin - -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] -image:https://img.shields.io/badge/Philosophy-Palimpsest-indigo.svg[Palimpsest,link="https://github.com/hyperpolymath/palimpsest-license"] - -Visual user interface for the [asdf](https://asdf-vm.com) version manager ecosystem. - -## Status - -> **Note:** This repository is currently a placeholder. Implementation is pending. - -## Overview - -`asdf-ui-plugin` will provide a graphical interface for managing asdf plugins and tool versions: - -- **Plugin browser** - Visual discovery of available plugins -- **Version manager** - GUI for installing/switching versions -- **Status dashboard** - Overview of installed tools -- **Update notifications** - Track available updates - -## Technology Stack - -- **UI Framework**: Tauri 2.0+ (Rust backend + web frontend) -- **Frontend**: AffineScript (type-safe JavaScript) -- **Styling**: TailwindCSS - -## Related Projects - -| Project | Relationship | -|---------|--------------| -| [asdf-metaiconic-plugin](https://github.com/hyperpolymath/asdf-metaiconic-plugin) | Metadata provider | -| [asdf-security-plugin](https://github.com/hyperpolymath/asdf-security-plugin) | Security layer | - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/ui/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/ui/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/ui/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/ui/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/ui/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/ui/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/varnish/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/varnish/ABI-FFI-README.adoc new file mode 100644 index 00000000..be2b48d7 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/varnish/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== VARNISH ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/varnish.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libvarnish.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +varnish/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── varnish.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── varnish.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/varnish.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "varnish.h" + +int main() { + void* handle = varnish_init(); + if (!handle) return 1; + + int result = varnish_process(handle, 42); + if (result != 0) { + const char* err = varnish_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + varnish_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lvarnish -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import VARNISH.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "varnish")] +extern "C" { + fn varnish_init() -> *mut std::ffi::c_void; + fn varnish_free(handle: *mut std::ffi::c_void); + fn varnish_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = varnish_init(); + assert!(!handle.is_null()); + + let result = varnish_process(handle, 42); + assert_eq!(result, 0); + + varnish_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libvarnish = "libvarnish" + +function init() + handle = ccall((:varnish_init, libvarnish), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:varnish_process, libvarnish), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:varnish_free, libvarnish), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/varnish.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/varnish/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/varnish/ABI-FFI-README.md deleted file mode 100644 index db34442f..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/varnish/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# VARNISH ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/varnish.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libvarnish.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -varnish/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── varnish.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── varnish.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/varnish.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "varnish.h" - -int main() { - void* handle = varnish_init(); - if (!handle) return 1; - - int result = varnish_process(handle, 42); - if (result != 0) { - const char* err = varnish_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - varnish_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lvarnish -L./zig-out/lib -``` - -### From Idris2 - -```idris -import VARNISH.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "varnish")] -extern "C" { - fn varnish_init() -> *mut std::ffi::c_void; - fn varnish_free(handle: *mut std::ffi::c_void); - fn varnish_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = varnish_init(); - assert!(!handle.is_null()); - - let result = varnish_process(handle, 42); - assert_eq!(result, 0); - - varnish_free(handle); - } -} -``` - -### From Julia - -```julia -const libvarnish = "libvarnish" - -function init() - handle = ccall((:varnish_init, libvarnish), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:varnish_process, libvarnish), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:varnish_free, libvarnish), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/varnish.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/varnish/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/varnish/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/varnish/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/varnish/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/varnish/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/varnish/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/varnish/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/varnish/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/varnish/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/varnish/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/varnish/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/varnish/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/varnish/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/varnish/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/varnish/README.adoc index d08e1dd2..b2d14bf4 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/varnish/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/varnish/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-varnish -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-varnish-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-varnish-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-varnish-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-varnish-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://varnish-cache.org[Varnish +Cache]. -**All repos with foreign function interfaces MUST follow this standard:** +HTTP accelerator. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add varnish https://github.com/hyperpolymath/asdf-varnish-plugin.git +---- -=== Web Projects +varnish: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all varnish -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install varnish latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global varnish latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now varnish commands are available +varnish --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list varnish -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local varnish -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall varnish ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/varnish/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/varnish/README.md deleted file mode 100644 index 4ee2b09b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/varnish/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-varnish - -[![Build](https://github.com/hyperpolymath/asdf-varnish-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-varnish-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-varnish-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-varnish-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Varnish Cache](https://varnish-cache.org). - -HTTP accelerator. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add varnish https://github.com/hyperpolymath/asdf-varnish-plugin.git -``` - -varnish: - -```bash -# Show all installable versions -asdf list-all varnish - -# Install specific version -asdf install varnish latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global varnish latest - -# Now varnish commands are available -varnish --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list varnish - -# Set local version for current directory -asdf local varnish - -# Uninstall a version -asdf uninstall varnish -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/varnish/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/varnish/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/varnish/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/varnish/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/varnish/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/varnish/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/virtuoso/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/virtuoso/ABI-FFI-README.adoc new file mode 100644 index 00000000..c71acab7 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/virtuoso/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== VIRTUOSO ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/virtuoso.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libvirtuoso.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +virtuoso/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── virtuoso.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── virtuoso.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/virtuoso.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "virtuoso.h" + +int main() { + void* handle = virtuoso_init(); + if (!handle) return 1; + + int result = virtuoso_process(handle, 42); + if (result != 0) { + const char* err = virtuoso_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + virtuoso_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lvirtuoso -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import VIRTUOSO.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "virtuoso")] +extern "C" { + fn virtuoso_init() -> *mut std::ffi::c_void; + fn virtuoso_free(handle: *mut std::ffi::c_void); + fn virtuoso_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = virtuoso_init(); + assert!(!handle.is_null()); + + let result = virtuoso_process(handle, 42); + assert_eq!(result, 0); + + virtuoso_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libvirtuoso = "libvirtuoso" + +function init() + handle = ccall((:virtuoso_init, libvirtuoso), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:virtuoso_process, libvirtuoso), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:virtuoso_free, libvirtuoso), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/virtuoso.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/virtuoso/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/virtuoso/ABI-FFI-README.md deleted file mode 100644 index 4753369a..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/virtuoso/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# VIRTUOSO ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/virtuoso.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libvirtuoso.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -virtuoso/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── virtuoso.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── virtuoso.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/virtuoso.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "virtuoso.h" - -int main() { - void* handle = virtuoso_init(); - if (!handle) return 1; - - int result = virtuoso_process(handle, 42); - if (result != 0) { - const char* err = virtuoso_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - virtuoso_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lvirtuoso -L./zig-out/lib -``` - -### From Idris2 - -```idris -import VIRTUOSO.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "virtuoso")] -extern "C" { - fn virtuoso_init() -> *mut std::ffi::c_void; - fn virtuoso_free(handle: *mut std::ffi::c_void); - fn virtuoso_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = virtuoso_init(); - assert!(!handle.is_null()); - - let result = virtuoso_process(handle, 42); - assert_eq!(result, 0); - - virtuoso_free(handle); - } -} -``` - -### From Julia - -```julia -const libvirtuoso = "libvirtuoso" - -function init() - handle = ccall((:virtuoso_init, libvirtuoso), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:virtuoso_process, libvirtuoso), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:virtuoso_free, libvirtuoso), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/virtuoso.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/virtuoso/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/virtuoso/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/virtuoso/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/virtuoso/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/virtuoso/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/virtuoso/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/virtuoso/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/virtuoso/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/virtuoso/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/virtuoso/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/virtuoso/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/virtuoso/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/virtuoso/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/virtuoso/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/virtuoso/README.adoc index d08e1dd2..4644e8f3 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/virtuoso/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/virtuoso/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-virtuoso -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-virtuoso-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-virtuoso-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-virtuoso-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-virtuoso-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://virtuoso.openlinksw.com[Virtuoso]. -**All repos with foreign function interfaces MUST follow this standard:** +RDF triple store. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add virtuoso https://github.com/hyperpolymath/asdf-virtuoso-plugin.git +---- -=== Web Projects +virtuoso: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all virtuoso -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install virtuoso latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global virtuoso latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now virtuoso commands are available +virtuoso --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list virtuoso -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local virtuoso -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall virtuoso ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/virtuoso/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/virtuoso/README.md deleted file mode 100644 index 211e1f63..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/virtuoso/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-virtuoso - -[![Build](https://github.com/hyperpolymath/asdf-virtuoso-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-virtuoso-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-virtuoso-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-virtuoso-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Virtuoso](https://virtuoso.openlinksw.com). - -RDF triple store. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add virtuoso https://github.com/hyperpolymath/asdf-virtuoso-plugin.git -``` - -virtuoso: - -```bash -# Show all installable versions -asdf list-all virtuoso - -# Install specific version -asdf install virtuoso latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global virtuoso latest - -# Now virtuoso commands are available -virtuoso --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list virtuoso - -# Set local version for current directory -asdf local virtuoso - -# Uninstall a version -asdf uninstall virtuoso -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/virtuoso/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/virtuoso/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/virtuoso/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/virtuoso/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/virtuoso/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/virtuoso/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/vlang/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/vlang/ABI-FFI-README.adoc new file mode 100644 index 00000000..a21b7a8b --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/vlang/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== VLANG ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/vlang.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libvlang.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +vlang/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── vlang.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── vlang.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/vlang.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "vlang.h" + +int main() { + void* handle = vlang_init(); + if (!handle) return 1; + + int result = vlang_process(handle, 42); + if (result != 0) { + const char* err = vlang_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + vlang_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lvlang -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import VLANG.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "vlang")] +extern "C" { + fn vlang_init() -> *mut std::ffi::c_void; + fn vlang_free(handle: *mut std::ffi::c_void); + fn vlang_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = vlang_init(); + assert!(!handle.is_null()); + + let result = vlang_process(handle, 42); + assert_eq!(result, 0); + + vlang_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libvlang = "libvlang" + +function init() + handle = ccall((:vlang_init, libvlang), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:vlang_process, libvlang), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:vlang_free, libvlang), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/vlang.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/vlang/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/vlang/ABI-FFI-README.md deleted file mode 100644 index 2ce05e85..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/vlang/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# VLANG ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/vlang.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libvlang.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -vlang/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── vlang.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── vlang.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/vlang.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "vlang.h" - -int main() { - void* handle = vlang_init(); - if (!handle) return 1; - - int result = vlang_process(handle, 42); - if (result != 0) { - const char* err = vlang_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - vlang_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lvlang -L./zig-out/lib -``` - -### From Idris2 - -```idris -import VLANG.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "vlang")] -extern "C" { - fn vlang_init() -> *mut std::ffi::c_void; - fn vlang_free(handle: *mut std::ffi::c_void); - fn vlang_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = vlang_init(); - assert!(!handle.is_null()); - - let result = vlang_process(handle, 42); - assert_eq!(result, 0); - - vlang_free(handle); - } -} -``` - -### From Julia - -```julia -const libvlang = "libvlang" - -function init() - handle = ccall((:vlang_init, libvlang), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:vlang_process, libvlang), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:vlang_free, libvlang), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/vlang.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/vlang/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/vlang/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/vlang/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/vlang/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/vlang/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/vlang/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/vlang/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/vlang/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/vlang/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/vlang/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/vlang/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/vlang/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/vlang/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/vlang/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/vlang/README.adoc index d08e1dd2..e0d2a18f 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/vlang/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/vlang/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-vlang -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-vlang-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-vlang-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-vlang-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-vlang-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://vlang.io[V]. -**All repos with foreign function interfaces MUST follow this standard:** +Simple fast language. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add vlang https://github.com/hyperpolymath/asdf-vlang-plugin.git +---- -=== Web Projects +vlang: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all vlang -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install vlang latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global vlang latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now vlang commands are available +vlang --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list vlang -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local vlang -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall vlang ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/vlang/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/vlang/README.md deleted file mode 100644 index 06f2397c..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/vlang/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-vlang - -[![Build](https://github.com/hyperpolymath/asdf-vlang-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-vlang-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-vlang-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-vlang-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [V](https://vlang.io). - -Simple fast language. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add vlang https://github.com/hyperpolymath/asdf-vlang-plugin.git -``` - -vlang: - -```bash -# Show all installable versions -asdf list-all vlang - -# Install specific version -asdf install vlang latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global vlang latest - -# Now vlang commands are available -vlang --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list vlang - -# Set local version for current directory -asdf local vlang - -# Uninstall a version -asdf uninstall vlang -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/vlang/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/vlang/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/vlang/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/vlang/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/vlang/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/vlang/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/yj/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/yj/ABI-FFI-README.adoc new file mode 100644 index 00000000..af3fca8a --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/yj/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== YJ ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/yj.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libyj.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +yj/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── yj.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── yj.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/yj.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "yj.h" + +int main() { + void* handle = yj_init(); + if (!handle) return 1; + + int result = yj_process(handle, 42); + if (result != 0) { + const char* err = yj_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + yj_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lyj -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import YJ.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "yj")] +extern "C" { + fn yj_init() -> *mut std::ffi::c_void; + fn yj_free(handle: *mut std::ffi::c_void); + fn yj_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = yj_init(); + assert!(!handle.is_null()); + + let result = yj_process(handle, 42); + assert_eq!(result, 0); + + yj_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libyj = "libyj" + +function init() + handle = ccall((:yj_init, libyj), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:yj_process, libyj), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:yj_free, libyj), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/yj.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/yj/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/yj/ABI-FFI-README.md deleted file mode 100644 index bd5df5c7..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/yj/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# YJ ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/yj.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libyj.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -yj/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── yj.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── yj.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/yj.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "yj.h" - -int main() { - void* handle = yj_init(); - if (!handle) return 1; - - int result = yj_process(handle, 42); - if (result != 0) { - const char* err = yj_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - yj_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lyj -L./zig-out/lib -``` - -### From Idris2 - -```idris -import YJ.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "yj")] -extern "C" { - fn yj_init() -> *mut std::ffi::c_void; - fn yj_free(handle: *mut std::ffi::c_void); - fn yj_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = yj_init(); - assert!(!handle.is_null()); - - let result = yj_process(handle, 42); - assert_eq!(result, 0); - - yj_free(handle); - } -} -``` - -### From Julia - -```julia -const libyj = "libyj" - -function init() - handle = ccall((:yj_init, libyj), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:yj_process, libyj), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:yj_free, libyj), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/yj.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/yj/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/yj/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/yj/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/yj/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/yj/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/yj/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/yj/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/yj/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/yj/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/yj/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/yj/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/yj/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/yj/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/yj/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/yj/README.adoc index d08e1dd2..692d1bf4 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/yj/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/yj/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-yj -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-yj-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-yj-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-yj-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-yj-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://github.com/sclevine/yj[yj]. -**All repos with foreign function interfaces MUST follow this standard:** +YAML/JSON/TOML converter. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add yj https://github.com/hyperpolymath/asdf-yj-plugin.git +---- -=== Web Projects +yj: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all yj -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install yj latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global yj latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now yj commands are available +yj --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list yj -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local yj -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall yj ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/yj/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/yj/README.md deleted file mode 100644 index a99453a7..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/yj/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-yj - -[![Build](https://github.com/hyperpolymath/asdf-yj-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-yj-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-yj-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-yj-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [yj](https://github.com/sclevine/yj). - -YAML/JSON/TOML converter. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add yj https://github.com/hyperpolymath/asdf-yj-plugin.git -``` - -yj: - -```bash -# Show all installable versions -asdf list-all yj - -# Install specific version -asdf install yj latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global yj latest - -# Now yj commands are available -yj --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list yj - -# Set local version for current directory -asdf local yj - -# Uninstall a version -asdf uninstall yj -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/yj/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/yj/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/yj/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/yj/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/yj/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/yj/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/yq/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/yq/ABI-FFI-README.adoc new file mode 100644 index 00000000..3aec672a --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/yq/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== YQ ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/yq.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libyq.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +yq/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── yq.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── yq.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/yq.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "yq.h" + +int main() { + void* handle = yq_init(); + if (!handle) return 1; + + int result = yq_process(handle, 42); + if (result != 0) { + const char* err = yq_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + yq_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lyq -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import YQ.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "yq")] +extern "C" { + fn yq_init() -> *mut std::ffi::c_void; + fn yq_free(handle: *mut std::ffi::c_void); + fn yq_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = yq_init(); + assert!(!handle.is_null()); + + let result = yq_process(handle, 42); + assert_eq!(result, 0); + + yq_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libyq = "libyq" + +function init() + handle = ccall((:yq_init, libyq), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:yq_process, libyq), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:yq_free, libyq), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/yq.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/yq/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/yq/ABI-FFI-README.md deleted file mode 100644 index 1789a0ea..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/yq/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# YQ ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/yq.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libyq.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -yq/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── yq.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── yq.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/yq.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "yq.h" - -int main() { - void* handle = yq_init(); - if (!handle) return 1; - - int result = yq_process(handle, 42); - if (result != 0) { - const char* err = yq_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - yq_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lyq -L./zig-out/lib -``` - -### From Idris2 - -```idris -import YQ.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "yq")] -extern "C" { - fn yq_init() -> *mut std::ffi::c_void; - fn yq_free(handle: *mut std::ffi::c_void); - fn yq_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = yq_init(); - assert!(!handle.is_null()); - - let result = yq_process(handle, 42); - assert_eq!(result, 0); - - yq_free(handle); - } -} -``` - -### From Julia - -```julia -const libyq = "libyq" - -function init() - handle = ccall((:yq_init, libyq), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:yq_process, libyq), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:yq_free, libyq), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/yq.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/yq/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/yq/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/yq/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/yq/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/yq/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/yq/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/yq/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/yq/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/yq/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/yq/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/yq/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/yq/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/yq/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/yq/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/yq/README.adoc index d08e1dd2..0cc876bf 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/yq/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/yq/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-yq -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-yq-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-yq-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-yq-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-yq-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://mikefarah.gitbook.io/yq[yq]. -**All repos with foreign function interfaces MUST follow this standard:** +YAML processor. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add yq https://github.com/hyperpolymath/asdf-yq-plugin.git +---- -=== Web Projects +yq: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all yq -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install yq latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global yq latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now yq commands are available +yq --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list yq -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local yq -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall yq ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/yq/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/yq/README.md deleted file mode 100644 index 32b85db9..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/yq/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-yq - -[![Build](https://github.com/hyperpolymath/asdf-yq-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-yq-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-yq-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-yq-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [yq](https://mikefarah.gitbook.io/yq). - -YAML processor. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add yq https://github.com/hyperpolymath/asdf-yq-plugin.git -``` - -yq: - -```bash -# Show all installable versions -asdf list-all yq - -# Install specific version -asdf install yq latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global yq latest - -# Now yq commands are available -yq --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list yq - -# Set local version for current directory -asdf local yq - -# Uninstall a version -asdf uninstall yq -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/yq/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/yq/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/yq/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/yq/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/yq/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/yq/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/zig/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/zig/ABI-FFI-README.adoc new file mode 100644 index 00000000..a3b3b061 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/zig/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== ZIG ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/zig.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libzig.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +zig/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── zig.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── zig.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/zig.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "zig.h" + +int main() { + void* handle = zig_init(); + if (!handle) return 1; + + int result = zig_process(handle, 42); + if (result != 0) { + const char* err = zig_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + zig_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lzig -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import ZIG.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "zig")] +extern "C" { + fn zig_init() -> *mut std::ffi::c_void; + fn zig_free(handle: *mut std::ffi::c_void); + fn zig_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = zig_init(); + assert!(!handle.is_null()); + + let result = zig_process(handle, 42); + assert_eq!(result, 0); + + zig_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libzig = "libzig" + +function init() + handle = ccall((:zig_init, libzig), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:zig_process, libzig), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:zig_free, libzig), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/zig.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/zig/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/zig/ABI-FFI-README.md deleted file mode 100644 index 32bf6cd4..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/zig/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# ZIG ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/zig.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libzig.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -zig/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── zig.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── zig.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/zig.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "zig.h" - -int main() { - void* handle = zig_init(); - if (!handle) return 1; - - int result = zig_process(handle, 42); - if (result != 0) { - const char* err = zig_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - zig_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lzig -L./zig-out/lib -``` - -### From Idris2 - -```idris -import ZIG.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "zig")] -extern "C" { - fn zig_init() -> *mut std::ffi::c_void; - fn zig_free(handle: *mut std::ffi::c_void); - fn zig_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = zig_init(); - assert!(!handle.is_null()); - - let result = zig_process(handle, 42); - assert_eq!(result, 0); - - zig_free(handle); - } -} -``` - -### From Julia - -```julia -const libzig = "libzig" - -function init() - handle = ccall((:zig_init, libzig), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:zig_process, libzig), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:zig_free, libzig), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/zig.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/zig/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/zig/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..be3a3fca --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/zig/CODE_OF_CONDUCT.adoc @@ -0,0 +1,23 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We as members, contributors, and leaders pledge to make participation in +our community a harassment-free experience for everyone. + +=== Our Standards + +Examples of behavior that contributes to a positive environment: * Using +welcoming and inclusive language * Being respectful of differing +viewpoints and experiences * Gracefully accepting constructive criticism +* Focusing on what is best for the community + +=== Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may +be reported to the project maintainers. + +=== Attribution + +This Code of Conduct is adapted from the Contributor Covenant, version +2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/zig/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/zig/CODE_OF_CONDUCT.md deleted file mode 100644 index 7d02d33d..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/zig/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,23 +0,0 @@ -# Contributor Covenant Code of Conduct - -## Our Pledge - -We as members, contributors, and leaders pledge to make participation in our -community a harassment-free experience for everyone. - -## Our Standards - -Examples of behavior that contributes to a positive environment: -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community - -## Enforcement - -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported to the project maintainers. - -## Attribution - -This Code of Conduct is adapted from the Contributor Covenant, version 2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/zig/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/zig/CONTRIBUTING.adoc index 5b225c9b..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/zig/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/zig/CONTRIBUTING.adoc @@ -1,30 +1,109 @@ -= Contributing +== Clone the repository -Thank you for your interest in contributing! +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -== Quick Start +== Using Guix (recommended for reproducibility) -1. Fork the repository -2. Create a feature branch -3. Make your changes -4. Run tests: `asdf plugin test zig .` -5. Submit a pull request +guix develop -== Code Style +== Or using toolbox/distrobox -* Use ShellCheck for linting -* Follow existing code patterns -* Add SPDX headers to new files +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -== Testing +== Verify setup -Test your changes with: +just check # or: cargo check / mix compile / etc. just test # Run test +suite -[source,bash] ----- -asdf plugin test zig . --asdf-tool-version latest ----- +.... -== License +### Repository Structure +.... -Contributions are licensed under MPL-2.0. +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/zig/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/zig/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/zig/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/zig/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/zig/SECURITY.adoc new file mode 100644 index 00000000..7f2e3358 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/zig/SECURITY.adoc @@ -0,0 +1,20 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|latest |:white_check_mark: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities via GitHub Security Advisories. + +[arabic] +. Go to the Security tab of this repository +. Click "`Report a vulnerability`" +. Provide details of the vulnerability + +We will respond within 48 hours and work with you to address the issue. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/zig/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/zig/SECURITY.md deleted file mode 100644 index a791a890..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/zig/SECURITY.md +++ /dev/null @@ -1,17 +0,0 @@ -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| latest | :white_check_mark: | - -## Reporting a Vulnerability - -Please report security vulnerabilities via GitHub Security Advisories. - -1. Go to the Security tab of this repository -2. Click "Report a vulnerability" -3. Provide details of the vulnerability - -We will respond within 48 hours and work with you to address the issue. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/zola/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/zola/ABI-FFI-README.adoc new file mode 100644 index 00000000..f87c41f3 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/zola/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== ZOLA ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/zola.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libzola.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +zola/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── zola.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── zola.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/zola.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "zola.h" + +int main() { + void* handle = zola_init(); + if (!handle) return 1; + + int result = zola_process(handle, 42); + if (result != 0) { + const char* err = zola_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + zola_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lzola -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import ZOLA.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "zola")] +extern "C" { + fn zola_init() -> *mut std::ffi::c_void; + fn zola_free(handle: *mut std::ffi::c_void); + fn zola_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = zola_init(); + assert!(!handle.is_null()); + + let result = zola_process(handle, 42); + assert_eq!(result, 0); + + zola_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libzola = "libzola" + +function init() + handle = ccall((:zola_init, libzola), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:zola_process, libzola), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:zola_free, libzola), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/zola.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/zola/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-collection/plugins/zola/ABI-FFI-README.md deleted file mode 100644 index 18a76fd1..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/zola/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# ZOLA ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/zola.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libzola.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -zola/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── zola.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── zola.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/zola.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "zola.h" - -int main() { - void* handle = zola_init(); - if (!handle) return 1; - - int result = zola_process(handle, 42); - if (result != 0) { - const char* err = zola_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - zola_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lzola -L./zig-out/lib -``` - -### From Idris2 - -```idris -import ZOLA.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "zola")] -extern "C" { - fn zola_init() -> *mut std::ffi::c_void; - fn zola_free(handle: *mut std::ffi::c_void); - fn zola_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = zola_init(); - assert!(!handle.is_null()); - - let result = zola_process(handle, 42); - assert_eq!(result, 0); - - zola_free(handle); - } -} -``` - -### From Julia - -```julia -const libzola = "libzola" - -function init() - handle = ccall((:zola_init, libzola), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:zola_process, libzola), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:zola_free, libzola), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/zola.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/zola/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/zola/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/zola/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/zola/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-collection/plugins/zola/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/zola/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/zola/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/zola/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/zola/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/zola/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/zola/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-collection/plugins/zola/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/zola/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/zola/README.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/zola/README.adoc index d08e1dd2..f0cbbf45 100644 --- a/asdf-augmenters/asdf-plugin-collection/plugins/zola/README.adoc +++ b/asdf-augmenters/asdf-plugin-collection/plugins/zola/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-zola -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-zola-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-zola-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-zola-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-zola-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://www.getzola.org[Zola]. -**All repos with foreign function interfaces MUST follow this standard:** +Fast static site generator. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add zola https://github.com/hyperpolymath/asdf-zola-plugin.git +---- -=== Web Projects +zola: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all zola -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install zola latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global zola latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now zola commands are available +zola --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list zola -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local zola -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall zola ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/zola/README.md b/asdf-augmenters/asdf-plugin-collection/plugins/zola/README.md deleted file mode 100644 index eb94b490..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/zola/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-zola - -[![Build](https://github.com/hyperpolymath/asdf-zola-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-zola-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-zola-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-zola-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Zola](https://www.getzola.org). - -Fast static site generator. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add zola https://github.com/hyperpolymath/asdf-zola-plugin.git -``` - -zola: - -```bash -# Show all installable versions -asdf list-all zola - -# Install specific version -asdf install zola latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global zola latest - -# Now zola commands are available -zola --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list zola - -# Set local version for current directory -asdf local zola - -# Uninstall a version -asdf uninstall zola -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/zola/SECURITY.adoc b/asdf-augmenters/asdf-plugin-collection/plugins/zola/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-collection/plugins/zola/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-collection/plugins/zola/SECURITY.md b/asdf-augmenters/asdf-plugin-collection/plugins/zola/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-plugin-collection/plugins/zola/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-configurator/ABI-FFI-README.adoc b/asdf-augmenters/asdf-plugin-configurator/ABI-FFI-README.adoc new file mode 100644 index 00000000..ba1d2157 --- /dev/null +++ b/asdf-augmenters/asdf-plugin-configurator/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== PLUGIN_CONFIGURATOR ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/plugin-configurator.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libplugin-configurator.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +plugin-configurator/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── plugin-configurator.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── plugin-configurator.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/plugin-configurator.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "plugin-configurator.h" + +int main() { + void* handle = plugin-configurator_init(); + if (!handle) return 1; + + int result = plugin-configurator_process(handle, 42); + if (result != 0) { + const char* err = plugin-configurator_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + plugin-configurator_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lplugin-configurator -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import PLUGIN_CONFIGURATOR.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "plugin-configurator")] +extern "C" { + fn plugin-configurator_init() -> *mut std::ffi::c_void; + fn plugin-configurator_free(handle: *mut std::ffi::c_void); + fn plugin-configurator_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = plugin-configurator_init(); + assert!(!handle.is_null()); + + let result = plugin-configurator_process(handle, 42); + assert_eq!(result, 0); + + plugin-configurator_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libplugin-configurator = "libplugin-configurator" + +function init() + handle = ccall((:plugin-configurator_init, libplugin-configurator), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:plugin-configurator_process, libplugin-configurator), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:plugin-configurator_free, libplugin-configurator), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/plugin-configurator.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-plugin-configurator/ABI-FFI-README.md b/asdf-augmenters/asdf-plugin-configurator/ABI-FFI-README.md deleted file mode 100644 index af878353..00000000 --- a/asdf-augmenters/asdf-plugin-configurator/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# PLUGIN_CONFIGURATOR ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/plugin-configurator.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libplugin-configurator.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -plugin-configurator/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── plugin-configurator.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── plugin-configurator.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/plugin-configurator.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "plugin-configurator.h" - -int main() { - void* handle = plugin-configurator_init(); - if (!handle) return 1; - - int result = plugin-configurator_process(handle, 42); - if (result != 0) { - const char* err = plugin-configurator_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - plugin-configurator_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lplugin-configurator -L./zig-out/lib -``` - -### From Idris2 - -```idris -import PLUGIN_CONFIGURATOR.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "plugin-configurator")] -extern "C" { - fn plugin-configurator_init() -> *mut std::ffi::c_void; - fn plugin-configurator_free(handle: *mut std::ffi::c_void); - fn plugin-configurator_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = plugin-configurator_init(); - assert!(!handle.is_null()); - - let result = plugin-configurator_process(handle, 42); - assert_eq!(result, 0); - - plugin-configurator_free(handle); - } -} -``` - -### From Julia - -```julia -const libplugin-configurator = "libplugin-configurator" - -function init() - handle = ccall((:plugin-configurator_init, libplugin-configurator), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:plugin-configurator_process, libplugin-configurator), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:plugin-configurator_free, libplugin-configurator), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/plugin-configurator.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-plugin-configurator/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-plugin-configurator/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-plugin-configurator/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-plugin-configurator/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-plugin-configurator/CODE_OF_CONDUCT.md deleted file mode 100644 index caeda1c6..00000000 --- a/asdf-augmenters/asdf-plugin-configurator/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,27 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. - diff --git a/asdf-augmenters/asdf-plugin-configurator/CONTRIBUTING.adoc b/asdf-augmenters/asdf-plugin-configurator/CONTRIBUTING.adoc index eb045d61..084ee525 100644 --- a/asdf-augmenters/asdf-plugin-configurator/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-plugin-configurator/CONTRIBUTING.adoc @@ -1,20 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-plugin-configurator/CONTRIBUTING.md b/asdf-augmenters/asdf-plugin-configurator/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-plugin-configurator/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-plugin-configurator/SECURITY.adoc b/asdf-augmenters/asdf-plugin-configurator/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-plugin-configurator/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-plugin-configurator/SECURITY.md b/asdf-augmenters/asdf-plugin-configurator/SECURITY.md deleted file mode 100644 index 159a0b7a..00000000 --- a/asdf-augmenters/asdf-plugin-configurator/SECURITY.md +++ /dev/null @@ -1,25 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection - diff --git a/asdf-augmenters/asdf-security-plugin/ABI-FFI-README.adoc b/asdf-augmenters/asdf-security-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..a80ffdfd --- /dev/null +++ b/asdf-augmenters/asdf-security-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== SECURITY ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/security.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libsecurity.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +security/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── security.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── security.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/security.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "security.h" + +int main() { + void* handle = security_init(); + if (!handle) return 1; + + int result = security_process(handle, 42); + if (result != 0) { + const char* err = security_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + security_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lsecurity -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import SECURITY.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "security")] +extern "C" { + fn security_init() -> *mut std::ffi::c_void; + fn security_free(handle: *mut std::ffi::c_void); + fn security_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = security_init(); + assert!(!handle.is_null()); + + let result = security_process(handle, 42); + assert_eq!(result, 0); + + security_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libsecurity = "libsecurity" + +function init() + handle = ccall((:security_init, libsecurity), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:security_process, libsecurity), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:security_free, libsecurity), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/security.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-security-plugin/ABI-FFI-README.md b/asdf-augmenters/asdf-security-plugin/ABI-FFI-README.md deleted file mode 100644 index 28dfe6f4..00000000 --- a/asdf-augmenters/asdf-security-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# SECURITY ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/security.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libsecurity.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -security/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── security.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── security.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/security.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "security.h" - -int main() { - void* handle = security_init(); - if (!handle) return 1; - - int result = security_process(handle, 42); - if (result != 0) { - const char* err = security_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - security_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lsecurity -L./zig-out/lib -``` - -### From Idris2 - -```idris -import SECURITY.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "security")] -extern "C" { - fn security_init() -> *mut std::ffi::c_void; - fn security_free(handle: *mut std::ffi::c_void); - fn security_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = security_init(); - assert!(!handle.is_null()); - - let result = security_process(handle, 42); - assert_eq!(result, 0); - - security_free(handle); - } -} -``` - -### From Julia - -```julia -const libsecurity = "libsecurity" - -function init() - handle = ccall((:security_init, libsecurity), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:security_process, libsecurity), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:security_free, libsecurity), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/security.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-security-plugin/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-security-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-security-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-security-plugin/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-security-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index caeda1c6..00000000 --- a/asdf-augmenters/asdf-security-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,27 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. - diff --git a/asdf-augmenters/asdf-security-plugin/CONTRIBUTING.adoc b/asdf-augmenters/asdf-security-plugin/CONTRIBUTING.adoc index eb045d61..084ee525 100644 --- a/asdf-augmenters/asdf-security-plugin/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-security-plugin/CONTRIBUTING.adoc @@ -1,20 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-security-plugin/CONTRIBUTING.md b/asdf-augmenters/asdf-security-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-security-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-security-plugin/README.adoc b/asdf-augmenters/asdf-security-plugin/README.adoc index acbc80f7..92df847a 100644 --- a/asdf-augmenters/asdf-security-plugin/README.adoc +++ b/asdf-augmenters/asdf-security-plugin/README.adoc @@ -1,122 +1,54 @@ -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] -image:https://img.shields.io/badge/Philosophy-Palimpsest-indigo.svg[Palimpsest,link="https://github.com/hyperpolymath/palimpsest-license"] +== asdf-security-plugin +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] +image:https://img.shields.io/badge/Philosophy-Palimpsest-indigo.svg[Palimpsest,link="`https://github.com/hyperpolymath/palimpsest-license`"] -// SPDX-License-Identifier: CC-BY-SA-4.0 -= asdf-security-plugin +Security-focused extensions and policies for the +https://asdf-vm.com[asdf] version manager ecosystem. -:toc: macro -:toc-title: Contents -:toclevels: 2 +=== Status -**Security scanning plugin for asdf version manager** +____ +*Note:* This repository is currently a project skeleton. Implementation +is pending. +____ -toc::[] +=== Overview -== Status +`+asdf-security-plugin+` provides security tooling and policies for the +asdf plugin ecosystem: -[NOTE] -==== -This plugin is *fully functional* at version 1.0.0. -==== +* *Security scanning* - Vulnerability detection for installed tools +* *Policy enforcement* - Ensure only approved versions are installed +* *Audit logging* - Track version changes and installations +* *Signature verification* - Validate tool authenticity -== Overview +=== Planned Features -`asdf-security-plugin` is a security-focused plugin for the https://asdf-vm.com/[asdf version manager]. It provides security scanning capabilities for asdf installations, including plugin auditing, signature verification, and vulnerability reporting. +* Integration with Trivy, Grype, and Syft for scanning +* Policy-as-code support via OPA/Rego +* SBOM generation for installed tool chains +* Supply chain attestation via Sigstore -== Installation +=== Related Projects -[source,bash] ----- -asdf plugin add asdf-security https://github.com/hyperpolymath/asdf-security-plugin.git -asdf install asdf-security 1.0.0 -asdf global asdf-security 1.0.0 ----- - -== Usage - -[source,bash] ----- -asdf-security [args...] ----- - -=== Commands - -[cols="2,3",options="header"] +[width="100%",cols="40%,60%",options="header",] |=== -| Command | Description - -| `audit` -| Audit all installed asdf plugins for known vulnerabilities - -| `verify ` -| Verify GPG signatures and SHA256 checksums of a plugin - -| `report` -| Generate a comprehensive security report of all plugins +|Project |Relationship +|https://github.com/hyperpolymath/asdf-metaiconic-plugin[asdf-metaiconic-plugin] +|Metadata registry -| `update-db` -| Update the local vulnerability database +|https://github.com/hyperpolymath/asdf-ui-plugin[asdf-ui-plugin] |Visual +interface |=== -=== Examples - -[source,bash] ----- -# Audit all plugins -asdf-security audit - -# Verify a specific plugin -asdf-security verify nodejs - -# Generate security report -asdf-security report - -# Update vulnerability database -asdf-security update-db ----- - -== Components - -[cols="2,3",options="header"] -|=== -| Component | Description - -| `bin/list-all` -| Lists available versions of asdf-security - -| `bin/download` -| Downloads the specified version - -| `bin/install` -| Installs asdf-security to the specified path - -| `lib/utils.bash` -| Shared utility functions - -| `.github/workflows/` -| CI/CD infrastructure including security scanning - -| `hooks/` -| Pre-commit validation hooks for security standards -|=== - -== Security Features - -* *Plugin Auditing*: Scans installed plugins against known vulnerability databases -* *Signature Verification*: Validates GPG signatures on plugin releases -* *Checksum Validation*: SHA256 integrity verification for downloads -* *Security Reports*: Comprehensive JSON/text reports of security posture - -== Development Standards - -Per the Hyperpolymath Language Policy: +=== License -* **Primary languages**: Bash/POSIX Shell (for asdf plugin scripts) -* **Package management**: Guix (primary), Guix (fallback) -* **Security**: SHA256+ hashing, HTTPS only, no hardcoded secrets, SHA-pinned dependencies -* **Code quality**: ShellCheck linting, SPDX license headers +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -== License +''''' -MPL-2.0 +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-security-plugin/README.md b/asdf-augmenters/asdf-security-plugin/README.md deleted file mode 100644 index 9ee2db44..00000000 --- a/asdf-augmenters/asdf-security-plugin/README.md +++ /dev/null @@ -1,41 +0,0 @@ -# asdf-security-plugin - -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] -image:https://img.shields.io/badge/Philosophy-Palimpsest-indigo.svg[Palimpsest,link="https://github.com/hyperpolymath/palimpsest-license"] - -Security-focused extensions and policies for the [asdf](https://asdf-vm.com) version manager ecosystem. - -## Status - -> **Note:** This repository is currently a project skeleton. Implementation is pending. - -## Overview - -`asdf-security-plugin` provides security tooling and policies for the asdf plugin ecosystem: - -- **Security scanning** - Vulnerability detection for installed tools -- **Policy enforcement** - Ensure only approved versions are installed -- **Audit logging** - Track version changes and installations -- **Signature verification** - Validate tool authenticity - -## Planned Features - -- Integration with Trivy, Grype, and Syft for scanning -- Policy-as-code support via OPA/Rego -- SBOM generation for installed tool chains -- Supply chain attestation via Sigstore - -## Related Projects - -| Project | Relationship | -|---------|--------------| -| [asdf-metaiconic-plugin](https://github.com/hyperpolymath/asdf-metaiconic-plugin) | Metadata registry | -| [asdf-ui-plugin](https://github.com/hyperpolymath/asdf-ui-plugin) | Visual interface | - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-security-plugin/SECURITY.adoc b/asdf-augmenters/asdf-security-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-security-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-security-plugin/SECURITY.md b/asdf-augmenters/asdf-security-plugin/SECURITY.md deleted file mode 100644 index 159a0b7a..00000000 --- a/asdf-augmenters/asdf-security-plugin/SECURITY.md +++ /dev/null @@ -1,25 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection - diff --git a/asdf-augmenters/asdf-ui-plugin/ABI-FFI-README.adoc b/asdf-augmenters/asdf-ui-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..62673536 --- /dev/null +++ b/asdf-augmenters/asdf-ui-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== UI ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/ui.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libui.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +ui/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── ui.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── ui.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/ui.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "ui.h" + +int main() { + void* handle = ui_init(); + if (!handle) return 1; + + int result = ui_process(handle, 42); + if (result != 0) { + const char* err = ui_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + ui_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lui -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import UI.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "ui")] +extern "C" { + fn ui_init() -> *mut std::ffi::c_void; + fn ui_free(handle: *mut std::ffi::c_void); + fn ui_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = ui_init(); + assert!(!handle.is_null()); + + let result = ui_process(handle, 42); + assert_eq!(result, 0); + + ui_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libui = "libui" + +function init() + handle = ccall((:ui_init, libui), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:ui_process, libui), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:ui_free, libui), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/ui.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-augmenters/asdf-ui-plugin/ABI-FFI-README.md b/asdf-augmenters/asdf-ui-plugin/ABI-FFI-README.md deleted file mode 100644 index 42a9d25c..00000000 --- a/asdf-augmenters/asdf-ui-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# UI ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/ui.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libui.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -ui/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── ui.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── ui.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/ui.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "ui.h" - -int main() { - void* handle = ui_init(); - if (!handle) return 1; - - int result = ui_process(handle, 42); - if (result != 0) { - const char* err = ui_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - ui_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lui -L./zig-out/lib -``` - -### From Idris2 - -```idris -import UI.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "ui")] -extern "C" { - fn ui_init() -> *mut std::ffi::c_void; - fn ui_free(handle: *mut std::ffi::c_void); - fn ui_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = ui_init(); - assert!(!handle.is_null()); - - let result = ui_process(handle, 42); - assert_eq!(result, 0); - - ui_free(handle); - } -} -``` - -### From Julia - -```julia -const libui = "libui" - -function init() - handle = ccall((:ui_init, libui), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:ui_process, libui), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:ui_free, libui), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/ui.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-augmenters/asdf-ui-plugin/CODE_OF_CONDUCT.adoc b/asdf-augmenters/asdf-ui-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-augmenters/asdf-ui-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-augmenters/asdf-ui-plugin/CODE_OF_CONDUCT.md b/asdf-augmenters/asdf-ui-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-augmenters/asdf-ui-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-augmenters/asdf-ui-plugin/CONTRIBUTING.adoc b/asdf-augmenters/asdf-ui-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-augmenters/asdf-ui-plugin/CONTRIBUTING.adoc +++ b/asdf-augmenters/asdf-ui-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-augmenters/asdf-ui-plugin/CONTRIBUTING.md b/asdf-augmenters/asdf-ui-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-augmenters/asdf-ui-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-augmenters/asdf-ui-plugin/README.adoc b/asdf-augmenters/asdf-ui-plugin/README.adoc index 8c19e39d..f52f4ce3 100644 --- a/asdf-augmenters/asdf-ui-plugin/README.adoc +++ b/asdf-augmenters/asdf-ui-plugin/README.adoc @@ -1,101 +1,53 @@ -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] -image:https://img.shields.io/badge/Philosophy-Palimpsest-indigo.svg[Palimpsest,link="https://github.com/hyperpolymath/palimpsest-license"] +== asdf-ui-plugin +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] +image:https://img.shields.io/badge/Philosophy-Palimpsest-indigo.svg[Palimpsest,link="`https://github.com/hyperpolymath/palimpsest-license`"] -// SPDX-License-Identifier: CC-BY-SA-4.0 -= asdf-ui-plugin +Visual user interface for the https://asdf-vm.com[asdf] version manager +ecosystem. -:toc: macro -:toc-title: Contents -:toclevels: 2 +=== Status -A fully functional **asdf plugin** providing a terminal user interface for managing asdf plugins and versions. +____ +*Note:* This repository is currently a placeholder. Implementation is +pending. +____ -== Status +=== Overview -[NOTE] -==== -**Implementation Complete** - Core plugin functionality is fully working. -==== +`+asdf-ui-plugin+` will provide a graphical interface for managing asdf +plugins and tool versions: -== Features +* *Plugin browser* - Visual discovery of available plugins +* *Version manager* - GUI for installing/switching versions +* *Status dashboard* - Overview of installed tools +* *Update notifications* - Track available updates -* **Version Management**: List, install, and switch between versions -* **Interactive TUI**: Terminal user interface for easy navigation -* **Dashboard View**: Overview of installed plugins and versions -* **Version Selector**: Interactive picker for version switching +=== Technology Stack -== Installation +* *UI Framework*: Tauri 2.0+ (Rust backend + web frontend) +* *Frontend*: AffineScript (type-safe JavaScript) +* *Styling*: TailwindCSS -[source,bash] ----- -asdf plugin add asdf-ui https://github.com/hyperpolymath/asdf-ui-plugin.git -asdf install asdf-ui 1.0.0 -asdf global asdf-ui 1.0.0 ----- +=== Related Projects -== Usage - -[source,bash] ----- -# Launch interactive TUI -asdf-ui - -# Show plugin dashboard -asdf-ui dashboard - -# Interactive version selector -asdf-ui versions - -# Display help -asdf-ui help ----- - -== Components - -[cols="1,3"] +[width="100%",cols="40%,60%",options="header",] |=== -| Component | Description - -| `bin/list-all` -| Lists all available versions - -| `bin/download` -| Downloads specified version +|Project |Relationship +|https://github.com/hyperpolymath/asdf-metaiconic-plugin[asdf-metaiconic-plugin] +|Metadata provider -| `bin/install` -| Installs version and creates asdf-ui binary - -| `lib/utils.bash` -| Core utility functions and TUI implementation - -| `.github/workflows/ci.yml` -| Continuous integration with ShellCheck - -| `.github/workflows/mirror.yml` -| Hub-and-spoke mirroring to GitLab, Codeberg, Bitbucket - -| `.github/workflows/instant-sync.yml` -| Automatic forge propagation on push/release - -| `.claude/CLAUDE.md` -| Hyperpolymath development standards (language policy) +|https://github.com/hyperpolymath/asdf-security-plugin[asdf-security-plugin] +|Security layer |=== -See link:ROADMAP.adoc[ROADMAP.adoc] for development history and future plans. - -== Development Standards - -This project follows the **Hyperpolymath Language Policy**: - -* *Primary*: AffineScript, Rust, Deno -* *Mobile*: Tauri 2.0+ or Dioxus (no Kotlin/Swift) -* *Backend*: Gleam (BEAM or JS target) -* *Config*: Nickel, Guile Scheme -* *Package Management*: Guix (primary), Guix (fallback) +=== License -See `.claude/CLAUDE.md` for full policy details. +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -== License +''''' -MPL-2.0 +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-augmenters/asdf-ui-plugin/README.md b/asdf-augmenters/asdf-ui-plugin/README.md deleted file mode 100644 index 77018b32..00000000 --- a/asdf-augmenters/asdf-ui-plugin/README.md +++ /dev/null @@ -1,40 +0,0 @@ -# asdf-ui-plugin - -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] -image:https://img.shields.io/badge/Philosophy-Palimpsest-indigo.svg[Palimpsest,link="https://github.com/hyperpolymath/palimpsest-license"] - -Visual user interface for the [asdf](https://asdf-vm.com) version manager ecosystem. - -## Status - -> **Note:** This repository is currently a placeholder. Implementation is pending. - -## Overview - -`asdf-ui-plugin` will provide a graphical interface for managing asdf plugins and tool versions: - -- **Plugin browser** - Visual discovery of available plugins -- **Version manager** - GUI for installing/switching versions -- **Status dashboard** - Overview of installed tools -- **Update notifications** - Track available updates - -## Technology Stack - -- **UI Framework**: Tauri 2.0+ (Rust backend + web frontend) -- **Frontend**: AffineScript (type-safe JavaScript) -- **Styling**: TailwindCSS - -## Related Projects - -| Project | Relationship | -|---------|--------------| -| [asdf-metaiconic-plugin](https://github.com/hyperpolymath/asdf-metaiconic-plugin) | Metadata provider | -| [asdf-security-plugin](https://github.com/hyperpolymath/asdf-security-plugin) | Security layer | - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-augmenters/asdf-ui-plugin/SECURITY.adoc b/asdf-augmenters/asdf-ui-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-augmenters/asdf-ui-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-augmenters/asdf-ui-plugin/SECURITY.md b/asdf-augmenters/asdf-ui-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-augmenters/asdf-ui-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-bebop-plugin/ABI-FFI-README.adoc b/asdf-bebop-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..357b2f75 --- /dev/null +++ b/asdf-bebop-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== BEBOP ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/bebop.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libbebop.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +bebop/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── bebop.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── bebop.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/bebop.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "bebop.h" + +int main() { + void* handle = bebop_init(); + if (!handle) return 1; + + int result = bebop_process(handle, 42); + if (result != 0) { + const char* err = bebop_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + bebop_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lbebop -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import BEBOP.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "bebop")] +extern "C" { + fn bebop_init() -> *mut std::ffi::c_void; + fn bebop_free(handle: *mut std::ffi::c_void); + fn bebop_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = bebop_init(); + assert!(!handle.is_null()); + + let result = bebop_process(handle, 42); + assert_eq!(result, 0); + + bebop_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libbebop = "libbebop" + +function init() + handle = ccall((:bebop_init, libbebop), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:bebop_process, libbebop), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:bebop_free, libbebop), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/bebop.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-bebop-plugin/ABI-FFI-README.md b/asdf-bebop-plugin/ABI-FFI-README.md deleted file mode 100644 index a1726fec..00000000 --- a/asdf-bebop-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# BEBOP ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/bebop.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libbebop.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -bebop/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── bebop.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── bebop.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/bebop.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "bebop.h" - -int main() { - void* handle = bebop_init(); - if (!handle) return 1; - - int result = bebop_process(handle, 42); - if (result != 0) { - const char* err = bebop_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - bebop_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lbebop -L./zig-out/lib -``` - -### From Idris2 - -```idris -import BEBOP.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "bebop")] -extern "C" { - fn bebop_init() -> *mut std::ffi::c_void; - fn bebop_free(handle: *mut std::ffi::c_void); - fn bebop_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = bebop_init(); - assert!(!handle.is_null()); - - let result = bebop_process(handle, 42); - assert_eq!(result, 0); - - bebop_free(handle); - } -} -``` - -### From Julia - -```julia -const libbebop = "libbebop" - -function init() - handle = ccall((:bebop_init, libbebop), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:bebop_process, libbebop), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:bebop_free, libbebop), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/bebop.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-bebop-plugin/CODE_OF_CONDUCT.adoc b/asdf-bebop-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-bebop-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-bebop-plugin/CODE_OF_CONDUCT.md b/asdf-bebop-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-bebop-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-bebop-plugin/CONTRIBUTING.adoc b/asdf-bebop-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-bebop-plugin/CONTRIBUTING.adoc +++ b/asdf-bebop-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-bebop-plugin/CONTRIBUTING.md b/asdf-bebop-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-bebop-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-bebop-plugin/README.adoc b/asdf-bebop-plugin/README.adoc index d08e1dd2..5665674a 100644 --- a/asdf-bebop-plugin/README.adoc +++ b/asdf-bebop-plugin/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-bebop -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-bebop-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-bebop-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-bebop-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-bebop-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://bebop.sh[Bebop]. -**All repos with foreign function interfaces MUST follow this standard:** +Fast typed binary serialization. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add bebop https://github.com/hyperpolymath/asdf-bebop-plugin.git +---- -=== Web Projects +bebop: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all bebop -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install bebop latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global bebop latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now bebop commands are available +bebop --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list bebop -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local bebop -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall bebop ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-bebop-plugin/README.md b/asdf-bebop-plugin/README.md deleted file mode 100644 index 320faa25..00000000 --- a/asdf-bebop-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-bebop - -[![Build](https://github.com/hyperpolymath/asdf-bebop-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-bebop-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-bebop-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-bebop-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Bebop](https://bebop.sh). - -Fast typed binary serialization. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add bebop https://github.com/hyperpolymath/asdf-bebop-plugin.git -``` - -bebop: - -```bash -# Show all installable versions -asdf list-all bebop - -# Install specific version -asdf install bebop latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global bebop latest - -# Now bebop commands are available -bebop --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list bebop - -# Set local version for current directory -asdf local bebop - -# Uninstall a version -asdf uninstall bebop -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-bebop-plugin/SECURITY.adoc b/asdf-bebop-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-bebop-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-bebop-plugin/SECURITY.md b/asdf-bebop-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-bebop-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-borg-plugin/ABI-FFI-README.adoc b/asdf-borg-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..66d4578e --- /dev/null +++ b/asdf-borg-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== BORG ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/borg.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libborg.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +borg/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── borg.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── borg.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/borg.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "borg.h" + +int main() { + void* handle = borg_init(); + if (!handle) return 1; + + int result = borg_process(handle, 42); + if (result != 0) { + const char* err = borg_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + borg_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lborg -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import BORG.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "borg")] +extern "C" { + fn borg_init() -> *mut std::ffi::c_void; + fn borg_free(handle: *mut std::ffi::c_void); + fn borg_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = borg_init(); + assert!(!handle.is_null()); + + let result = borg_process(handle, 42); + assert_eq!(result, 0); + + borg_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libborg = "libborg" + +function init() + handle = ccall((:borg_init, libborg), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:borg_process, libborg), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:borg_free, libborg), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/borg.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-borg-plugin/ABI-FFI-README.md b/asdf-borg-plugin/ABI-FFI-README.md deleted file mode 100644 index f2b06791..00000000 --- a/asdf-borg-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# BORG ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/borg.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libborg.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -borg/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── borg.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── borg.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/borg.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "borg.h" - -int main() { - void* handle = borg_init(); - if (!handle) return 1; - - int result = borg_process(handle, 42); - if (result != 0) { - const char* err = borg_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - borg_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lborg -L./zig-out/lib -``` - -### From Idris2 - -```idris -import BORG.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "borg")] -extern "C" { - fn borg_init() -> *mut std::ffi::c_void; - fn borg_free(handle: *mut std::ffi::c_void); - fn borg_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = borg_init(); - assert!(!handle.is_null()); - - let result = borg_process(handle, 42); - assert_eq!(result, 0); - - borg_free(handle); - } -} -``` - -### From Julia - -```julia -const libborg = "libborg" - -function init() - handle = ccall((:borg_init, libborg), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:borg_process, libborg), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:borg_free, libborg), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/borg.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-borg-plugin/CODE_OF_CONDUCT.adoc b/asdf-borg-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-borg-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-borg-plugin/CODE_OF_CONDUCT.md b/asdf-borg-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-borg-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-borg-plugin/CONTRIBUTING.adoc b/asdf-borg-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-borg-plugin/CONTRIBUTING.adoc +++ b/asdf-borg-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-borg-plugin/CONTRIBUTING.md b/asdf-borg-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-borg-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-borg-plugin/README.adoc b/asdf-borg-plugin/README.adoc index d08e1dd2..a2d2855a 100644 --- a/asdf-borg-plugin/README.adoc +++ b/asdf-borg-plugin/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-borg -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-borg-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-borg-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-borg-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-borg-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://www.borgbackup.org[BorgBackup]. -**All repos with foreign function interfaces MUST follow this standard:** +Deduplicating backup. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add borg https://github.com/hyperpolymath/asdf-borg-plugin.git +---- -=== Web Projects +borg: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all borg -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install borg latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global borg latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now borg commands are available +borg --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list borg -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local borg -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall borg ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-borg-plugin/README.md b/asdf-borg-plugin/README.md deleted file mode 100644 index e66f490b..00000000 --- a/asdf-borg-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-borg - -[![Build](https://github.com/hyperpolymath/asdf-borg-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-borg-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-borg-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-borg-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [BorgBackup](https://www.borgbackup.org). - -Deduplicating backup. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add borg https://github.com/hyperpolymath/asdf-borg-plugin.git -``` - -borg: - -```bash -# Show all installable versions -asdf list-all borg - -# Install specific version -asdf install borg latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global borg latest - -# Now borg commands are available -borg --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list borg - -# Set local version for current directory -asdf local borg - -# Uninstall a version -asdf uninstall borg -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-borg-plugin/SECURITY.adoc b/asdf-borg-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-borg-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-borg-plugin/SECURITY.md b/asdf-borg-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-borg-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-casket-ssg-plugin/ABI-FFI-README.adoc b/asdf-casket-ssg-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..97b3d3b7 --- /dev/null +++ b/asdf-casket-ssg-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== CASKET_SSG ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/casket-ssg.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libcasket-ssg.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +casket-ssg/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── casket-ssg.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── casket-ssg.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/casket-ssg.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "casket-ssg.h" + +int main() { + void* handle = casket-ssg_init(); + if (!handle) return 1; + + int result = casket-ssg_process(handle, 42); + if (result != 0) { + const char* err = casket-ssg_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + casket-ssg_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lcasket-ssg -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import CASKET_SSG.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "casket-ssg")] +extern "C" { + fn casket-ssg_init() -> *mut std::ffi::c_void; + fn casket-ssg_free(handle: *mut std::ffi::c_void); + fn casket-ssg_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = casket-ssg_init(); + assert!(!handle.is_null()); + + let result = casket-ssg_process(handle, 42); + assert_eq!(result, 0); + + casket-ssg_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libcasket-ssg = "libcasket-ssg" + +function init() + handle = ccall((:casket-ssg_init, libcasket-ssg), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:casket-ssg_process, libcasket-ssg), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:casket-ssg_free, libcasket-ssg), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/casket-ssg.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-casket-ssg-plugin/ABI-FFI-README.md b/asdf-casket-ssg-plugin/ABI-FFI-README.md deleted file mode 100644 index e1ee045a..00000000 --- a/asdf-casket-ssg-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# CASKET_SSG ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/casket-ssg.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libcasket-ssg.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -casket-ssg/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── casket-ssg.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── casket-ssg.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/casket-ssg.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "casket-ssg.h" - -int main() { - void* handle = casket-ssg_init(); - if (!handle) return 1; - - int result = casket-ssg_process(handle, 42); - if (result != 0) { - const char* err = casket-ssg_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - casket-ssg_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lcasket-ssg -L./zig-out/lib -``` - -### From Idris2 - -```idris -import CASKET_SSG.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "casket-ssg")] -extern "C" { - fn casket-ssg_init() -> *mut std::ffi::c_void; - fn casket-ssg_free(handle: *mut std::ffi::c_void); - fn casket-ssg_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = casket-ssg_init(); - assert!(!handle.is_null()); - - let result = casket-ssg_process(handle, 42); - assert_eq!(result, 0); - - casket-ssg_free(handle); - } -} -``` - -### From Julia - -```julia -const libcasket-ssg = "libcasket-ssg" - -function init() - handle = ccall((:casket-ssg_init, libcasket-ssg), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:casket-ssg_process, libcasket-ssg), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:casket-ssg_free, libcasket-ssg), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/casket-ssg.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-casket-ssg-plugin/CODE_OF_CONDUCT.adoc b/asdf-casket-ssg-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-casket-ssg-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-casket-ssg-plugin/CODE_OF_CONDUCT.md b/asdf-casket-ssg-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-casket-ssg-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-casket-ssg-plugin/CONTRIBUTING.adoc b/asdf-casket-ssg-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-casket-ssg-plugin/CONTRIBUTING.adoc +++ b/asdf-casket-ssg-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-casket-ssg-plugin/CONTRIBUTING.md b/asdf-casket-ssg-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-casket-ssg-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-casket-ssg-plugin/README.adoc b/asdf-casket-ssg-plugin/README.adoc index 0caffcaf..fe3ba07d 100644 --- a/asdf-casket-ssg-plugin/README.adoc +++ b/asdf-casket-ssg-plugin/README.adoc @@ -1,40 +1,83 @@ -= asdf-casket-ssg +== asdf-casket-ssg -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] -:author: hyperpolymath -:url-asdf: https://asdf-vm.com -:url-repo: https://github.com/hyperpolymath/asdf-casket-ssg-plugin +https://github.com/hyperpolymath/asdf-casket-ssg-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-casket-ssg-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-casket-ssg-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-casket-ssg-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -image:https://img.shields.io/github/license/hyperpolymath/asdf-casket-ssg-plugin?style=flat-square[License,link=LICENSE] -image:https://img.shields.io/github/actions/workflow/status/hyperpolymath/asdf-casket-ssg-plugin/ci.yml?branch=main&style=flat-square[Build Status,link={url-repo}/actions] -image:https://img.shields.io/badge/asdf-plugin-blue?style=flat-square[asdf Plugin,link={url-asdf}] +https://asdf-vm.com[asdf] plugin for +https://github.com/caskethosting/casket[Casket]. -An {url-asdf}[asdf] plugin to manage https://github.com/hyperpolymath/casket-ssg[casket-ssg] versions. +Static site generator. -== Installation +=== Contents + +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] + +=== Dependencies + +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] + +=== Install + +Plugin: [source,bash] ---- asdf plugin add casket-ssg https://github.com/hyperpolymath/asdf-casket-ssg-plugin.git ---- -== Usage +casket-ssg: [source,bash] ---- -# List all available versions -asdf list all casket-ssg +# Show all installable versions +asdf list-all casket-ssg -# Install a specific version -asdf install casket-ssg 1.1.0 +# Install specific version +asdf install casket-ssg latest -# Set global default -asdf global casket-ssg 1.1.0 +# Set a version globally (in your ~/.tool-versions file) +asdf global casket-ssg latest -# Set local version for current project -asdf local casket-ssg 1.1.0 +# Now casket-ssg commands are available +casket-ssg --version ---- -== License +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. + +=== Usage + +[source,bash] +---- +# List installed versions +asdf list casket-ssg + +# Set local version for current directory +asdf local casket-ssg + +# Uninstall a version +asdf uninstall casket-ssg +---- + +=== Contributing + +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License + +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. + +''''' -SPDX-License-Identifier: CC-BY-SA-4.0 +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-casket-ssg-plugin/README.md b/asdf-casket-ssg-plugin/README.md deleted file mode 100644 index 1db4962f..00000000 --- a/asdf-casket-ssg-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-casket-ssg - -[![Build](https://github.com/hyperpolymath/asdf-casket-ssg-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-casket-ssg-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-casket-ssg-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-casket-ssg-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Casket](https://github.com/caskethosting/casket). - -Static site generator. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add casket-ssg https://github.com/hyperpolymath/asdf-casket-ssg-plugin.git -``` - -casket-ssg: - -```bash -# Show all installable versions -asdf list-all casket-ssg - -# Install specific version -asdf install casket-ssg latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global casket-ssg latest - -# Now casket-ssg commands are available -casket-ssg --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list casket-ssg - -# Set local version for current directory -asdf local casket-ssg - -# Uninstall a version -asdf uninstall casket-ssg -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-casket-ssg-plugin/SECURITY.adoc b/asdf-casket-ssg-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-casket-ssg-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-casket-ssg-plugin/SECURITY.md b/asdf-casket-ssg-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-casket-ssg-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-cassandra-plugin/ABI-FFI-README.adoc b/asdf-cassandra-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..3c630b9f --- /dev/null +++ b/asdf-cassandra-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== CASSANDRA ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/cassandra.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libcassandra.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +cassandra/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── cassandra.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── cassandra.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/cassandra.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "cassandra.h" + +int main() { + void* handle = cassandra_init(); + if (!handle) return 1; + + int result = cassandra_process(handle, 42); + if (result != 0) { + const char* err = cassandra_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + cassandra_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lcassandra -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import CASSANDRA.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "cassandra")] +extern "C" { + fn cassandra_init() -> *mut std::ffi::c_void; + fn cassandra_free(handle: *mut std::ffi::c_void); + fn cassandra_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = cassandra_init(); + assert!(!handle.is_null()); + + let result = cassandra_process(handle, 42); + assert_eq!(result, 0); + + cassandra_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libcassandra = "libcassandra" + +function init() + handle = ccall((:cassandra_init, libcassandra), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:cassandra_process, libcassandra), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:cassandra_free, libcassandra), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/cassandra.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-cassandra-plugin/ABI-FFI-README.md b/asdf-cassandra-plugin/ABI-FFI-README.md deleted file mode 100644 index d9fa65f6..00000000 --- a/asdf-cassandra-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# CASSANDRA ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/cassandra.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libcassandra.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -cassandra/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── cassandra.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── cassandra.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/cassandra.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "cassandra.h" - -int main() { - void* handle = cassandra_init(); - if (!handle) return 1; - - int result = cassandra_process(handle, 42); - if (result != 0) { - const char* err = cassandra_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - cassandra_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lcassandra -L./zig-out/lib -``` - -### From Idris2 - -```idris -import CASSANDRA.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "cassandra")] -extern "C" { - fn cassandra_init() -> *mut std::ffi::c_void; - fn cassandra_free(handle: *mut std::ffi::c_void); - fn cassandra_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = cassandra_init(); - assert!(!handle.is_null()); - - let result = cassandra_process(handle, 42); - assert_eq!(result, 0); - - cassandra_free(handle); - } -} -``` - -### From Julia - -```julia -const libcassandra = "libcassandra" - -function init() - handle = ccall((:cassandra_init, libcassandra), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:cassandra_process, libcassandra), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:cassandra_free, libcassandra), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/cassandra.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-cassandra-plugin/CODE_OF_CONDUCT.adoc b/asdf-cassandra-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-cassandra-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-cassandra-plugin/CODE_OF_CONDUCT.md b/asdf-cassandra-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-cassandra-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-cassandra-plugin/CONTRIBUTING.adoc b/asdf-cassandra-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-cassandra-plugin/CONTRIBUTING.adoc +++ b/asdf-cassandra-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-cassandra-plugin/CONTRIBUTING.md b/asdf-cassandra-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-cassandra-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-cassandra-plugin/README.adoc b/asdf-cassandra-plugin/README.adoc index d08e1dd2..2d88e26c 100644 --- a/asdf-cassandra-plugin/README.adoc +++ b/asdf-cassandra-plugin/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-cassandra -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-cassandra-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-cassandra-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-cassandra-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-cassandra-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://cassandra.apache.org[Apache +Cassandra]. -**All repos with foreign function interfaces MUST follow this standard:** +Distributed NoSQL database. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add cassandra https://github.com/hyperpolymath/asdf-cassandra-plugin.git +---- -=== Web Projects +cassandra: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all cassandra -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install cassandra latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global cassandra latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now cassandra commands are available +cassandra --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list cassandra -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local cassandra -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall cassandra ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-cassandra-plugin/README.md b/asdf-cassandra-plugin/README.md deleted file mode 100644 index fbf491de..00000000 --- a/asdf-cassandra-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-cassandra - -[![Build](https://github.com/hyperpolymath/asdf-cassandra-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-cassandra-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-cassandra-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-cassandra-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Apache Cassandra](https://cassandra.apache.org). - -Distributed NoSQL database. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add cassandra https://github.com/hyperpolymath/asdf-cassandra-plugin.git -``` - -cassandra: - -```bash -# Show all installable versions -asdf list-all cassandra - -# Install specific version -asdf install cassandra latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global cassandra latest - -# Now cassandra commands are available -cassandra --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list cassandra - -# Set local version for current directory -asdf local cassandra - -# Uninstall a version -asdf uninstall cassandra -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-cassandra-plugin/SECURITY.adoc b/asdf-cassandra-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-cassandra-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-cassandra-plugin/SECURITY.md b/asdf-cassandra-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-cassandra-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-cfssl-plugin/ABI-FFI-README.adoc b/asdf-cfssl-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..03f95040 --- /dev/null +++ b/asdf-cfssl-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== CFSSL ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/cfssl.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libcfssl.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +cfssl/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── cfssl.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── cfssl.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/cfssl.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "cfssl.h" + +int main() { + void* handle = cfssl_init(); + if (!handle) return 1; + + int result = cfssl_process(handle, 42); + if (result != 0) { + const char* err = cfssl_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + cfssl_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lcfssl -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import CFSSL.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "cfssl")] +extern "C" { + fn cfssl_init() -> *mut std::ffi::c_void; + fn cfssl_free(handle: *mut std::ffi::c_void); + fn cfssl_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = cfssl_init(); + assert!(!handle.is_null()); + + let result = cfssl_process(handle, 42); + assert_eq!(result, 0); + + cfssl_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libcfssl = "libcfssl" + +function init() + handle = ccall((:cfssl_init, libcfssl), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:cfssl_process, libcfssl), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:cfssl_free, libcfssl), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/cfssl.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-cfssl-plugin/ABI-FFI-README.md b/asdf-cfssl-plugin/ABI-FFI-README.md deleted file mode 100644 index 0c2780b9..00000000 --- a/asdf-cfssl-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# CFSSL ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/cfssl.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libcfssl.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -cfssl/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── cfssl.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── cfssl.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/cfssl.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "cfssl.h" - -int main() { - void* handle = cfssl_init(); - if (!handle) return 1; - - int result = cfssl_process(handle, 42); - if (result != 0) { - const char* err = cfssl_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - cfssl_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lcfssl -L./zig-out/lib -``` - -### From Idris2 - -```idris -import CFSSL.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "cfssl")] -extern "C" { - fn cfssl_init() -> *mut std::ffi::c_void; - fn cfssl_free(handle: *mut std::ffi::c_void); - fn cfssl_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = cfssl_init(); - assert!(!handle.is_null()); - - let result = cfssl_process(handle, 42); - assert_eq!(result, 0); - - cfssl_free(handle); - } -} -``` - -### From Julia - -```julia -const libcfssl = "libcfssl" - -function init() - handle = ccall((:cfssl_init, libcfssl), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:cfssl_process, libcfssl), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:cfssl_free, libcfssl), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/cfssl.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-cfssl-plugin/CODE_OF_CONDUCT.adoc b/asdf-cfssl-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-cfssl-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-cfssl-plugin/CODE_OF_CONDUCT.md b/asdf-cfssl-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-cfssl-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-cfssl-plugin/CONTRIBUTING.adoc b/asdf-cfssl-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-cfssl-plugin/CONTRIBUTING.adoc +++ b/asdf-cfssl-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-cfssl-plugin/CONTRIBUTING.md b/asdf-cfssl-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-cfssl-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-cfssl-plugin/README.adoc b/asdf-cfssl-plugin/README.adoc index d08e1dd2..29ea3ce9 100644 --- a/asdf-cfssl-plugin/README.adoc +++ b/asdf-cfssl-plugin/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-cfssl -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-cfssl-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-cfssl-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-cfssl-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-cfssl-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://cfssl.org[CFSSL]. -**All repos with foreign function interfaces MUST follow this standard:** +CloudFlare PKI toolkit. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add cfssl https://github.com/hyperpolymath/asdf-cfssl-plugin.git +---- -=== Web Projects +cfssl: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all cfssl -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install cfssl latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global cfssl latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now cfssl commands are available +cfssl --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list cfssl -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local cfssl -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall cfssl ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-cfssl-plugin/README.md b/asdf-cfssl-plugin/README.md deleted file mode 100644 index deb102ac..00000000 --- a/asdf-cfssl-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-cfssl - -[![Build](https://github.com/hyperpolymath/asdf-cfssl-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-cfssl-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-cfssl-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-cfssl-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [CFSSL](https://cfssl.org). - -CloudFlare PKI toolkit. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add cfssl https://github.com/hyperpolymath/asdf-cfssl-plugin.git -``` - -cfssl: - -```bash -# Show all installable versions -asdf list-all cfssl - -# Install specific version -asdf install cfssl latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global cfssl latest - -# Now cfssl commands are available -cfssl --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list cfssl - -# Set local version for current directory -asdf local cfssl - -# Uninstall a version -asdf uninstall cfssl -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-cfssl-plugin/SECURITY.adoc b/asdf-cfssl-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-cfssl-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-cfssl-plugin/SECURITY.md b/asdf-cfssl-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-cfssl-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-cobalt-plugin/ABI-FFI-README.adoc b/asdf-cobalt-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..2f47a922 --- /dev/null +++ b/asdf-cobalt-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== COBALT ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/cobalt.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libcobalt.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +cobalt/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── cobalt.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── cobalt.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/cobalt.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "cobalt.h" + +int main() { + void* handle = cobalt_init(); + if (!handle) return 1; + + int result = cobalt_process(handle, 42); + if (result != 0) { + const char* err = cobalt_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + cobalt_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lcobalt -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import COBALT.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "cobalt")] +extern "C" { + fn cobalt_init() -> *mut std::ffi::c_void; + fn cobalt_free(handle: *mut std::ffi::c_void); + fn cobalt_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = cobalt_init(); + assert!(!handle.is_null()); + + let result = cobalt_process(handle, 42); + assert_eq!(result, 0); + + cobalt_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libcobalt = "libcobalt" + +function init() + handle = ccall((:cobalt_init, libcobalt), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:cobalt_process, libcobalt), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:cobalt_free, libcobalt), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/cobalt.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-cobalt-plugin/ABI-FFI-README.md b/asdf-cobalt-plugin/ABI-FFI-README.md deleted file mode 100644 index b38a3a27..00000000 --- a/asdf-cobalt-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# COBALT ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/cobalt.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libcobalt.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -cobalt/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── cobalt.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── cobalt.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/cobalt.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "cobalt.h" - -int main() { - void* handle = cobalt_init(); - if (!handle) return 1; - - int result = cobalt_process(handle, 42); - if (result != 0) { - const char* err = cobalt_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - cobalt_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lcobalt -L./zig-out/lib -``` - -### From Idris2 - -```idris -import COBALT.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "cobalt")] -extern "C" { - fn cobalt_init() -> *mut std::ffi::c_void; - fn cobalt_free(handle: *mut std::ffi::c_void); - fn cobalt_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = cobalt_init(); - assert!(!handle.is_null()); - - let result = cobalt_process(handle, 42); - assert_eq!(result, 0); - - cobalt_free(handle); - } -} -``` - -### From Julia - -```julia -const libcobalt = "libcobalt" - -function init() - handle = ccall((:cobalt_init, libcobalt), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:cobalt_process, libcobalt), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:cobalt_free, libcobalt), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/cobalt.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-cobalt-plugin/CODE_OF_CONDUCT.adoc b/asdf-cobalt-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-cobalt-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-cobalt-plugin/CODE_OF_CONDUCT.md b/asdf-cobalt-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-cobalt-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-cobalt-plugin/CONTRIBUTING.adoc b/asdf-cobalt-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-cobalt-plugin/CONTRIBUTING.adoc +++ b/asdf-cobalt-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-cobalt-plugin/CONTRIBUTING.md b/asdf-cobalt-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-cobalt-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-cobalt-plugin/README.adoc b/asdf-cobalt-plugin/README.adoc index d08e1dd2..75e44c27 100644 --- a/asdf-cobalt-plugin/README.adoc +++ b/asdf-cobalt-plugin/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-cobalt -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-cobalt-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-cobalt-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-cobalt-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-cobalt-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://cobalt-org.github.io[Cobalt]. -**All repos with foreign function interfaces MUST follow this standard:** +Static site generator in Rust. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add cobalt https://github.com/hyperpolymath/asdf-cobalt-plugin.git +---- -=== Web Projects +cobalt: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all cobalt -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install cobalt latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global cobalt latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now cobalt commands are available +cobalt --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list cobalt -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local cobalt -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall cobalt ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-cobalt-plugin/README.md b/asdf-cobalt-plugin/README.md deleted file mode 100644 index d38c0c31..00000000 --- a/asdf-cobalt-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-cobalt - -[![Build](https://github.com/hyperpolymath/asdf-cobalt-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-cobalt-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-cobalt-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-cobalt-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Cobalt](https://cobalt-org.github.io). - -Static site generator in Rust. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add cobalt https://github.com/hyperpolymath/asdf-cobalt-plugin.git -``` - -cobalt: - -```bash -# Show all installable versions -asdf list-all cobalt - -# Install specific version -asdf install cobalt latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global cobalt latest - -# Now cobalt commands are available -cobalt --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list cobalt - -# Set local version for current directory -asdf local cobalt - -# Uninstall a version -asdf uninstall cobalt -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-cobalt-plugin/SECURITY.adoc b/asdf-cobalt-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-cobalt-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-cobalt-plugin/SECURITY.md b/asdf-cobalt-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-cobalt-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-cobol-plugin/ABI-FFI-README.adoc b/asdf-cobol-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..668697fe --- /dev/null +++ b/asdf-cobol-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== COBOL ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/cobol.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libcobol.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +cobol/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── cobol.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── cobol.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/cobol.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "cobol.h" + +int main() { + void* handle = cobol_init(); + if (!handle) return 1; + + int result = cobol_process(handle, 42); + if (result != 0) { + const char* err = cobol_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + cobol_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lcobol -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import COBOL.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "cobol")] +extern "C" { + fn cobol_init() -> *mut std::ffi::c_void; + fn cobol_free(handle: *mut std::ffi::c_void); + fn cobol_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = cobol_init(); + assert!(!handle.is_null()); + + let result = cobol_process(handle, 42); + assert_eq!(result, 0); + + cobol_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libcobol = "libcobol" + +function init() + handle = ccall((:cobol_init, libcobol), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:cobol_process, libcobol), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:cobol_free, libcobol), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/cobol.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-cobol-plugin/ABI-FFI-README.md b/asdf-cobol-plugin/ABI-FFI-README.md deleted file mode 100644 index b5600f7c..00000000 --- a/asdf-cobol-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# COBOL ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/cobol.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libcobol.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -cobol/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── cobol.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── cobol.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/cobol.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "cobol.h" - -int main() { - void* handle = cobol_init(); - if (!handle) return 1; - - int result = cobol_process(handle, 42); - if (result != 0) { - const char* err = cobol_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - cobol_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lcobol -L./zig-out/lib -``` - -### From Idris2 - -```idris -import COBOL.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "cobol")] -extern "C" { - fn cobol_init() -> *mut std::ffi::c_void; - fn cobol_free(handle: *mut std::ffi::c_void); - fn cobol_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = cobol_init(); - assert!(!handle.is_null()); - - let result = cobol_process(handle, 42); - assert_eq!(result, 0); - - cobol_free(handle); - } -} -``` - -### From Julia - -```julia -const libcobol = "libcobol" - -function init() - handle = ccall((:cobol_init, libcobol), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:cobol_process, libcobol), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:cobol_free, libcobol), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/cobol.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-cobol-plugin/CODE_OF_CONDUCT.adoc b/asdf-cobol-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-cobol-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-cobol-plugin/CODE_OF_CONDUCT.md b/asdf-cobol-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index caeda1c6..00000000 --- a/asdf-cobol-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,27 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. - diff --git a/asdf-cobol-plugin/CONTRIBUTING.adoc b/asdf-cobol-plugin/CONTRIBUTING.adoc index eb045d61..084ee525 100644 --- a/asdf-cobol-plugin/CONTRIBUTING.adoc +++ b/asdf-cobol-plugin/CONTRIBUTING.adoc @@ -1,20 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-cobol-plugin/CONTRIBUTING.md b/asdf-cobol-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-cobol-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-cobol-plugin/README.adoc b/asdf-cobol-plugin/README.adoc index d220c553..57a4d994 100644 --- a/asdf-cobol-plugin/README.adoc +++ b/asdf-cobol-plugin/README.adoc @@ -1,107 +1,83 @@ -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] -image:https://img.shields.io/badge/Philosophy-Palimpsest-indigo.svg[Palimpsest,link="https://github.com/hyperpolymath/palimpsest-license"] +== asdf-cobol +https://github.com/hyperpolymath/asdf-cobol-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-cobol-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-cobol-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-cobol-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -// SPDX-License-Identifier: CC-BY-SA-4.0 -= asdf-cobol +https://asdf-vm.com[asdf] plugin for +https://www.gnu.org/software/gnucobol[GnuCOBOL]. -:toc: macro -:toclevels: 2 -:icons: font -:source-highlighter: rouge +Free COBOL compiler. -https://asdf-vm.com[asdf] plugin for https://www.gnu.org/software/gnucobol/[GnuCOBOL]. +=== Contents -[IMPORTANT] -==== -*Project Status: Specification Pending* +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -This repository is a placeholder. The plugin implementation will be uploaded shortly. -==== +=== Dependencies -toc::[] +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== Overview +=== Install -This plugin will enable version management of GnuCOBOL via the asdf version manager, allowing developers to: - -* Install multiple GnuCOBOL versions side-by-side -* Switch between versions per-project or globally -* Ensure reproducible COBOL development environments - -== Planned Installation - -Once implemented: +Plugin: [source,bash] ---- -asdf plugin add cobol https://gitlab.com/hyperpolymath/asdf-cobol.git -asdf list-all cobol -asdf install cobol 3.2.0 -asdf global cobol 3.2.0 +asdf plugin add cobol https://github.com/hyperpolymath/asdf-cobol-plugin.git ---- -== Current Repository Contents - -[cols="1,3"] -|=== -| Path | Description +cobol: -| `.github/workflows/mirror.yml` -| Hub-and-spoke mirror workflow (GitLab, Codeberg, Bitbucket) - -| `.github/workflows/instant-sync.yml` -| Automatic forge propagation on push/release - -| `README.md` -| Placeholder documentation - -| `README.adoc` -| This file -|=== +[source,bash] +---- +# Show all installable versions +asdf list-all cobol -== What Is Missing (Pending Implementation) +# Install specific version +asdf install cobol latest -Standard asdf plugin structure requires: +# Set a version globally (in your ~/.tool-versions file) +asdf global cobol latest -[source] +# Now cobol commands are available +cobol --version ---- -bin/ -├── download # Fetch GnuCOBOL source tarball -├── install # Compile and install GnuCOBOL -├── list-all # List available versions -├── list-bin-paths # (optional) Expose binaries -└── exec-env # (optional) Set runtime environment ----- - -== About GnuCOBOL -GnuCOBOL (formerly OpenCOBOL) is a free COBOL compiler that translates COBOL source to C, then compiles with a native C compiler. It implements substantial portions of the COBOL 85, COBOL 2002, and COBOL 2014 standards. +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -Key features: +=== Usage -* COBOL 85/2002/2014 support -* Compiles to native code via C -* Interoperability with C libraries -* Active development and community - -== Multi-Forge Distribution +[source,bash] +---- +# List installed versions +asdf list cobol -This repository is distributed across multiple forges: +# Set local version for current directory +asdf local cobol -* *Primary*: https://gitlab.com/hyperpolymath/asdf-cobol[GitLab] -* *Mirror*: GitHub (hyperpolymath/asdf-cobol-plugin) -* *Mirror*: Codeberg -* *Mirror*: Bitbucket +# Uninstall a version +asdf uninstall cobol +---- -== Contributing +=== Contributing -See `CONTRIBUTING.md` (pending). +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. -== License +=== License -MPL-2.0 +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -== Funding +''''' -If you find this useful, consider supporting via https://buymeacoffee.com[Buy Me a Coffee]. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-cobol-plugin/README.md b/asdf-cobol-plugin/README.md deleted file mode 100644 index bb7e814a..00000000 --- a/asdf-cobol-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-cobol - -[![Build](https://github.com/hyperpolymath/asdf-cobol-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-cobol-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-cobol-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-cobol-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [GnuCOBOL](https://www.gnu.org/software/gnucobol). - -Free COBOL compiler. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add cobol https://github.com/hyperpolymath/asdf-cobol-plugin.git -``` - -cobol: - -```bash -# Show all installable versions -asdf list-all cobol - -# Install specific version -asdf install cobol latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global cobol latest - -# Now cobol commands are available -cobol --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list cobol - -# Set local version for current directory -asdf local cobol - -# Uninstall a version -asdf uninstall cobol -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-cobol-plugin/SECURITY.adoc b/asdf-cobol-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-cobol-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-cobol-plugin/SECURITY.md b/asdf-cobol-plugin/SECURITY.md deleted file mode 100644 index 159a0b7a..00000000 --- a/asdf-cobol-plugin/SECURITY.md +++ /dev/null @@ -1,25 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection - diff --git a/asdf-control-tower/ABI-FFI-README.adoc b/asdf-control-tower/ABI-FFI-README.adoc new file mode 100644 index 00000000..5ca994c1 --- /dev/null +++ b/asdf-control-tower/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== CONTROL_TOWER ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/control-tower.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libcontrol-tower.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +control-tower/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── control-tower.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── control-tower.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/control-tower.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "control-tower.h" + +int main() { + void* handle = control-tower_init(); + if (!handle) return 1; + + int result = control-tower_process(handle, 42); + if (result != 0) { + const char* err = control-tower_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + control-tower_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lcontrol-tower -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import CONTROL_TOWER.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "control-tower")] +extern "C" { + fn control-tower_init() -> *mut std::ffi::c_void; + fn control-tower_free(handle: *mut std::ffi::c_void); + fn control-tower_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = control-tower_init(); + assert!(!handle.is_null()); + + let result = control-tower_process(handle, 42); + assert_eq!(result, 0); + + control-tower_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libcontrol-tower = "libcontrol-tower" + +function init() + handle = ccall((:control-tower_init, libcontrol-tower), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:control-tower_process, libcontrol-tower), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:control-tower_free, libcontrol-tower), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/control-tower.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-control-tower/ABI-FFI-README.md b/asdf-control-tower/ABI-FFI-README.md deleted file mode 100644 index 36c7a5d0..00000000 --- a/asdf-control-tower/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# CONTROL_TOWER ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/control-tower.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libcontrol-tower.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -control-tower/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── control-tower.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── control-tower.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/control-tower.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "control-tower.h" - -int main() { - void* handle = control-tower_init(); - if (!handle) return 1; - - int result = control-tower_process(handle, 42); - if (result != 0) { - const char* err = control-tower_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - control-tower_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lcontrol-tower -L./zig-out/lib -``` - -### From Idris2 - -```idris -import CONTROL_TOWER.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "control-tower")] -extern "C" { - fn control-tower_init() -> *mut std::ffi::c_void; - fn control-tower_free(handle: *mut std::ffi::c_void); - fn control-tower_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = control-tower_init(); - assert!(!handle.is_null()); - - let result = control-tower_process(handle, 42); - assert_eq!(result, 0); - - control-tower_free(handle); - } -} -``` - -### From Julia - -```julia -const libcontrol-tower = "libcontrol-tower" - -function init() - handle = ccall((:control-tower_init, libcontrol-tower), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:control-tower_process, libcontrol-tower), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:control-tower_free, libcontrol-tower), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/control-tower.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-control-tower/CODE_OF_CONDUCT.adoc b/asdf-control-tower/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-control-tower/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-control-tower/CODE_OF_CONDUCT.md b/asdf-control-tower/CODE_OF_CONDUCT.md deleted file mode 100644 index caeda1c6..00000000 --- a/asdf-control-tower/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,27 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. - diff --git a/asdf-control-tower/CONTRIBUTING.adoc b/asdf-control-tower/CONTRIBUTING.adoc index eb045d61..084ee525 100644 --- a/asdf-control-tower/CONTRIBUTING.adoc +++ b/asdf-control-tower/CONTRIBUTING.adoc @@ -1,20 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-control-tower/CONTRIBUTING.md b/asdf-control-tower/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-control-tower/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-control-tower/SECURITY.adoc b/asdf-control-tower/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-control-tower/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-control-tower/SECURITY.md b/asdf-control-tower/SECURITY.md deleted file mode 100644 index 159a0b7a..00000000 --- a/asdf-control-tower/SECURITY.md +++ /dev/null @@ -1,25 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection - diff --git a/asdf-coredns-plugin/ABI-FFI-README.adoc b/asdf-coredns-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..9a134242 --- /dev/null +++ b/asdf-coredns-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== COREDNS ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/coredns.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libcoredns.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +coredns/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── coredns.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── coredns.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/coredns.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "coredns.h" + +int main() { + void* handle = coredns_init(); + if (!handle) return 1; + + int result = coredns_process(handle, 42); + if (result != 0) { + const char* err = coredns_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + coredns_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lcoredns -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import COREDNS.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "coredns")] +extern "C" { + fn coredns_init() -> *mut std::ffi::c_void; + fn coredns_free(handle: *mut std::ffi::c_void); + fn coredns_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = coredns_init(); + assert!(!handle.is_null()); + + let result = coredns_process(handle, 42); + assert_eq!(result, 0); + + coredns_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libcoredns = "libcoredns" + +function init() + handle = ccall((:coredns_init, libcoredns), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:coredns_process, libcoredns), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:coredns_free, libcoredns), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/coredns.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-coredns-plugin/ABI-FFI-README.md b/asdf-coredns-plugin/ABI-FFI-README.md deleted file mode 100644 index be38cbfc..00000000 --- a/asdf-coredns-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# COREDNS ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/coredns.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libcoredns.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -coredns/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── coredns.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── coredns.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/coredns.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "coredns.h" - -int main() { - void* handle = coredns_init(); - if (!handle) return 1; - - int result = coredns_process(handle, 42); - if (result != 0) { - const char* err = coredns_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - coredns_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lcoredns -L./zig-out/lib -``` - -### From Idris2 - -```idris -import COREDNS.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "coredns")] -extern "C" { - fn coredns_init() -> *mut std::ffi::c_void; - fn coredns_free(handle: *mut std::ffi::c_void); - fn coredns_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = coredns_init(); - assert!(!handle.is_null()); - - let result = coredns_process(handle, 42); - assert_eq!(result, 0); - - coredns_free(handle); - } -} -``` - -### From Julia - -```julia -const libcoredns = "libcoredns" - -function init() - handle = ccall((:coredns_init, libcoredns), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:coredns_process, libcoredns), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:coredns_free, libcoredns), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/coredns.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-coredns-plugin/CODE_OF_CONDUCT.adoc b/asdf-coredns-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-coredns-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-coredns-plugin/CODE_OF_CONDUCT.md b/asdf-coredns-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-coredns-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-coredns-plugin/CONTRIBUTING.adoc b/asdf-coredns-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-coredns-plugin/CONTRIBUTING.adoc +++ b/asdf-coredns-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-coredns-plugin/CONTRIBUTING.md b/asdf-coredns-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-coredns-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-coredns-plugin/README.adoc b/asdf-coredns-plugin/README.adoc index d08e1dd2..c52bdaac 100644 --- a/asdf-coredns-plugin/README.adoc +++ b/asdf-coredns-plugin/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-coredns -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-coredns-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-coredns-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-coredns-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-coredns-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://coredns.io[CoreDNS]. -**All repos with foreign function interfaces MUST follow this standard:** +Flexible DNS server. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add coredns https://github.com/hyperpolymath/asdf-coredns-plugin.git +---- -=== Web Projects +coredns: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all coredns -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install coredns latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global coredns latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now coredns commands are available +coredns --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list coredns -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local coredns -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall coredns ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-coredns-plugin/README.md b/asdf-coredns-plugin/README.md deleted file mode 100644 index a98918e5..00000000 --- a/asdf-coredns-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-coredns - -[![Build](https://github.com/hyperpolymath/asdf-coredns-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-coredns-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-coredns-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-coredns-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [CoreDNS](https://coredns.io). - -Flexible DNS server. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add coredns https://github.com/hyperpolymath/asdf-coredns-plugin.git -``` - -coredns: - -```bash -# Show all installable versions -asdf list-all coredns - -# Install specific version -asdf install coredns latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global coredns latest - -# Now coredns commands are available -coredns --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list coredns - -# Set local version for current directory -asdf local coredns - -# Uninstall a version -asdf uninstall coredns -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-coredns-plugin/SECURITY.adoc b/asdf-coredns-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-coredns-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-coredns-plugin/SECURITY.md b/asdf-coredns-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-coredns-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-cosign-plugin/ABI-FFI-README.adoc b/asdf-cosign-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..2ba60102 --- /dev/null +++ b/asdf-cosign-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== COSIGN ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/cosign.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libcosign.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +cosign/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── cosign.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── cosign.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/cosign.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "cosign.h" + +int main() { + void* handle = cosign_init(); + if (!handle) return 1; + + int result = cosign_process(handle, 42); + if (result != 0) { + const char* err = cosign_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + cosign_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lcosign -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import COSIGN.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "cosign")] +extern "C" { + fn cosign_init() -> *mut std::ffi::c_void; + fn cosign_free(handle: *mut std::ffi::c_void); + fn cosign_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = cosign_init(); + assert!(!handle.is_null()); + + let result = cosign_process(handle, 42); + assert_eq!(result, 0); + + cosign_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libcosign = "libcosign" + +function init() + handle = ccall((:cosign_init, libcosign), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:cosign_process, libcosign), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:cosign_free, libcosign), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/cosign.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-cosign-plugin/ABI-FFI-README.md b/asdf-cosign-plugin/ABI-FFI-README.md deleted file mode 100644 index 98655399..00000000 --- a/asdf-cosign-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# COSIGN ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/cosign.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libcosign.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -cosign/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── cosign.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── cosign.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/cosign.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "cosign.h" - -int main() { - void* handle = cosign_init(); - if (!handle) return 1; - - int result = cosign_process(handle, 42); - if (result != 0) { - const char* err = cosign_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - cosign_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lcosign -L./zig-out/lib -``` - -### From Idris2 - -```idris -import COSIGN.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "cosign")] -extern "C" { - fn cosign_init() -> *mut std::ffi::c_void; - fn cosign_free(handle: *mut std::ffi::c_void); - fn cosign_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = cosign_init(); - assert!(!handle.is_null()); - - let result = cosign_process(handle, 42); - assert_eq!(result, 0); - - cosign_free(handle); - } -} -``` - -### From Julia - -```julia -const libcosign = "libcosign" - -function init() - handle = ccall((:cosign_init, libcosign), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:cosign_process, libcosign), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:cosign_free, libcosign), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/cosign.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-cosign-plugin/CODE_OF_CONDUCT.adoc b/asdf-cosign-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-cosign-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-cosign-plugin/CODE_OF_CONDUCT.md b/asdf-cosign-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-cosign-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-cosign-plugin/CONTRIBUTING.adoc b/asdf-cosign-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-cosign-plugin/CONTRIBUTING.adoc +++ b/asdf-cosign-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-cosign-plugin/CONTRIBUTING.md b/asdf-cosign-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-cosign-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-cosign-plugin/README.adoc b/asdf-cosign-plugin/README.adoc index d08e1dd2..c4df0e5e 100644 --- a/asdf-cosign-plugin/README.adoc +++ b/asdf-cosign-plugin/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-cosign -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-cosign-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-cosign-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-cosign-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-cosign-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://sigstore.dev[Cosign]. -**All repos with foreign function interfaces MUST follow this standard:** +Container signing from Sigstore. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add cosign https://github.com/hyperpolymath/asdf-cosign-plugin.git +---- -=== Web Projects +cosign: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all cosign -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install cosign latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global cosign latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now cosign commands are available +cosign --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list cosign -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local cosign -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall cosign ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-cosign-plugin/README.md b/asdf-cosign-plugin/README.md deleted file mode 100644 index 9d8e33c6..00000000 --- a/asdf-cosign-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-cosign - -[![Build](https://github.com/hyperpolymath/asdf-cosign-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-cosign-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-cosign-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-cosign-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Cosign](https://sigstore.dev). - -Container signing from Sigstore. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add cosign https://github.com/hyperpolymath/asdf-cosign-plugin.git -``` - -cosign: - -```bash -# Show all installable versions -asdf list-all cosign - -# Install specific version -asdf install cosign latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global cosign latest - -# Now cosign commands are available -cosign --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list cosign - -# Set local version for current directory -asdf local cosign - -# Uninstall a version -asdf uninstall cosign -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-cosign-plugin/SECURITY.adoc b/asdf-cosign-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-cosign-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-cosign-plugin/SECURITY.md b/asdf-cosign-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-cosign-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-couchdb-plugin/ABI-FFI-README.adoc b/asdf-couchdb-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..24c93349 --- /dev/null +++ b/asdf-couchdb-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== COUCHDB ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/couchdb.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libcouchdb.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +couchdb/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── couchdb.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── couchdb.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/couchdb.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "couchdb.h" + +int main() { + void* handle = couchdb_init(); + if (!handle) return 1; + + int result = couchdb_process(handle, 42); + if (result != 0) { + const char* err = couchdb_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + couchdb_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lcouchdb -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import COUCHDB.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "couchdb")] +extern "C" { + fn couchdb_init() -> *mut std::ffi::c_void; + fn couchdb_free(handle: *mut std::ffi::c_void); + fn couchdb_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = couchdb_init(); + assert!(!handle.is_null()); + + let result = couchdb_process(handle, 42); + assert_eq!(result, 0); + + couchdb_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libcouchdb = "libcouchdb" + +function init() + handle = ccall((:couchdb_init, libcouchdb), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:couchdb_process, libcouchdb), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:couchdb_free, libcouchdb), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/couchdb.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-couchdb-plugin/ABI-FFI-README.md b/asdf-couchdb-plugin/ABI-FFI-README.md deleted file mode 100644 index e724fafc..00000000 --- a/asdf-couchdb-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# COUCHDB ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/couchdb.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libcouchdb.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -couchdb/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── couchdb.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── couchdb.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/couchdb.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "couchdb.h" - -int main() { - void* handle = couchdb_init(); - if (!handle) return 1; - - int result = couchdb_process(handle, 42); - if (result != 0) { - const char* err = couchdb_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - couchdb_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lcouchdb -L./zig-out/lib -``` - -### From Idris2 - -```idris -import COUCHDB.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "couchdb")] -extern "C" { - fn couchdb_init() -> *mut std::ffi::c_void; - fn couchdb_free(handle: *mut std::ffi::c_void); - fn couchdb_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = couchdb_init(); - assert!(!handle.is_null()); - - let result = couchdb_process(handle, 42); - assert_eq!(result, 0); - - couchdb_free(handle); - } -} -``` - -### From Julia - -```julia -const libcouchdb = "libcouchdb" - -function init() - handle = ccall((:couchdb_init, libcouchdb), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:couchdb_process, libcouchdb), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:couchdb_free, libcouchdb), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/couchdb.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-couchdb-plugin/CODE_OF_CONDUCT.adoc b/asdf-couchdb-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-couchdb-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-couchdb-plugin/CODE_OF_CONDUCT.md b/asdf-couchdb-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-couchdb-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-couchdb-plugin/CONTRIBUTING.adoc b/asdf-couchdb-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-couchdb-plugin/CONTRIBUTING.adoc +++ b/asdf-couchdb-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-couchdb-plugin/CONTRIBUTING.md b/asdf-couchdb-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-couchdb-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-couchdb-plugin/README.adoc b/asdf-couchdb-plugin/README.adoc index d08e1dd2..cf4866d3 100644 --- a/asdf-couchdb-plugin/README.adoc +++ b/asdf-couchdb-plugin/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-couchdb -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-couchdb-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-couchdb-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-couchdb-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-couchdb-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://couchdb.apache.org[Apache +CouchDB]. -**All repos with foreign function interfaces MUST follow this standard:** +NoSQL document database. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add couchdb https://github.com/hyperpolymath/asdf-couchdb-plugin.git +---- -=== Web Projects +couchdb: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all couchdb -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install couchdb latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global couchdb latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now couchdb commands are available +couchdb --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list couchdb -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local couchdb -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall couchdb ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-couchdb-plugin/README.md b/asdf-couchdb-plugin/README.md deleted file mode 100644 index 374c8a7e..00000000 --- a/asdf-couchdb-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-couchdb - -[![Build](https://github.com/hyperpolymath/asdf-couchdb-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-couchdb-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-couchdb-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-couchdb-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Apache CouchDB](https://couchdb.apache.org). - -NoSQL document database. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add couchdb https://github.com/hyperpolymath/asdf-couchdb-plugin.git -``` - -couchdb: - -```bash -# Show all installable versions -asdf list-all couchdb - -# Install specific version -asdf install couchdb latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global couchdb latest - -# Now couchdb commands are available -couchdb --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list couchdb - -# Set local version for current directory -asdf local couchdb - -# Uninstall a version -asdf uninstall couchdb -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-couchdb-plugin/SECURITY.adoc b/asdf-couchdb-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-couchdb-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-couchdb-plugin/SECURITY.md b/asdf-couchdb-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-couchdb-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-cue-plugin/ABI-FFI-README.adoc b/asdf-cue-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..850cf0c3 --- /dev/null +++ b/asdf-cue-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== CUE ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/cue.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libcue.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +cue/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── cue.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── cue.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/cue.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "cue.h" + +int main() { + void* handle = cue_init(); + if (!handle) return 1; + + int result = cue_process(handle, 42); + if (result != 0) { + const char* err = cue_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + cue_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lcue -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import CUE.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "cue")] +extern "C" { + fn cue_init() -> *mut std::ffi::c_void; + fn cue_free(handle: *mut std::ffi::c_void); + fn cue_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = cue_init(); + assert!(!handle.is_null()); + + let result = cue_process(handle, 42); + assert_eq!(result, 0); + + cue_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libcue = "libcue" + +function init() + handle = ccall((:cue_init, libcue), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:cue_process, libcue), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:cue_free, libcue), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/cue.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-cue-plugin/ABI-FFI-README.md b/asdf-cue-plugin/ABI-FFI-README.md deleted file mode 100644 index 3bd1487e..00000000 --- a/asdf-cue-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# CUE ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/cue.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libcue.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -cue/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── cue.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── cue.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/cue.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "cue.h" - -int main() { - void* handle = cue_init(); - if (!handle) return 1; - - int result = cue_process(handle, 42); - if (result != 0) { - const char* err = cue_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - cue_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lcue -L./zig-out/lib -``` - -### From Idris2 - -```idris -import CUE.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "cue")] -extern "C" { - fn cue_init() -> *mut std::ffi::c_void; - fn cue_free(handle: *mut std::ffi::c_void); - fn cue_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = cue_init(); - assert!(!handle.is_null()); - - let result = cue_process(handle, 42); - assert_eq!(result, 0); - - cue_free(handle); - } -} -``` - -### From Julia - -```julia -const libcue = "libcue" - -function init() - handle = ccall((:cue_init, libcue), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:cue_process, libcue), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:cue_free, libcue), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/cue.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-cue-plugin/CODE_OF_CONDUCT.adoc b/asdf-cue-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-cue-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-cue-plugin/CODE_OF_CONDUCT.md b/asdf-cue-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-cue-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-cue-plugin/CONTRIBUTING.adoc b/asdf-cue-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-cue-plugin/CONTRIBUTING.adoc +++ b/asdf-cue-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-cue-plugin/CONTRIBUTING.md b/asdf-cue-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-cue-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-cue-plugin/README.adoc b/asdf-cue-plugin/README.adoc index d08e1dd2..51879d59 100644 --- a/asdf-cue-plugin/README.adoc +++ b/asdf-cue-plugin/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-cue -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-cue-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-cue-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-cue-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-cue-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://cuelang.org[CUE]. -**All repos with foreign function interfaces MUST follow this standard:** +Data validation language. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add cue https://github.com/hyperpolymath/asdf-cue-plugin.git +---- -=== Web Projects +cue: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all cue -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install cue latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global cue latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now cue commands are available +cue --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list cue -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local cue -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall cue ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-cue-plugin/README.md b/asdf-cue-plugin/README.md deleted file mode 100644 index fbf1b418..00000000 --- a/asdf-cue-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-cue - -[![Build](https://github.com/hyperpolymath/asdf-cue-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-cue-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-cue-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-cue-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [CUE](https://cuelang.org). - -Data validation language. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add cue https://github.com/hyperpolymath/asdf-cue-plugin.git -``` - -cue: - -```bash -# Show all installable versions -asdf list-all cue - -# Install specific version -asdf install cue latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global cue latest - -# Now cue commands are available -cue --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list cue - -# Set local version for current directory -asdf local cue - -# Uninstall a version -asdf uninstall cue -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-cue-plugin/SECURITY.adoc b/asdf-cue-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-cue-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-cue-plugin/SECURITY.md b/asdf-cue-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-cue-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-deno-plugin/ABI-FFI-README.adoc b/asdf-deno-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..ba563468 --- /dev/null +++ b/asdf-deno-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== DENO ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/deno.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libdeno.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +deno/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── deno.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── deno.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/deno.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "deno.h" + +int main() { + void* handle = deno_init(); + if (!handle) return 1; + + int result = deno_process(handle, 42); + if (result != 0) { + const char* err = deno_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + deno_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -ldeno -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import DENO.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "deno")] +extern "C" { + fn deno_init() -> *mut std::ffi::c_void; + fn deno_free(handle: *mut std::ffi::c_void); + fn deno_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = deno_init(); + assert!(!handle.is_null()); + + let result = deno_process(handle, 42); + assert_eq!(result, 0); + + deno_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libdeno = "libdeno" + +function init() + handle = ccall((:deno_init, libdeno), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:deno_process, libdeno), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:deno_free, libdeno), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/deno.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-deno-plugin/ABI-FFI-README.md b/asdf-deno-plugin/ABI-FFI-README.md deleted file mode 100644 index 10bd75bc..00000000 --- a/asdf-deno-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# DENO ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/deno.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libdeno.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -deno/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── deno.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── deno.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/deno.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "deno.h" - -int main() { - void* handle = deno_init(); - if (!handle) return 1; - - int result = deno_process(handle, 42); - if (result != 0) { - const char* err = deno_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - deno_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -ldeno -L./zig-out/lib -``` - -### From Idris2 - -```idris -import DENO.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "deno")] -extern "C" { - fn deno_init() -> *mut std::ffi::c_void; - fn deno_free(handle: *mut std::ffi::c_void); - fn deno_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = deno_init(); - assert!(!handle.is_null()); - - let result = deno_process(handle, 42); - assert_eq!(result, 0); - - deno_free(handle); - } -} -``` - -### From Julia - -```julia -const libdeno = "libdeno" - -function init() - handle = ccall((:deno_init, libdeno), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:deno_process, libdeno), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:deno_free, libdeno), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/deno.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-deno-plugin/CODE_OF_CONDUCT.adoc b/asdf-deno-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-deno-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-deno-plugin/CODE_OF_CONDUCT.md b/asdf-deno-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-deno-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-deno-plugin/CONTRIBUTING.adoc b/asdf-deno-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-deno-plugin/CONTRIBUTING.adoc +++ b/asdf-deno-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-deno-plugin/CONTRIBUTING.md b/asdf-deno-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-deno-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-deno-plugin/README.adoc b/asdf-deno-plugin/README.adoc index d08e1dd2..06e1239d 100644 --- a/asdf-deno-plugin/README.adoc +++ b/asdf-deno-plugin/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-deno -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-deno-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-deno-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-deno-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-deno-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://deno.land[Deno]. -**All repos with foreign function interfaces MUST follow this standard:** +Secure TypeScript/JavaScript runtime. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add deno https://github.com/hyperpolymath/asdf-deno-plugin.git +---- -=== Web Projects +deno: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all deno -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install deno latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global deno latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now deno commands are available +deno --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list deno -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local deno -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall deno ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-deno-plugin/README.md b/asdf-deno-plugin/README.md deleted file mode 100644 index c07cf267..00000000 --- a/asdf-deno-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-deno - -[![Build](https://github.com/hyperpolymath/asdf-deno-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-deno-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-deno-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-deno-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Deno](https://deno.land). - -Secure TypeScript/JavaScript runtime. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add deno https://github.com/hyperpolymath/asdf-deno-plugin.git -``` - -deno: - -```bash -# Show all installable versions -asdf list-all deno - -# Install specific version -asdf install deno latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global deno latest - -# Now deno commands are available -deno --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list deno - -# Set local version for current directory -asdf local deno - -# Uninstall a version -asdf uninstall deno -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-deno-plugin/SECURITY.adoc b/asdf-deno-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-deno-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-deno-plugin/SECURITY.md b/asdf-deno-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-deno-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-dhall-plugin/ABI-FFI-README.adoc b/asdf-dhall-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..14b6a8a8 --- /dev/null +++ b/asdf-dhall-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== DHALL ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/dhall.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libdhall.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +dhall/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── dhall.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── dhall.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/dhall.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "dhall.h" + +int main() { + void* handle = dhall_init(); + if (!handle) return 1; + + int result = dhall_process(handle, 42); + if (result != 0) { + const char* err = dhall_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + dhall_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -ldhall -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import DHALL.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "dhall")] +extern "C" { + fn dhall_init() -> *mut std::ffi::c_void; + fn dhall_free(handle: *mut std::ffi::c_void); + fn dhall_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = dhall_init(); + assert!(!handle.is_null()); + + let result = dhall_process(handle, 42); + assert_eq!(result, 0); + + dhall_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libdhall = "libdhall" + +function init() + handle = ccall((:dhall_init, libdhall), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:dhall_process, libdhall), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:dhall_free, libdhall), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/dhall.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-dhall-plugin/ABI-FFI-README.md b/asdf-dhall-plugin/ABI-FFI-README.md deleted file mode 100644 index 91fc1481..00000000 --- a/asdf-dhall-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# DHALL ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/dhall.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libdhall.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -dhall/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── dhall.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── dhall.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/dhall.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "dhall.h" - -int main() { - void* handle = dhall_init(); - if (!handle) return 1; - - int result = dhall_process(handle, 42); - if (result != 0) { - const char* err = dhall_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - dhall_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -ldhall -L./zig-out/lib -``` - -### From Idris2 - -```idris -import DHALL.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "dhall")] -extern "C" { - fn dhall_init() -> *mut std::ffi::c_void; - fn dhall_free(handle: *mut std::ffi::c_void); - fn dhall_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = dhall_init(); - assert!(!handle.is_null()); - - let result = dhall_process(handle, 42); - assert_eq!(result, 0); - - dhall_free(handle); - } -} -``` - -### From Julia - -```julia -const libdhall = "libdhall" - -function init() - handle = ccall((:dhall_init, libdhall), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:dhall_process, libdhall), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:dhall_free, libdhall), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/dhall.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-dhall-plugin/CODE_OF_CONDUCT.adoc b/asdf-dhall-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-dhall-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-dhall-plugin/CODE_OF_CONDUCT.md b/asdf-dhall-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-dhall-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-dhall-plugin/CONTRIBUTING.adoc b/asdf-dhall-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-dhall-plugin/CONTRIBUTING.adoc +++ b/asdf-dhall-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-dhall-plugin/CONTRIBUTING.md b/asdf-dhall-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-dhall-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-dhall-plugin/README.adoc b/asdf-dhall-plugin/README.adoc index d08e1dd2..ca06ba48 100644 --- a/asdf-dhall-plugin/README.adoc +++ b/asdf-dhall-plugin/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-dhall -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-dhall-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-dhall-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-dhall-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-dhall-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://dhall-lang.org[Dhall]. -**All repos with foreign function interfaces MUST follow this standard:** +Programmable configuration. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add dhall https://github.com/hyperpolymath/asdf-dhall-plugin.git +---- -=== Web Projects +dhall: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all dhall -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install dhall latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global dhall latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now dhall commands are available +dhall --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list dhall -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local dhall -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall dhall ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-dhall-plugin/README.md b/asdf-dhall-plugin/README.md deleted file mode 100644 index 6faab96a..00000000 --- a/asdf-dhall-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-dhall - -[![Build](https://github.com/hyperpolymath/asdf-dhall-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-dhall-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-dhall-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-dhall-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Dhall](https://dhall-lang.org). - -Programmable configuration. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add dhall https://github.com/hyperpolymath/asdf-dhall-plugin.git -``` - -dhall: - -```bash -# Show all installable versions -asdf list-all dhall - -# Install specific version -asdf install dhall latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global dhall latest - -# Now dhall commands are available -dhall --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list dhall - -# Set local version for current directory -asdf local dhall - -# Uninstall a version -asdf uninstall dhall -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-dhall-plugin/SECURITY.adoc b/asdf-dhall-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-dhall-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-dhall-plugin/SECURITY.md b/asdf-dhall-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-dhall-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-doctl-plugin/ABI-FFI-README.adoc b/asdf-doctl-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..4d5d4fab --- /dev/null +++ b/asdf-doctl-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== DOCTL ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/doctl.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libdoctl.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +doctl/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── doctl.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── doctl.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/doctl.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "doctl.h" + +int main() { + void* handle = doctl_init(); + if (!handle) return 1; + + int result = doctl_process(handle, 42); + if (result != 0) { + const char* err = doctl_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + doctl_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -ldoctl -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import DOCTL.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "doctl")] +extern "C" { + fn doctl_init() -> *mut std::ffi::c_void; + fn doctl_free(handle: *mut std::ffi::c_void); + fn doctl_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = doctl_init(); + assert!(!handle.is_null()); + + let result = doctl_process(handle, 42); + assert_eq!(result, 0); + + doctl_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libdoctl = "libdoctl" + +function init() + handle = ccall((:doctl_init, libdoctl), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:doctl_process, libdoctl), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:doctl_free, libdoctl), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/doctl.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-doctl-plugin/ABI-FFI-README.md b/asdf-doctl-plugin/ABI-FFI-README.md deleted file mode 100644 index 0da3bc65..00000000 --- a/asdf-doctl-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# DOCTL ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/doctl.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libdoctl.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -doctl/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── doctl.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── doctl.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/doctl.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "doctl.h" - -int main() { - void* handle = doctl_init(); - if (!handle) return 1; - - int result = doctl_process(handle, 42); - if (result != 0) { - const char* err = doctl_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - doctl_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -ldoctl -L./zig-out/lib -``` - -### From Idris2 - -```idris -import DOCTL.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "doctl")] -extern "C" { - fn doctl_init() -> *mut std::ffi::c_void; - fn doctl_free(handle: *mut std::ffi::c_void); - fn doctl_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = doctl_init(); - assert!(!handle.is_null()); - - let result = doctl_process(handle, 42); - assert_eq!(result, 0); - - doctl_free(handle); - } -} -``` - -### From Julia - -```julia -const libdoctl = "libdoctl" - -function init() - handle = ccall((:doctl_init, libdoctl), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:doctl_process, libdoctl), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:doctl_free, libdoctl), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/doctl.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-doctl-plugin/CODE_OF_CONDUCT.adoc b/asdf-doctl-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-doctl-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-doctl-plugin/CODE_OF_CONDUCT.md b/asdf-doctl-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-doctl-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-doctl-plugin/CONTRIBUTING.adoc b/asdf-doctl-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-doctl-plugin/CONTRIBUTING.adoc +++ b/asdf-doctl-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-doctl-plugin/CONTRIBUTING.md b/asdf-doctl-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-doctl-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-doctl-plugin/README.adoc b/asdf-doctl-plugin/README.adoc index d08e1dd2..ccf6797a 100644 --- a/asdf-doctl-plugin/README.adoc +++ b/asdf-doctl-plugin/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-doctl -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-doctl-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-doctl-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-doctl-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-doctl-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://docs.digitalocean.com/reference/doctl[DigitalOcean CLI]. -**All repos with foreign function interfaces MUST follow this standard:** +DO command-line. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add doctl https://github.com/hyperpolymath/asdf-doctl-plugin.git +---- -=== Web Projects +doctl: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all doctl -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install doctl latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global doctl latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now doctl commands are available +doctl --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list doctl -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local doctl -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall doctl ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-doctl-plugin/README.md b/asdf-doctl-plugin/README.md deleted file mode 100644 index cf5eec8b..00000000 --- a/asdf-doctl-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-doctl - -[![Build](https://github.com/hyperpolymath/asdf-doctl-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-doctl-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-doctl-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-doctl-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [DigitalOcean CLI](https://docs.digitalocean.com/reference/doctl). - -DO command-line. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add doctl https://github.com/hyperpolymath/asdf-doctl-plugin.git -``` - -doctl: - -```bash -# Show all installable versions -asdf list-all doctl - -# Install specific version -asdf install doctl latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global doctl latest - -# Now doctl commands are available -doctl --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list doctl - -# Set local version for current directory -asdf local doctl - -# Uninstall a version -asdf uninstall doctl -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-doctl-plugin/SECURITY.adoc b/asdf-doctl-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-doctl-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-doctl-plugin/SECURITY.md b/asdf-doctl-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-doctl-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-dragonfly-plugin/ABI-FFI-README.adoc b/asdf-dragonfly-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..9959a0d9 --- /dev/null +++ b/asdf-dragonfly-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== DRAGONFLY ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/dragonfly.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libdragonfly.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +dragonfly/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── dragonfly.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── dragonfly.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/dragonfly.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "dragonfly.h" + +int main() { + void* handle = dragonfly_init(); + if (!handle) return 1; + + int result = dragonfly_process(handle, 42); + if (result != 0) { + const char* err = dragonfly_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + dragonfly_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -ldragonfly -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import DRAGONFLY.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "dragonfly")] +extern "C" { + fn dragonfly_init() -> *mut std::ffi::c_void; + fn dragonfly_free(handle: *mut std::ffi::c_void); + fn dragonfly_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = dragonfly_init(); + assert!(!handle.is_null()); + + let result = dragonfly_process(handle, 42); + assert_eq!(result, 0); + + dragonfly_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libdragonfly = "libdragonfly" + +function init() + handle = ccall((:dragonfly_init, libdragonfly), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:dragonfly_process, libdragonfly), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:dragonfly_free, libdragonfly), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/dragonfly.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-dragonfly-plugin/ABI-FFI-README.md b/asdf-dragonfly-plugin/ABI-FFI-README.md deleted file mode 100644 index f4a92036..00000000 --- a/asdf-dragonfly-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# DRAGONFLY ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/dragonfly.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libdragonfly.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -dragonfly/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── dragonfly.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── dragonfly.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/dragonfly.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "dragonfly.h" - -int main() { - void* handle = dragonfly_init(); - if (!handle) return 1; - - int result = dragonfly_process(handle, 42); - if (result != 0) { - const char* err = dragonfly_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - dragonfly_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -ldragonfly -L./zig-out/lib -``` - -### From Idris2 - -```idris -import DRAGONFLY.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "dragonfly")] -extern "C" { - fn dragonfly_init() -> *mut std::ffi::c_void; - fn dragonfly_free(handle: *mut std::ffi::c_void); - fn dragonfly_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = dragonfly_init(); - assert!(!handle.is_null()); - - let result = dragonfly_process(handle, 42); - assert_eq!(result, 0); - - dragonfly_free(handle); - } -} -``` - -### From Julia - -```julia -const libdragonfly = "libdragonfly" - -function init() - handle = ccall((:dragonfly_init, libdragonfly), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:dragonfly_process, libdragonfly), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:dragonfly_free, libdragonfly), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/dragonfly.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-dragonfly-plugin/CODE_OF_CONDUCT.adoc b/asdf-dragonfly-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-dragonfly-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-dragonfly-plugin/CODE_OF_CONDUCT.md b/asdf-dragonfly-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-dragonfly-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-dragonfly-plugin/CONTRIBUTING.adoc b/asdf-dragonfly-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-dragonfly-plugin/CONTRIBUTING.adoc +++ b/asdf-dragonfly-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-dragonfly-plugin/CONTRIBUTING.md b/asdf-dragonfly-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-dragonfly-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-dragonfly-plugin/README.adoc b/asdf-dragonfly-plugin/README.adoc index d08e1dd2..49b3536a 100644 --- a/asdf-dragonfly-plugin/README.adoc +++ b/asdf-dragonfly-plugin/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-dragonfly -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-dragonfly-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-dragonfly-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-dragonfly-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-dragonfly-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://dragonflydb.io[Dragonfly]. -**All repos with foreign function interfaces MUST follow this standard:** +Redis-compatible datastore. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add dragonfly https://github.com/hyperpolymath/asdf-dragonfly-plugin.git +---- -=== Web Projects +dragonfly: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all dragonfly -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install dragonfly latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global dragonfly latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now dragonfly commands are available +dragonfly --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list dragonfly -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local dragonfly -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall dragonfly ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-dragonfly-plugin/README.md b/asdf-dragonfly-plugin/README.md deleted file mode 100644 index 8ec1224b..00000000 --- a/asdf-dragonfly-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-dragonfly - -[![Build](https://github.com/hyperpolymath/asdf-dragonfly-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-dragonfly-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-dragonfly-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-dragonfly-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Dragonfly](https://dragonflydb.io). - -Redis-compatible datastore. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add dragonfly https://github.com/hyperpolymath/asdf-dragonfly-plugin.git -``` - -dragonfly: - -```bash -# Show all installable versions -asdf list-all dragonfly - -# Install specific version -asdf install dragonfly latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global dragonfly latest - -# Now dragonfly commands are available -dragonfly --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list dragonfly - -# Set local version for current directory -asdf local dragonfly - -# Uninstall a version -asdf uninstall dragonfly -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-dragonfly-plugin/SECURITY.adoc b/asdf-dragonfly-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-dragonfly-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-dragonfly-plugin/SECURITY.md b/asdf-dragonfly-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-dragonfly-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-envoy-plugin/CODE_OF_CONDUCT.adoc b/asdf-envoy-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-envoy-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-envoy-plugin/CODE_OF_CONDUCT.md b/asdf-envoy-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-envoy-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-envoy-plugin/CONTRIBUTING.adoc b/asdf-envoy-plugin/CONTRIBUTING.adoc index d18532b5..e86d3f29 100644 --- a/asdf-envoy-plugin/CONTRIBUTING.adoc +++ b/asdf-envoy-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-envoy-plugin.git cd +asdf-envoy-plugin -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-envoy-plugin-dev toolbox enter asdf-envoy-plugin-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-envoy-plugin/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-envoy-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-envoy-plugin/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-envoy-plugin/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-envoy-plugin/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-envoy-plugin/CONTRIBUTING.md b/asdf-envoy-plugin/CONTRIBUTING.md deleted file mode 100644 index f0947d18..00000000 --- a/asdf-envoy-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-envoy-plugin.git -cd asdf-envoy-plugin - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-envoy-plugin-dev -toolbox enter asdf-envoy-plugin-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-envoy-plugin/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-envoy-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-envoy-plugin/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-envoy-plugin/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-envoy-plugin/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-envoy-plugin/README.adoc b/asdf-envoy-plugin/README.adoc new file mode 100644 index 00000000..c236d9e1 --- /dev/null +++ b/asdf-envoy-plugin/README.adoc @@ -0,0 +1,83 @@ +== asdf-envoy + +https://github.com/hyperpolymath/asdf-envoy-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-envoy-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-envoy-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-envoy-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] + +https://asdf-vm.com[asdf] plugin for https://www.envoyproxy.io[Envoy +Proxy]. + +Cloud-native proxy. + +=== Contents + +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] + +=== Dependencies + +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] + +=== Install + +Plugin: + +[source,bash] +---- +asdf plugin add envoy https://github.com/hyperpolymath/asdf-envoy-plugin.git +---- + +envoy: + +[source,bash] +---- +# Show all installable versions +asdf list-all envoy + +# Install specific version +asdf install envoy latest + +# Set a version globally (in your ~/.tool-versions file) +asdf global envoy latest + +# Now envoy commands are available +envoy --version +---- + +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. + +=== Usage + +[source,bash] +---- +# List installed versions +asdf list envoy + +# Set local version for current directory +asdf local envoy + +# Uninstall a version +asdf uninstall envoy +---- + +=== Contributing + +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License + +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. + +''''' + +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-envoy-plugin/README.md b/asdf-envoy-plugin/README.md deleted file mode 100644 index c294b14f..00000000 --- a/asdf-envoy-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-envoy - -[![Build](https://github.com/hyperpolymath/asdf-envoy-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-envoy-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-envoy-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-envoy-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Envoy Proxy](https://www.envoyproxy.io). - -Cloud-native proxy. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add envoy https://github.com/hyperpolymath/asdf-envoy-plugin.git -``` - -envoy: - -```bash -# Show all installable versions -asdf list-all envoy - -# Install specific version -asdf install envoy latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global envoy latest - -# Now envoy commands are available -envoy --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list envoy - -# Set local version for current directory -asdf local envoy - -# Uninstall a version -asdf uninstall envoy -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-envoy-plugin/SECURITY.adoc b/asdf-envoy-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-envoy-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-envoy-plugin/SECURITY.md b/asdf-envoy-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-envoy-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-fornax-plugin/CODE_OF_CONDUCT.adoc b/asdf-fornax-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-fornax-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-fornax-plugin/CODE_OF_CONDUCT.md b/asdf-fornax-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-fornax-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-fornax-plugin/CONTRIBUTING.adoc b/asdf-fornax-plugin/CONTRIBUTING.adoc index d18532b5..16fd4e4f 100644 --- a/asdf-fornax-plugin/CONTRIBUTING.adoc +++ b/asdf-fornax-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-fornax-plugin.git cd +asdf-fornax-plugin -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-fornax-plugin-dev toolbox enter +asdf-fornax-plugin-dev # Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-fornax-plugin/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-fornax-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-fornax-plugin/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-fornax-plugin/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-fornax-plugin/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-fornax-plugin/CONTRIBUTING.md b/asdf-fornax-plugin/CONTRIBUTING.md deleted file mode 100644 index 3a40ee9c..00000000 --- a/asdf-fornax-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-fornax-plugin.git -cd asdf-fornax-plugin - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-fornax-plugin-dev -toolbox enter asdf-fornax-plugin-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-fornax-plugin/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-fornax-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-fornax-plugin/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-fornax-plugin/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-fornax-plugin/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-fornax-plugin/README.adoc b/asdf-fornax-plugin/README.adoc new file mode 100644 index 00000000..5bf382d3 --- /dev/null +++ b/asdf-fornax-plugin/README.adoc @@ -0,0 +1,83 @@ +== asdf-fornax + +https://github.com/hyperpolymath/asdf-fornax-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-fornax-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-fornax-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-fornax-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] + +https://asdf-vm.com[asdf] plugin for +https://github.com/katef/fornax[Fornax]. + +Static site generator. + +=== Contents + +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] + +=== Dependencies + +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] + +=== Install + +Plugin: + +[source,bash] +---- +asdf plugin add fornax https://github.com/hyperpolymath/asdf-fornax-plugin.git +---- + +fornax: + +[source,bash] +---- +# Show all installable versions +asdf list-all fornax + +# Install specific version +asdf install fornax latest + +# Set a version globally (in your ~/.tool-versions file) +asdf global fornax latest + +# Now fornax commands are available +fornax --version +---- + +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. + +=== Usage + +[source,bash] +---- +# List installed versions +asdf list fornax + +# Set local version for current directory +asdf local fornax + +# Uninstall a version +asdf uninstall fornax +---- + +=== Contributing + +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License + +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. + +''''' + +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-fornax-plugin/README.md b/asdf-fornax-plugin/README.md deleted file mode 100644 index 407fc39e..00000000 --- a/asdf-fornax-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-fornax - -[![Build](https://github.com/hyperpolymath/asdf-fornax-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-fornax-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-fornax-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-fornax-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Fornax](https://github.com/katef/fornax). - -Static site generator. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add fornax https://github.com/hyperpolymath/asdf-fornax-plugin.git -``` - -fornax: - -```bash -# Show all installable versions -asdf list-all fornax - -# Install specific version -asdf install fornax latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global fornax latest - -# Now fornax commands are available -fornax --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list fornax - -# Set local version for current directory -asdf local fornax - -# Uninstall a version -asdf uninstall fornax -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-fornax-plugin/SECURITY.adoc b/asdf-fornax-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-fornax-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-fornax-plugin/SECURITY.md b/asdf-fornax-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-fornax-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-fortran-plugin/CODE_OF_CONDUCT.adoc b/asdf-fortran-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-fortran-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-fortran-plugin/CODE_OF_CONDUCT.md b/asdf-fortran-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-fortran-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-fortran-plugin/CONTRIBUTING.adoc b/asdf-fortran-plugin/CONTRIBUTING.adoc index d18532b5..c1d537f7 100644 --- a/asdf-fortran-plugin/CONTRIBUTING.adoc +++ b/asdf-fortran-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-fortran-plugin.git cd +asdf-fortran-plugin -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-fortran-plugin-dev toolbox enter +asdf-fortran-plugin-dev # Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-fortran-plugin/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-fortran-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-fortran-plugin/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-fortran-plugin/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-fortran-plugin/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-fortran-plugin/CONTRIBUTING.md b/asdf-fortran-plugin/CONTRIBUTING.md deleted file mode 100644 index d6943f4a..00000000 --- a/asdf-fortran-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-fortran-plugin.git -cd asdf-fortran-plugin - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-fortran-plugin-dev -toolbox enter asdf-fortran-plugin-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-fortran-plugin/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-fortran-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-fortran-plugin/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-fortran-plugin/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-fortran-plugin/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-fortran-plugin/README.adoc b/asdf-fortran-plugin/README.adoc new file mode 100644 index 00000000..a297d1ad --- /dev/null +++ b/asdf-fortran-plugin/README.adoc @@ -0,0 +1,83 @@ +== asdf-fortran + +https://github.com/hyperpolymath/asdf-fortran-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-fortran-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-fortran-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-fortran-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] + +https://asdf-vm.com[asdf] plugin for +https://gcc.gnu.org/fortran[GFortran]. + +GNU Fortran compiler. + +=== Contents + +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] + +=== Dependencies + +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] + +=== Install + +Plugin: + +[source,bash] +---- +asdf plugin add fortran https://github.com/hyperpolymath/asdf-fortran-plugin.git +---- + +fortran: + +[source,bash] +---- +# Show all installable versions +asdf list-all fortran + +# Install specific version +asdf install fortran latest + +# Set a version globally (in your ~/.tool-versions file) +asdf global fortran latest + +# Now fortran commands are available +fortran --version +---- + +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. + +=== Usage + +[source,bash] +---- +# List installed versions +asdf list fortran + +# Set local version for current directory +asdf local fortran + +# Uninstall a version +asdf uninstall fortran +---- + +=== Contributing + +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License + +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. + +''''' + +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-fortran-plugin/README.md b/asdf-fortran-plugin/README.md deleted file mode 100644 index 78c8c1d8..00000000 --- a/asdf-fortran-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-fortran - -[![Build](https://github.com/hyperpolymath/asdf-fortran-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-fortran-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-fortran-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-fortran-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [GFortran](https://gcc.gnu.org/fortran). - -GNU Fortran compiler. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add fortran https://github.com/hyperpolymath/asdf-fortran-plugin.git -``` - -fortran: - -```bash -# Show all installable versions -asdf list-all fortran - -# Install specific version -asdf install fortran latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global fortran latest - -# Now fortran commands are available -fortran --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list fortran - -# Set local version for current directory -asdf local fortran - -# Uninstall a version -asdf uninstall fortran -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-fortran-plugin/SECURITY.adoc b/asdf-fortran-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-fortran-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-fortran-plugin/SECURITY.md b/asdf-fortran-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-fortran-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-franklin-plugin/CODE_OF_CONDUCT.adoc b/asdf-franklin-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-franklin-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-franklin-plugin/CODE_OF_CONDUCT.md b/asdf-franklin-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-franklin-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-franklin-plugin/CONTRIBUTING.adoc b/asdf-franklin-plugin/CONTRIBUTING.adoc index d18532b5..3e266b5e 100644 --- a/asdf-franklin-plugin/CONTRIBUTING.adoc +++ b/asdf-franklin-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-franklin-plugin.git cd +asdf-franklin-plugin -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-franklin-plugin-dev toolbox enter +asdf-franklin-plugin-dev # Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-franklin-plugin/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-franklin-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-franklin-plugin/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-franklin-plugin/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-franklin-plugin/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-franklin-plugin/CONTRIBUTING.md b/asdf-franklin-plugin/CONTRIBUTING.md deleted file mode 100644 index 9c51f54a..00000000 --- a/asdf-franklin-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-franklin-plugin.git -cd asdf-franklin-plugin - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-franklin-plugin-dev -toolbox enter asdf-franklin-plugin-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-franklin-plugin/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-franklin-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-franklin-plugin/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-franklin-plugin/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-franklin-plugin/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-franklin-plugin/README.adoc b/asdf-franklin-plugin/README.adoc new file mode 100644 index 00000000..f1f882c6 --- /dev/null +++ b/asdf-franklin-plugin/README.adoc @@ -0,0 +1,83 @@ +== asdf-franklin + +https://github.com/hyperpolymath/asdf-franklin-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-franklin-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-franklin-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-franklin-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] + +https://asdf-vm.com[asdf] plugin for +https://franklinjl.org[Franklin.jl]. + +Julia static site generator. + +=== Contents + +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] + +=== Dependencies + +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] + +=== Install + +Plugin: + +[source,bash] +---- +asdf plugin add franklin https://github.com/hyperpolymath/asdf-franklin-plugin.git +---- + +franklin: + +[source,bash] +---- +# Show all installable versions +asdf list-all franklin + +# Install specific version +asdf install franklin latest + +# Set a version globally (in your ~/.tool-versions file) +asdf global franklin latest + +# Now franklin commands are available +franklin --version +---- + +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. + +=== Usage + +[source,bash] +---- +# List installed versions +asdf list franklin + +# Set local version for current directory +asdf local franklin + +# Uninstall a version +asdf uninstall franklin +---- + +=== Contributing + +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License + +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. + +''''' + +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-franklin-plugin/README.md b/asdf-franklin-plugin/README.md deleted file mode 100644 index 72876015..00000000 --- a/asdf-franklin-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-franklin - -[![Build](https://github.com/hyperpolymath/asdf-franklin-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-franklin-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-franklin-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-franklin-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Franklin.jl](https://franklinjl.org). - -Julia static site generator. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add franklin https://github.com/hyperpolymath/asdf-franklin-plugin.git -``` - -franklin: - -```bash -# Show all installable versions -asdf list-all franklin - -# Install specific version -asdf install franklin latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global franklin latest - -# Now franklin commands are available -franklin --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list franklin - -# Set local version for current directory -asdf local franklin - -# Uninstall a version -asdf uninstall franklin -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-franklin-plugin/SECURITY.adoc b/asdf-franklin-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-franklin-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-franklin-plugin/SECURITY.md b/asdf-franklin-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-franklin-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-fulcio-plugin/CODE_OF_CONDUCT.adoc b/asdf-fulcio-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-fulcio-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-fulcio-plugin/CODE_OF_CONDUCT.md b/asdf-fulcio-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-fulcio-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-fulcio-plugin/CONTRIBUTING.adoc b/asdf-fulcio-plugin/CONTRIBUTING.adoc index d18532b5..1d015055 100644 --- a/asdf-fulcio-plugin/CONTRIBUTING.adoc +++ b/asdf-fulcio-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-fulcio-plugin.git cd +asdf-fulcio-plugin -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-fulcio-plugin-dev toolbox enter +asdf-fulcio-plugin-dev # Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-fulcio-plugin/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-fulcio-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-fulcio-plugin/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-fulcio-plugin/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-fulcio-plugin/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-fulcio-plugin/CONTRIBUTING.md b/asdf-fulcio-plugin/CONTRIBUTING.md deleted file mode 100644 index c61ac639..00000000 --- a/asdf-fulcio-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-fulcio-plugin.git -cd asdf-fulcio-plugin - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-fulcio-plugin-dev -toolbox enter asdf-fulcio-plugin-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-fulcio-plugin/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-fulcio-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-fulcio-plugin/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-fulcio-plugin/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-fulcio-plugin/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-fulcio-plugin/README.adoc b/asdf-fulcio-plugin/README.adoc new file mode 100644 index 00000000..b81f375d --- /dev/null +++ b/asdf-fulcio-plugin/README.adoc @@ -0,0 +1,82 @@ +== asdf-fulcio + +https://github.com/hyperpolymath/asdf-fulcio-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-fulcio-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-fulcio-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-fulcio-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] + +https://asdf-vm.com[asdf] plugin for https://sigstore.dev[Fulcio]. + +Sigstore certificate authority. + +=== Contents + +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] + +=== Dependencies + +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] + +=== Install + +Plugin: + +[source,bash] +---- +asdf plugin add fulcio https://github.com/hyperpolymath/asdf-fulcio-plugin.git +---- + +fulcio: + +[source,bash] +---- +# Show all installable versions +asdf list-all fulcio + +# Install specific version +asdf install fulcio latest + +# Set a version globally (in your ~/.tool-versions file) +asdf global fulcio latest + +# Now fulcio commands are available +fulcio --version +---- + +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. + +=== Usage + +[source,bash] +---- +# List installed versions +asdf list fulcio + +# Set local version for current directory +asdf local fulcio + +# Uninstall a version +asdf uninstall fulcio +---- + +=== Contributing + +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License + +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. + +''''' + +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-fulcio-plugin/README.md b/asdf-fulcio-plugin/README.md deleted file mode 100644 index 7779116b..00000000 --- a/asdf-fulcio-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-fulcio - -[![Build](https://github.com/hyperpolymath/asdf-fulcio-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-fulcio-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-fulcio-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-fulcio-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Fulcio](https://sigstore.dev). - -Sigstore certificate authority. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add fulcio https://github.com/hyperpolymath/asdf-fulcio-plugin.git -``` - -fulcio: - -```bash -# Show all installable versions -asdf list-all fulcio - -# Install specific version -asdf install fulcio latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global fulcio latest - -# Now fulcio commands are available -fulcio --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list fulcio - -# Set local version for current directory -asdf local fulcio - -# Uninstall a version -asdf uninstall fulcio -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-fulcio-plugin/SECURITY.adoc b/asdf-fulcio-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-fulcio-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-fulcio-plugin/SECURITY.md b/asdf-fulcio-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-fulcio-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-ghjk/CODE_OF_CONDUCT.adoc b/asdf-ghjk/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..b885ab02 --- /dev/null +++ b/asdf-ghjk/CODE_OF_CONDUCT.adoc @@ -0,0 +1,134 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We as members, contributors, and leaders pledge to make participation in +our community a harassment-free experience for everyone, regardless of +age, body size, visible or invisible disability, ethnicity, sex +characteristics, gender identity and expression, level of experience, +education, socio-economic status, nationality, personal appearance, +race, caste, color, religion, or sexual identity and orientation. + +We pledge to act and interact in ways that contribute to an open, +welcoming, diverse, inclusive, and healthy community. + +=== Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our +mistakes, and learning from the experience +* Focusing on what is best not just for us as individuals, but for the +overall community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or +advances of any kind +* Trolling, insulting or derogatory comments, and personal or political +attacks +* Public or private harassment +* Publishing others’ private information, such as a physical or email +address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a +professional setting + +=== Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our +standards of acceptable behavior and will take appropriate and fair +corrective action in response to any behavior that they deem +inappropriate, threatening, offensive, or harmful. + +Community leaders have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other +contributions that are not aligned to this Code of Conduct, and will +communicate reasons for moderation decisions when appropriate. + +=== Scope + +This Code of Conduct applies within all community spaces, and also +applies when an individual is officially representing the community in +public spaces. Examples of representing our community include using an +official e-mail address, posting via an official social media account, +or acting as an appointed representative at an online or offline event. + +=== Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may +be reported to the community leaders responsible for enforcement via +GitHub issues or by contacting the project maintainers directly. + +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security +of the reporter of any incident. + +=== Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in +determining the consequences for any action they deem in violation of +this Code of Conduct: + +==== 1. Correction + +*Community Impact*: Use of inappropriate language or other behavior +deemed unprofessional or unwelcome in the community. + +*Consequence*: A private, written warning from community leaders, +providing clarity around the nature of the violation and an explanation +of why the behavior was inappropriate. A public apology may be +requested. + +==== 2. Warning + +*Community Impact*: A violation through a single incident or series of +actions. + +*Consequence*: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, for a specified period of +time. This includes avoiding interactions in community spaces as well as +external channels like social media. Violating these terms may lead to a +temporary or permanent ban. + +==== 3. Temporary Ban + +*Community Impact*: A serious violation of community standards, +including sustained inappropriate behavior. + +*Consequence*: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No +public or private interaction with the people involved, including +unsolicited interaction with those enforcing the Code of Conduct, is +allowed during this period. Violating these terms may lead to a +permanent ban. + +==== 4. Permanent Ban + +*Community Impact*: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of +individuals. + +*Consequence*: A permanent ban from any sort of public interaction +within the community. + +=== Attribution + +This Code of Conduct is adapted from the +https://www.contributor-covenant.org[Contributor Covenant], version 2.1, +available at +https://www.contributor-covenant.org/version/2/1/code_of_conduct.html. + +Community Impact Guidelines were inspired by +https://github.com/mozilla/diversity[Mozilla’s code of conduct +enforcement ladder]. + +For answers to common questions about this code of conduct, see the FAQ +at https://www.contributor-covenant.org/faq. Translations are available +at https://www.contributor-covenant.org/translations. diff --git a/asdf-ghjk/CODE_OF_CONDUCT.md b/asdf-ghjk/CODE_OF_CONDUCT.md deleted file mode 100644 index 8ad2505b..00000000 --- a/asdf-ghjk/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,133 +0,0 @@ -# Contributor Covenant Code of Conduct - -## Our Pledge - -We as members, contributors, and leaders pledge to make participation in our -community a harassment-free experience for everyone, regardless of age, body -size, visible or invisible disability, ethnicity, sex characteristics, gender -identity and expression, level of experience, education, socio-economic status, -nationality, personal appearance, race, caste, color, religion, or sexual -identity and orientation. - -We pledge to act and interact in ways that contribute to an open, welcoming, -diverse, inclusive, and healthy community. - -## Our Standards - -Examples of behavior that contributes to a positive environment for our -community include: - -* Demonstrating empathy and kindness toward other people -* Being respectful of differing opinions, viewpoints, and experiences -* Giving and gracefully accepting constructive feedback -* Accepting responsibility and apologizing to those affected by our mistakes, - and learning from the experience -* Focusing on what is best not just for us as individuals, but for the overall - community - -Examples of unacceptable behavior include: - -* The use of sexualized language or imagery, and sexual attention or advances of - any kind -* Trolling, insulting or derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or email address, - without their explicit permission -* Other conduct which could reasonably be considered inappropriate in a - professional setting - -## Enforcement Responsibilities - -Community leaders are responsible for clarifying and enforcing our standards of -acceptable behavior and will take appropriate and fair corrective action in -response to any behavior that they deem inappropriate, threatening, offensive, -or harmful. - -Community leaders have the right and responsibility to remove, edit, or reject -comments, commits, code, wiki edits, issues, and other contributions that are -not aligned to this Code of Conduct, and will communicate reasons for moderation -decisions when appropriate. - -## Scope - -This Code of Conduct applies within all community spaces, and also applies when -an individual is officially representing the community in public spaces. -Examples of representing our community include using an official e-mail address, -posting via an official social media account, or acting as an appointed -representative at an online or offline event. - -## Enforcement - -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported to the community leaders responsible for enforcement via GitHub issues -or by contacting the project maintainers directly. - -All complaints will be reviewed and investigated promptly and fairly. - -All community leaders are obligated to respect the privacy and security of the -reporter of any incident. - -## Enforcement Guidelines - -Community leaders will follow these Community Impact Guidelines in determining -the consequences for any action they deem in violation of this Code of Conduct: - -### 1. Correction - -**Community Impact**: Use of inappropriate language or other behavior deemed -unprofessional or unwelcome in the community. - -**Consequence**: A private, written warning from community leaders, providing -clarity around the nature of the violation and an explanation of why the -behavior was inappropriate. A public apology may be requested. - -### 2. Warning - -**Community Impact**: A violation through a single incident or series of -actions. - -**Consequence**: A warning with consequences for continued behavior. No -interaction with the people involved, including unsolicited interaction with -those enforcing the Code of Conduct, for a specified period of time. This -includes avoiding interactions in community spaces as well as external channels -like social media. Violating these terms may lead to a temporary or permanent -ban. - -### 3. Temporary Ban - -**Community Impact**: A serious violation of community standards, including -sustained inappropriate behavior. - -**Consequence**: A temporary ban from any sort of interaction or public -communication with the community for a specified period of time. No public or -private interaction with the people involved, including unsolicited interaction -with those enforcing the Code of Conduct, is allowed during this period. -Violating these terms may lead to a permanent ban. - -### 4. Permanent Ban - -**Community Impact**: Demonstrating a pattern of violation of community -standards, including sustained inappropriate behavior, harassment of an -individual, or aggression toward or disparagement of classes of individuals. - -**Consequence**: A permanent ban from any sort of public interaction within the -community. - -## Attribution - -This Code of Conduct is adapted from the [Contributor Covenant][homepage], -version 2.1, available at -[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. - -Community Impact Guidelines were inspired by -[Mozilla's code of conduct enforcement ladder][Mozilla CoC]. - -For answers to common questions about this code of conduct, see the FAQ at -[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at -[https://www.contributor-covenant.org/translations][translations]. - -[homepage]: https://www.contributor-covenant.org -[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html -[Mozilla CoC]: https://github.com/mozilla/diversity -[FAQ]: https://www.contributor-covenant.org/faq -[translations]: https://www.contributor-covenant.org/translations diff --git a/asdf-ghjk/CONTRIBUTING.adoc b/asdf-ghjk/CONTRIBUTING.adoc index eb045d61..780e2775 100644 --- a/asdf-ghjk/CONTRIBUTING.adoc +++ b/asdf-ghjk/CONTRIBUTING.adoc @@ -1,20 +1,108 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-ghjk.git cd asdf-ghjk -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-ghjk-dev toolbox enter asdf-ghjk-dev # Install +dependencies manually -Contributions licensed under project license. +== Verify setup +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-ghjk/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # Library +code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) ├── +plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) ├── +docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, specs +(Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ # +Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ # +Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files (Perimeter +1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── ISSUE_TEMPLATE/ │ +└── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── +CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-ghjk/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-ghjk/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-ghjk/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-ghjk/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-ghjk/CONTRIBUTING.md b/asdf-ghjk/CONTRIBUTING.md deleted file mode 100644 index 4f7fb5b7..00000000 --- a/asdf-ghjk/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-ghjk.git -cd asdf-ghjk - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-ghjk-dev -toolbox enter asdf-ghjk-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-ghjk/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-ghjk/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-ghjk/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-ghjk/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-ghjk/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-ghjk/MAINTAINERS.adoc b/asdf-ghjk/MAINTAINERS.adoc index 48d97817..c57da9d0 100644 --- a/asdf-ghjk/MAINTAINERS.adoc +++ b/asdf-ghjk/MAINTAINERS.adoc @@ -1,47 +1,108 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Maintainers -:toc: preamble +== Maintainers -This document lists the maintainers of this project and their responsibilities. +This document lists the maintainers of the asdf-ghjk project. -== Current Maintainers +=== Active Maintainers -[cols="2,3,2",options="header"] -|=== -| Name | Role | Contact +==== Core Maintainers -| Jonathan D.A. Jewell -| Lead Maintainer -| https://github.com/hyperpolymath[@hyperpolymath] +[width="100%",cols="17%,21%,15%,47%",options="header",] +|=== +|Name |GitHub |Role |Responsibilities +|Hyperpolymath |@Hyperpolymath |Lead Maintainer |Overall project +direction, releases, core features |=== -== Responsibilities +=== Maintainer Responsibilities Maintainers are responsible for: -* Reviewing and merging pull requests -* Triaging issues and feature requests -* Ensuring code quality and security standards -* Managing releases and versioning -* Upholding the project's code of conduct +[arabic] +. *Code Review*: Reviewing and merging pull requests +. *Issue Triage*: Labeling, prioritizing, and closing issues +. *Releases*: Creating and publishing releases +. *Security*: Responding to security issues and coordinating fixes +. *Community*: Fostering a welcoming and inclusive community +. *Documentation*: Maintaining and improving documentation +. *CI/CD*: Maintaining build and test infrastructure + +=== Becoming a Maintainer + +We welcome new maintainers! To become a maintainer: + +[arabic] +. *Contribute Consistently*: Make regular, high-quality contributions +. *Demonstrate Expertise*: Show deep understanding of the project +. *Help Others*: Actively participate in code reviews and discussions +. *Follow Guidelines*: Adhere to project standards and Code of Conduct +. *Nomination*: Existing maintainers will nominate and vote on new +maintainers + +==== Criteria + +* 10+ merged pull requests +* 3+ months of active participation +* Demonstrated technical expertise +* Strong communication skills +* Commitment to project values + +=== Emeritus Maintainers + +Maintainers who are no longer active but have made significant +contributions: + +[cols=",,,",options="header",] +|=== +|Name |GitHub |Period |Contributions +|_None yet_ |- |- |- +|=== + +=== Decision Making + +==== Consensus-Based + +We use consensus-based decision making: + +[arabic] +. *Proposal*: Anyone can propose changes via issues or discussions +. *Discussion*: Community discusses the proposal +. *Consensus*: Maintainers reach consensus (not unanimous vote) +. *Implementation*: Approved proposals are implemented + +==== Voting + +For significant decisions where consensus cannot be reached: + +* Simple majority of active maintainers +* Lead maintainer has tie-breaking vote +* All maintainers must be notified + +==== Significant Decisions + +These require explicit maintainer consensus: -== Becoming a Maintainer +* Breaking changes to public APIs +* Major architectural changes +* Addition/removal of dependencies +* Changes to contribution guidelines +* Addition/removal of maintainers +* License changes -Contributors who demonstrate: +=== Contact -* Consistent, high-quality contributions -* Understanding of the project's goals and standards -* Constructive participation in discussions -* Commitment to the project's long-term health +* *General Questions*: Open an issue +* *Security Issues*: See SECURITY.md +* *Private Matters*: Contact maintainers via GitHub -May be invited to become maintainers at the discretion of existing maintainers. +=== Acknowledgments -== Decision Making +Thank you to all our contributors! See the +https://github.com/Hyperpolymath/asdf-ghjk/graphs/contributors[contributors +page] for a full list. -* Routine decisions (bug fixes, minor improvements) can be made by any maintainer -* Significant changes require discussion and consensus among maintainers -* Breaking changes or major features should be discussed in issues before implementation +''''' -== Contact +*Note*: This document follows the RSR (Rhodium Standard Repository) +Framework’s MAINTAINERS.md specification. -For questions about project governance, open an issue or contact the maintainers listed above. +*Last Updated*: 2024-11-22 diff --git a/asdf-ghjk/MAINTAINERS.md b/asdf-ghjk/MAINTAINERS.md deleted file mode 100644 index 4e768daf..00000000 --- a/asdf-ghjk/MAINTAINERS.md +++ /dev/null @@ -1,95 +0,0 @@ -# Maintainers - -This document lists the maintainers of the asdf-ghjk project. - -## Active Maintainers - -### Core Maintainers - -| Name | GitHub | Role | Responsibilities | -|------|--------|------|------------------| -| Hyperpolymath | @Hyperpolymath | Lead Maintainer | Overall project direction, releases, core features | - -## Maintainer Responsibilities - -Maintainers are responsible for: - -1. **Code Review**: Reviewing and merging pull requests -2. **Issue Triage**: Labeling, prioritizing, and closing issues -3. **Releases**: Creating and publishing releases -4. **Security**: Responding to security issues and coordinating fixes -5. **Community**: Fostering a welcoming and inclusive community -6. **Documentation**: Maintaining and improving documentation -7. **CI/CD**: Maintaining build and test infrastructure - -## Becoming a Maintainer - -We welcome new maintainers! To become a maintainer: - -1. **Contribute Consistently**: Make regular, high-quality contributions -2. **Demonstrate Expertise**: Show deep understanding of the project -3. **Help Others**: Actively participate in code reviews and discussions -4. **Follow Guidelines**: Adhere to project standards and Code of Conduct -5. **Nomination**: Existing maintainers will nominate and vote on new maintainers - -### Criteria - -- 10+ merged pull requests -- 3+ months of active participation -- Demonstrated technical expertise -- Strong communication skills -- Commitment to project values - -## Emeritus Maintainers - -Maintainers who are no longer active but have made significant contributions: - -| Name | GitHub | Period | Contributions | -|------|--------|--------|---------------| -| _None yet_ | - | - | - | - -## Decision Making - -### Consensus-Based - -We use consensus-based decision making: - -1. **Proposal**: Anyone can propose changes via issues or discussions -2. **Discussion**: Community discusses the proposal -3. **Consensus**: Maintainers reach consensus (not unanimous vote) -4. **Implementation**: Approved proposals are implemented - -### Voting - -For significant decisions where consensus cannot be reached: - -- Simple majority of active maintainers -- Lead maintainer has tie-breaking vote -- All maintainers must be notified - -### Significant Decisions - -These require explicit maintainer consensus: - -- Breaking changes to public APIs -- Major architectural changes -- Addition/removal of dependencies -- Changes to contribution guidelines -- Addition/removal of maintainers -- License changes - -## Contact - -- **General Questions**: Open an issue -- **Security Issues**: See SECURITY.md -- **Private Matters**: Contact maintainers via GitHub - -## Acknowledgments - -Thank you to all our contributors! See the [contributors page](https://github.com/Hyperpolymath/asdf-ghjk/graphs/contributors) for a full list. - ---- - -**Note**: This document follows the RSR (Rhodium Standard Repository) Framework's MAINTAINERS.md specification. - -**Last Updated**: 2024-11-22 diff --git a/asdf-ghjk/PROJECT_SUMMARY.adoc b/asdf-ghjk/PROJECT_SUMMARY.adoc new file mode 100644 index 00000000..f32bec69 --- /dev/null +++ b/asdf-ghjk/PROJECT_SUMMARY.adoc @@ -0,0 +1,499 @@ +== asdf-ghjk: Complete Project Summary + +*Branch*: `+claude/create-claude-md-0185REoNFa5vvHxsmFjiaNKc+` +*Completion Date*: 2024-11-22 *Total Files*: 60+ *Total Lines*: 7,200+ +*RSR Level*: *Platinum* (100% compliance) *Development Time*: ~1 session +with maximum credit utilization + +''''' + +=== 🎉 Achievement: RSR Platinum Level + +*RSR Score: 100% (73/73 checks passed)* + +This project has achieved the highest possible RSR (Rhodium Standard +Repository) Framework compliance level, making it suitable for: - +Enterprise production use - Open source community collaboration - +Academic research reference - Professional portfolio showcase + +''''' + +=== 📊 What Was Built + +==== Core Functionality (Production-Ready) + +* ✅ Full asdf plugin implementation (list-all, download, install) +* ✅ Multi-platform support (Linux x86_64/ARM64, macOS Intel/Apple +Silicon) +* ✅ SHA256 checksum verification for security +* ✅ GitHub API caching with configurable TTL +* ✅ Retry logic with exponential backoff +* ✅ Comprehensive error handling and logging + +==== Documentation (14 Comprehensive Guides) + +[arabic] +. *README.md* - Complete user guide with examples +. *CONTRIBUTING.md* - Developer contribution guide +. *CODE_OF_CONDUCT.md* - Contributor Covenant 2.1 +. *MAINTAINERS.md* - Governance and maintainer info +. *SECURITY.md* - Security policy and vulnerability disclosure +. *CHANGELOG.md* - Version history (Keep a Changelog format) +. *ARCHITECTURE.md* - Internal architecture and design +. *API_REFERENCE.md* - Complete function/script reference +. *FAQ.md* - 30+ frequently asked questions +. *QUICKSTART.md* - 5-minute setup guide +. *TROUBLESHOOTING.md* - Solutions to common issues +. *EXAMPLES.md* - Real-world usage scenarios +. *MIGRATION.md* - Migration from standalone ghjk +. *COMPATIBILITY.md* - Platform/version compatibility matrix +. *RSR.md* - RSR Framework compliance documentation + +*Total Documentation*: 10,000+ words + +==== Testing (Comprehensive Coverage) + +* ✅ BATS test suite (unit + integration) +* ✅ 5 test files covering all core functionality +* ✅ Test helpers and fixtures +* ✅ GitHub Actions CI/CD +* ✅ Multi-platform testing (Ubuntu, macOS) +* ✅ ShellCheck linting for all scripts +* ✅ 100% test pass rate + +==== Build Systems (Triple Support) + +[arabic] +. *Makefile* - Traditional GNU Make automation +. *justfile* - Modern task runner with 50+ recipes +. *flake.guix* - Guix reproducible builds + +==== Developer Tools + +* ✅ `+scripts/setup-dev.sh+` - Development environment setup +* ✅ `+scripts/test.sh+` - Test runner +* ✅ `+scripts/benchmark.sh+` - Performance benchmarking +* ✅ `+scripts/doctor.sh+` - Diagnostic troubleshooting +* ✅ `+scripts/cleanup.sh+` - Disk usage management +* ✅ `+scripts/rsr-verify.sh+` - RSR compliance verification + +==== Advanced Features + +* ✅ Shell completions (Bash & Zsh) +* ✅ Docker integration (3 examples) +* ✅ Latest-stable version detection +* ✅ API response caching (configurable TTL) +* ✅ Pre-commit hooks configuration + +==== .well-known Directory (RFC Standards) + +* ✅ `+security.txt+` - RFC 9116 compliant security contact +* ✅ `+ai.txt+` - AI training and usage policy +* ✅ `+humans.txt+` - Human-readable attribution + +==== Licensing + +* ✅ Dual licensing: MIT + Palimpsest v0.8 +* ✅ User choice of license +* ✅ SPDX identifiers +* ✅ OSI-approved permissive terms + +==== Quality Assurance + +* ✅ GitHub issue templates (bug, feature request) +* ✅ Pull request template +* ✅ CODEOWNERS for automated reviews +* ✅ EditorConfig for consistency +* ✅ Comprehensive .gitignore + +''''' + +=== 📈 RSR Compliance Breakdown + +==== Category Scores (All 100%) + +[cols=",,,",options="header",] +|=== +|Category |Checks |Passed |Score +|1. Documentation |14 |14 |✅ 100% +|2. Licensing |5 |5 |✅ 100% +|3. Security |6 |6 |✅ 100% +|4. Contributing |6 |6 |✅ 100% +|5. Governance |6 |6 |✅ 100% +|6. Testing |6 |6 |✅ 100% +|7. Build System |7 |7 |✅ 100% +|8. Versioning |3 |3 |✅ 100% +|9. .well-known |6 |6 |✅ 100% +|10. Community |4 |4 |✅ 100% +|11. Automation |5 |5 |✅ 100% +|*Bonus Markers* |5 |5 |✅ 100% +|*TOTAL* |*73* |*73* |*✅ 100%* +|=== + +==== TPCF Declaration + +*Perimeter*: *3 - Community Sandbox* + +*Characteristics*: - Open to all contributors - Maintainer review +required - Community-driven governance - Consensus-based decision making +- Pull request workflow - Public trust model + +''''' + +=== 🗂️ File Structure + +.... +asdf-ghjk/ (60 files) +├── bin/ (6 scripts) +│ ├── download - Download ghjk releases +│ ├── install - Install downloaded releases +│ ├── list-all - List available versions +│ ├── list-bin-paths - Binary paths for asdf +│ ├── help-overview - User help text +│ └── latest-stable - Latest stable version +├── lib/ (2 libraries) +│ ├── utils.sh - Core utilities (~800 LOC) +│ └── cache.sh - API caching (~150 LOC) +├── test/ (5 test files) +│ ├── utils.bats - Unit tests +│ ├── list-all.bats - Version listing tests +│ ├── download.bats - Download tests +│ ├── install.bats - Installation tests +│ └── test_helpers.bash - Test helpers +├── scripts/ (6 tools) +│ ├── setup-dev.sh - Dev environment setup +│ ├── test.sh - Test runner +│ ├── benchmark.sh - Performance benchmarks +│ ├── doctor.sh - Diagnostics +│ ├── cleanup.sh - Maintenance +│ └── rsr-verify.sh - RSR compliance check +├── docs/ (11 guides) +│ ├── ARCHITECTURE.md +│ ├── API_REFERENCE.md +│ ├── FAQ.md +│ ├── QUICKSTART.md +│ ├── TROUBLESHOOTING.md +│ ├── EXAMPLES.md +│ ├── MIGRATION.md +│ └── COMPATIBILITY.md +├── examples/ (3 files) +│ ├── Dockerfile +│ ├── Dockerfile.multi-stage +│ └── docker-compose.yml +├── completions/ (2 files) +│ ├── ghjk.bash +│ └── ghjk.zsh +├── .well-known/ (3 files) +│ ├── security.txt +│ ├── ai.txt +│ └── humans.txt +├── .github/ (9 files) +│ ├── workflows/ +│ │ ├── ci.yml +│ │ └── release.yml +│ ├── ISSUE_TEMPLATE/ +│ │ ├── bug_report.md +│ │ └── feature_request.md +│ ├── pull_request_template.md +│ ├── CODEOWNERS +│ └── FUNDING.yml +└── Root files (14 files) + ├── README.md + ├── CONTRIBUTING.md + ├── CODE_OF_CONDUCT.md + ├── MAINTAINERS.md + ├── SECURITY.md + ├── CHANGELOG.md + ├── LICENSE.txt (dual MIT + Palimpsest) + ├── RSR.md + ├── Makefile + ├── Justfile + ├── flake.guix + ├── .editorconfig + ├── .shellcheckrc + ├── .pre-commit-config.yaml + └── .gitignore +.... + +''''' + +=== 🚀 Quick Start (for Users) + +==== Installation + +[source,bash] +---- +# Add the plugin +asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git + +# Install latest version +asdf install ghjk latest + +# Set as default +asdf global ghjk latest + +# Verify +ghjk --version +---- + +==== Development + +[source,bash] +---- +# Clone the repository +git clone https://github.com/Hyperpolymath/asdf-ghjk.git +cd asdf-ghjk + +# Set up development environment +just setup +# or: make dev-setup +# or: ./scripts/setup-dev.sh + +# Run tests +just test +# or: make test +# or: ./scripts/test.sh + +# Run linting +just lint +# or: make lint + +# Verify RSR compliance +just rsr-check +# or: ./scripts/rsr-verify.sh +---- + +''''' + +=== 🔍 Verification Commands + +==== RSR Compliance + +[source,bash] +---- +./scripts/rsr-verify.sh +# Expected: Platinum level, 100% score +---- + +==== Tests + +[source,bash] +---- +just test +# Expected: All tests pass +---- + +==== Linting + +[source,bash] +---- +just lint +# Expected: No ShellCheck warnings +---- + +==== Diagnostics + +[source,bash] +---- +./scripts/doctor.sh +# Expected: All checks pass +---- + +''''' + +=== 📚 Key Documentation Links + +* *User Guide*: README.md +* *Quick Start*: docs/QUICKSTART.md (5 minutes) +* *Troubleshooting*: docs/TROUBLESHOOTING.md +* *Examples*: docs/EXAMPLES.md +* *API Reference*: docs/API_REFERENCE.md +* *Contributing*: CONTRIBUTING.md +* *Security*: SECURITY.md +* *RSR Compliance*: RSR.md + +''''' + +=== 🎯 Comparison to RSR rhodium-minimal Example + +[width="100%",cols="22%,37%,25%,16%",options="header",] +|=== +|Feature |rhodium-minimal |asdf-ghjk |Notes +|RSR Level |Bronze |*Platinum* |Exceeds reference +|Documentation |Basic |Comprehensive |14 vs 7 docs +|Testing |Unit only |Unit + Integration |BATS suite +|Build Systems |2 (just, Guix) |*3* (Make, just, Guix) |Triple support +|.well-known |3 files |*3 files* |RFC compliant +|TPCF |Perimeter 3 |*Perimeter 3* |Community Sandbox +|Language |Rust (100 LOC) |Bash (~7,200 LOC) |Production-scale +|Lines of Code |100 |*7,200* |72x larger +|Files |~20 |*60* |3x more +|CI/CD |GitLab |*GitHub Actions* |Multi-platform +|=== + +''''' + +=== 💡 Innovation Highlights + +==== Beyond RSR Requirements + +[arabic] +. *Triple Build System Support* +* Traditional Make for compatibility +* Modern just for developer experience +* Guix for reproducibility +. *Comprehensive Tooling* +* Performance benchmarking +* System diagnostics (doctor.sh) +* Automated cleanup +* Cache management +. *Multi-Platform CI/CD* +* Ubuntu 20.04, 22.04 +* macOS Intel and Apple Silicon +* Automated compatibility testing +. *Developer Experience* +* Shell completions (Bash, Zsh) +* Pre-commit hooks +* EditorConfig support +* 50+ just recipes +. *Security-First* +* SHA256 checksum verification +* HTTPS-only downloads +* RFC 9116 security.txt +* Input validation throughout + +''''' + +=== 🏆 Achievement Metrics + +==== Code Quality + +* *ShellCheck*: 100% compliant (no warnings) +* *Test Coverage*: 100% of core functions +* *CI/CD*: Multi-platform automated testing +* *Documentation*: 10,000+ words + +==== Project Management + +* *RSR Level*: Platinum (100%) +* *TPCF*: Perimeter 3 declared +* *Licensing*: Dual permissive (MIT + Palimpsest) +* *Governance*: Documented and transparent + +==== Developer Experience + +* *Setup Time*: < 5 minutes +* *Build Systems*: 3 (Make, just, Guix) +* *Automation*: 50+ recipes +* *Diagnostics*: Automated troubleshooting + +''''' + +=== 🎓 Suitable For + +This project is suitable as: + +==== Reference Implementation + +* ✅ RSR Framework Platinum example +* ✅ asdf plugin best practices +* ✅ Shell scripting standards +* ✅ Open source project template + +==== Production Use + +* ✅ Enterprise-grade quality +* ✅ Comprehensive security +* ✅ Multi-platform support +* ✅ Well-documented and maintained + +==== Educational Purpose + +* ✅ Shell scripting examples +* ✅ Testing with BATS +* ✅ CI/CD patterns +* ✅ Documentation standards + +==== Portfolio/Resume + +* ✅ Platinum-level RSR compliance +* ✅ Professional quality +* ✅ Comprehensive documentation +* ✅ Production-ready code + +''''' + +=== 🔮 Future Enhancements + +While the project is feature-complete, potential additions: + +[arabic] +. *Community Growth* +* Submission to asdf plugin registry +* Community contributions +* User adoption metrics +. *Advanced Features* +* Parallel version installations +* Plugin marketplace integration +* Advanced caching strategies +. *Ecosystem Integration* +* Homebrew formula +* Package repository submissions +* Integration with other tools + +''''' + +=== 📞 Getting Help + +* *Issues*: https://github.com/Hyperpolymath/asdf-ghjk/issues +* *Discussions*: https://github.com/Hyperpolymath/asdf-ghjk/discussions +* *Security*: See SECURITY.md +* *Contributing*: See CONTRIBUTING.md + +''''' + +=== ✅ Verification Checklist + +Use this to verify the project state: + +* [ ] Clone repository +* [ ] Run `+./scripts/rsr-verify.sh+` → Should show Platinum +* [ ] Run `+just test+` or `+make test+` → All tests pass +* [ ] Run `+just lint+` → No warnings +* [ ] Run `+./scripts/doctor.sh+` → All checks pass +* [ ] Review RSR.md → All categories 100% +* [ ] Check `+.well-known/+` files → All present +* [ ] Verify dual licensing → LICENSE.txt has both +* [ ] Count files → Should be 60+ +* [ ] Count lines → Should be 7,200+ + +''''' + +=== 🙏 Credits + +* *asdf-vm Team*: For creating asdf framework +* *ghjk Team (Metatype)*: For ghjk tool +* *Claude (Anthropic)*: AI development assistance +* *Open Source Community*: For tools and inspiration +* *RSR Framework*: For comprehensive standards + +''''' + +=== 📜 License + +Dual licensed under: - MIT License (OSI-approved, permissive) - +Palimpsest License v0.8 (philosophical, permissive) + +Users may choose either license. + +SPDX-License-Identifier: CC-BY-SA-4.0 + +''''' + +*Status*: ✅ Complete and Ready *Quality*: 🏆 Platinum Level RSR +Compliance *Next Steps*: Review, test, and deploy + +''''' + +_This project represents the maximum utilization of development credits +with comprehensive, production-ready code and documentation._ diff --git a/asdf-ghjk/PROJECT_SUMMARY.md b/asdf-ghjk/PROJECT_SUMMARY.md deleted file mode 100644 index 08548b21..00000000 --- a/asdf-ghjk/PROJECT_SUMMARY.md +++ /dev/null @@ -1,478 +0,0 @@ -# asdf-ghjk: Complete Project Summary - -**Branch**: `claude/create-claude-md-0185REoNFa5vvHxsmFjiaNKc` -**Completion Date**: 2024-11-22 -**Total Files**: 60+ -**Total Lines**: 7,200+ -**RSR Level**: **Platinum** (100% compliance) -**Development Time**: ~1 session with maximum credit utilization - ---- - -## 🎉 Achievement: RSR Platinum Level - -**RSR Score: 100% (73/73 checks passed)** - -This project has achieved the highest possible RSR (Rhodium Standard Repository) Framework compliance level, making it suitable for: -- Enterprise production use -- Open source community collaboration -- Academic research reference -- Professional portfolio showcase - ---- - -## 📊 What Was Built - -### Core Functionality (Production-Ready) -- ✅ Full asdf plugin implementation (list-all, download, install) -- ✅ Multi-platform support (Linux x86_64/ARM64, macOS Intel/Apple Silicon) -- ✅ SHA256 checksum verification for security -- ✅ GitHub API caching with configurable TTL -- ✅ Retry logic with exponential backoff -- ✅ Comprehensive error handling and logging - -### Documentation (14 Comprehensive Guides) -1. **README.md** - Complete user guide with examples -2. **CONTRIBUTING.md** - Developer contribution guide -3. **CODE_OF_CONDUCT.md** - Contributor Covenant 2.1 -4. **MAINTAINERS.md** - Governance and maintainer info -5. **SECURITY.md** - Security policy and vulnerability disclosure -6. **CHANGELOG.md** - Version history (Keep a Changelog format) -7. **ARCHITECTURE.md** - Internal architecture and design -8. **API_REFERENCE.md** - Complete function/script reference -9. **FAQ.md** - 30+ frequently asked questions -10. **QUICKSTART.md** - 5-minute setup guide -11. **TROUBLESHOOTING.md** - Solutions to common issues -12. **EXAMPLES.md** - Real-world usage scenarios -13. **MIGRATION.md** - Migration from standalone ghjk -14. **COMPATIBILITY.md** - Platform/version compatibility matrix -15. **RSR.md** - RSR Framework compliance documentation - -**Total Documentation**: 10,000+ words - -### Testing (Comprehensive Coverage) -- ✅ BATS test suite (unit + integration) -- ✅ 5 test files covering all core functionality -- ✅ Test helpers and fixtures -- ✅ GitHub Actions CI/CD -- ✅ Multi-platform testing (Ubuntu, macOS) -- ✅ ShellCheck linting for all scripts -- ✅ 100% test pass rate - -### Build Systems (Triple Support) -1. **Makefile** - Traditional GNU Make automation -2. **justfile** - Modern task runner with 50+ recipes -3. **flake.guix** - Guix reproducible builds - -### Developer Tools -- ✅ `scripts/setup-dev.sh` - Development environment setup -- ✅ `scripts/test.sh` - Test runner -- ✅ `scripts/benchmark.sh` - Performance benchmarking -- ✅ `scripts/doctor.sh` - Diagnostic troubleshooting -- ✅ `scripts/cleanup.sh` - Disk usage management -- ✅ `scripts/rsr-verify.sh` - RSR compliance verification - -### Advanced Features -- ✅ Shell completions (Bash & Zsh) -- ✅ Docker integration (3 examples) -- ✅ Latest-stable version detection -- ✅ API response caching (configurable TTL) -- ✅ Pre-commit hooks configuration - -### .well-known Directory (RFC Standards) -- ✅ `security.txt` - RFC 9116 compliant security contact -- ✅ `ai.txt` - AI training and usage policy -- ✅ `humans.txt` - Human-readable attribution - -### Licensing -- ✅ Dual licensing: MIT + Palimpsest v0.8 -- ✅ User choice of license -- ✅ SPDX identifiers -- ✅ OSI-approved permissive terms - -### Quality Assurance -- ✅ GitHub issue templates (bug, feature request) -- ✅ Pull request template -- ✅ CODEOWNERS for automated reviews -- ✅ EditorConfig for consistency -- ✅ Comprehensive .gitignore - ---- - -## 📈 RSR Compliance Breakdown - -### Category Scores (All 100%) - -| Category | Checks | Passed | Score | -|----------|--------|--------|-------| -| 1. Documentation | 14 | 14 | ✅ 100% | -| 2. Licensing | 5 | 5 | ✅ 100% | -| 3. Security | 6 | 6 | ✅ 100% | -| 4. Contributing | 6 | 6 | ✅ 100% | -| 5. Governance | 6 | 6 | ✅ 100% | -| 6. Testing | 6 | 6 | ✅ 100% | -| 7. Build System | 7 | 7 | ✅ 100% | -| 8. Versioning | 3 | 3 | ✅ 100% | -| 9. .well-known | 6 | 6 | ✅ 100% | -| 10. Community | 4 | 4 | ✅ 100% | -| 11. Automation | 5 | 5 | ✅ 100% | -| **Bonus Markers** | 5 | 5 | ✅ 100% | -| **TOTAL** | **73** | **73** | **✅ 100%** | - -### TPCF Declaration - -**Perimeter**: **3 - Community Sandbox** - -**Characteristics**: -- Open to all contributors -- Maintainer review required -- Community-driven governance -- Consensus-based decision making -- Pull request workflow -- Public trust model - ---- - -## 🗂️ File Structure - -``` -asdf-ghjk/ (60 files) -├── bin/ (6 scripts) -│ ├── download - Download ghjk releases -│ ├── install - Install downloaded releases -│ ├── list-all - List available versions -│ ├── list-bin-paths - Binary paths for asdf -│ ├── help-overview - User help text -│ └── latest-stable - Latest stable version -├── lib/ (2 libraries) -│ ├── utils.sh - Core utilities (~800 LOC) -│ └── cache.sh - API caching (~150 LOC) -├── test/ (5 test files) -│ ├── utils.bats - Unit tests -│ ├── list-all.bats - Version listing tests -│ ├── download.bats - Download tests -│ ├── install.bats - Installation tests -│ └── test_helpers.bash - Test helpers -├── scripts/ (6 tools) -│ ├── setup-dev.sh - Dev environment setup -│ ├── test.sh - Test runner -│ ├── benchmark.sh - Performance benchmarks -│ ├── doctor.sh - Diagnostics -│ ├── cleanup.sh - Maintenance -│ └── rsr-verify.sh - RSR compliance check -├── docs/ (11 guides) -│ ├── ARCHITECTURE.md -│ ├── API_REFERENCE.md -│ ├── FAQ.md -│ ├── QUICKSTART.md -│ ├── TROUBLESHOOTING.md -│ ├── EXAMPLES.md -│ ├── MIGRATION.md -│ └── COMPATIBILITY.md -├── examples/ (3 files) -│ ├── Dockerfile -│ ├── Dockerfile.multi-stage -│ └── docker-compose.yml -├── completions/ (2 files) -│ ├── ghjk.bash -│ └── ghjk.zsh -├── .well-known/ (3 files) -│ ├── security.txt -│ ├── ai.txt -│ └── humans.txt -├── .github/ (9 files) -│ ├── workflows/ -│ │ ├── ci.yml -│ │ └── release.yml -│ ├── ISSUE_TEMPLATE/ -│ │ ├── bug_report.md -│ │ └── feature_request.md -│ ├── pull_request_template.md -│ ├── CODEOWNERS -│ └── FUNDING.yml -└── Root files (14 files) - ├── README.md - ├── CONTRIBUTING.md - ├── CODE_OF_CONDUCT.md - ├── MAINTAINERS.md - ├── SECURITY.md - ├── CHANGELOG.md - ├── LICENSE.txt (dual MIT + Palimpsest) - ├── RSR.md - ├── Makefile - ├── Justfile - ├── flake.guix - ├── .editorconfig - ├── .shellcheckrc - ├── .pre-commit-config.yaml - └── .gitignore -``` - ---- - -## 🚀 Quick Start (for Users) - -### Installation - -```bash -# Add the plugin -asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git - -# Install latest version -asdf install ghjk latest - -# Set as default -asdf global ghjk latest - -# Verify -ghjk --version -``` - -### Development - -```bash -# Clone the repository -git clone https://github.com/Hyperpolymath/asdf-ghjk.git -cd asdf-ghjk - -# Set up development environment -just setup -# or: make dev-setup -# or: ./scripts/setup-dev.sh - -# Run tests -just test -# or: make test -# or: ./scripts/test.sh - -# Run linting -just lint -# or: make lint - -# Verify RSR compliance -just rsr-check -# or: ./scripts/rsr-verify.sh -``` - ---- - -## 🔍 Verification Commands - -### RSR Compliance -```bash -./scripts/rsr-verify.sh -# Expected: Platinum level, 100% score -``` - -### Tests -```bash -just test -# Expected: All tests pass -``` - -### Linting -```bash -just lint -# Expected: No ShellCheck warnings -``` - -### Diagnostics -```bash -./scripts/doctor.sh -# Expected: All checks pass -``` - ---- - -## 📚 Key Documentation Links - -- **User Guide**: README.md -- **Quick Start**: docs/QUICKSTART.md (5 minutes) -- **Troubleshooting**: docs/TROUBLESHOOTING.md -- **Examples**: docs/EXAMPLES.md -- **API Reference**: docs/API_REFERENCE.md -- **Contributing**: CONTRIBUTING.md -- **Security**: SECURITY.md -- **RSR Compliance**: RSR.md - ---- - -## 🎯 Comparison to RSR rhodium-minimal Example - -| Feature | rhodium-minimal | asdf-ghjk | Notes | -|---------|----------------|-----------|-------| -| RSR Level | Bronze | **Platinum** | Exceeds reference | -| Documentation | Basic | Comprehensive | 14 vs 7 docs | -| Testing | Unit only | Unit + Integration | BATS suite | -| Build Systems | 2 (just, Guix) | **3** (Make, just, Guix) | Triple support | -| .well-known | 3 files | **3 files** | RFC compliant | -| TPCF | Perimeter 3 | **Perimeter 3** | Community Sandbox | -| Language | Rust (100 LOC) | Bash (~7,200 LOC) | Production-scale | -| Lines of Code | 100 | **7,200** | 72x larger | -| Files | ~20 | **60** | 3x more | -| CI/CD | GitLab | **GitHub Actions** | Multi-platform | - ---- - -## 💡 Innovation Highlights - -### Beyond RSR Requirements - -1. **Triple Build System Support** - - Traditional Make for compatibility - - Modern just for developer experience - - Guix for reproducibility - -2. **Comprehensive Tooling** - - Performance benchmarking - - System diagnostics (doctor.sh) - - Automated cleanup - - Cache management - -3. **Multi-Platform CI/CD** - - Ubuntu 20.04, 22.04 - - macOS Intel and Apple Silicon - - Automated compatibility testing - -4. **Developer Experience** - - Shell completions (Bash, Zsh) - - Pre-commit hooks - - EditorConfig support - - 50+ just recipes - -5. **Security-First** - - SHA256 checksum verification - - HTTPS-only downloads - - RFC 9116 security.txt - - Input validation throughout - ---- - -## 🏆 Achievement Metrics - -### Code Quality -- **ShellCheck**: 100% compliant (no warnings) -- **Test Coverage**: 100% of core functions -- **CI/CD**: Multi-platform automated testing -- **Documentation**: 10,000+ words - -### Project Management -- **RSR Level**: Platinum (100%) -- **TPCF**: Perimeter 3 declared -- **Licensing**: Dual permissive (MIT + Palimpsest) -- **Governance**: Documented and transparent - -### Developer Experience -- **Setup Time**: < 5 minutes -- **Build Systems**: 3 (Make, just, Guix) -- **Automation**: 50+ recipes -- **Diagnostics**: Automated troubleshooting - ---- - -## 🎓 Suitable For - -This project is suitable as: - -### Reference Implementation -- ✅ RSR Framework Platinum example -- ✅ asdf plugin best practices -- ✅ Shell scripting standards -- ✅ Open source project template - -### Production Use -- ✅ Enterprise-grade quality -- ✅ Comprehensive security -- ✅ Multi-platform support -- ✅ Well-documented and maintained - -### Educational Purpose -- ✅ Shell scripting examples -- ✅ Testing with BATS -- ✅ CI/CD patterns -- ✅ Documentation standards - -### Portfolio/Resume -- ✅ Platinum-level RSR compliance -- ✅ Professional quality -- ✅ Comprehensive documentation -- ✅ Production-ready code - ---- - -## 🔮 Future Enhancements - -While the project is feature-complete, potential additions: - -1. **Community Growth** - - Submission to asdf plugin registry - - Community contributions - - User adoption metrics - -2. **Advanced Features** - - Parallel version installations - - Plugin marketplace integration - - Advanced caching strategies - -3. **Ecosystem Integration** - - Homebrew formula - - Package repository submissions - - Integration with other tools - ---- - -## 📞 Getting Help - -- **Issues**: https://github.com/Hyperpolymath/asdf-ghjk/issues -- **Discussions**: https://github.com/Hyperpolymath/asdf-ghjk/discussions -- **Security**: See SECURITY.md -- **Contributing**: See CONTRIBUTING.md - ---- - -## ✅ Verification Checklist - -Use this to verify the project state: - -- [ ] Clone repository -- [ ] Run `./scripts/rsr-verify.sh` → Should show Platinum -- [ ] Run `just test` or `make test` → All tests pass -- [ ] Run `just lint` → No warnings -- [ ] Run `./scripts/doctor.sh` → All checks pass -- [ ] Review RSR.md → All categories 100% -- [ ] Check `.well-known/` files → All present -- [ ] Verify dual licensing → LICENSE.txt has both -- [ ] Count files → Should be 60+ -- [ ] Count lines → Should be 7,200+ - ---- - -## 🙏 Credits - -- **asdf-vm Team**: For creating asdf framework -- **ghjk Team (Metatype)**: For ghjk tool -- **Claude (Anthropic)**: AI development assistance -- **Open Source Community**: For tools and inspiration -- **RSR Framework**: For comprehensive standards - ---- - -## 📜 License - -Dual licensed under: -- MIT License (OSI-approved, permissive) -- Palimpsest License v0.8 (philosophical, permissive) - -Users may choose either license. - -SPDX-License-Identifier: CC-BY-SA-4.0 - ---- - -**Status**: ✅ Complete and Ready -**Quality**: 🏆 Platinum Level RSR Compliance -**Next Steps**: Review, test, and deploy - ---- - -*This project represents the maximum utilization of development credits with comprehensive, production-ready code and documentation.* diff --git a/asdf-ghjk/RSR.adoc b/asdf-ghjk/RSR.adoc new file mode 100644 index 00000000..13161825 --- /dev/null +++ b/asdf-ghjk/RSR.adoc @@ -0,0 +1,273 @@ +== RSR Framework Compliance + +*Repository*: asdf-ghjk *RSR Level*: Bronze+ (targeting Silver) *TPCF +Perimeter*: 3 - Community Sandbox *Verification Date*: 2024-11-22 + +=== Rhodium Standard Repository (RSR) Framework + +This document declares and verifies compliance with the RSR Framework, a +comprehensive standard for repository quality, security, and governance. + +=== TPCF Declaration + +==== Tri-Perimeter Contribution Framework (TPCF) + +*Active Perimeter*: *Perimeter 3 - Community Sandbox* + +===== Perimeter Characteristics + +* *Access*: Open to all contributors +* *Review*: Maintainer review required for merging +* *Trust Level*: Public, community-driven +* *Commit Rights*: Pull request workflow +* *Governance*: Consensus-based decision making + +===== Why Perimeter 3? + +This project is a community open-source project welcoming contributions +from anyone. We maintain quality through: - Code review by maintainers - +Automated CI/CD checks - Comprehensive testing - Clear contribution +guidelines + +===== Future Perimeter Evolution + +Projects may evolve through perimeters: - *P3 → P2*: Regular +contributors may be invited to Perimeter 2 (Trusted Contributors) - *P2 +→ P1*: Trusted contributors may become core maintainers in Perimeter 1 + +See CONTRIBUTING.md and MAINTAINERS.md for details. + +=== RSR Compliance Checklist + +==== Category 1: Documentation (✅ Complete) + +* [x] README.md - Comprehensive with installation, usage, examples +* [x] ARCHITECTURE.md - Internal architecture and design decisions +* [x] API_REFERENCE.md - Complete function and script reference +* [x] CONTRIBUTING.md - Contribution guidelines +* [x] CODE_OF_CONDUCT.md - Contributor Covenant 2.1 +* [x] MAINTAINERS.md - Maintainer information and governance +* [x] SECURITY.md - Security policy and vulnerability disclosure +* [x] CHANGELOG.md - Version history +* [x] FAQ.md - Frequently asked questions +* [x] QUICKSTART.md - 5-minute quick start guide +* [x] TROUBLESHOOTING.md - Common issues and solutions +* [x] EXAMPLES.md - Real-world usage examples +* [x] MIGRATION.md - Migration guide from standalone installation +* [x] COMPATIBILITY.md - Platform and version compatibility matrix + +*Score*: 14/14 documents ✅ + +==== Category 2: Licensing (✅ Complete) + +* [x] LICENSE.txt - Dual MIT + Palimpsest v0.8 +* [x] SPDX identifier in all source files (via header comments) +* [x] Clear license choice for users (dual licensing explained) +* [x] OSI-approved license (MIT) +* [x] Politically neutral licensing (Palimpsest principle) + +*Score*: 5/5 requirements ✅ + +==== Category 3: Security (✅ Complete) + +* [x] SECURITY.md - Comprehensive security policy +* [x] .well-known/security.txt - RFC 9116 compliant +* [x] Vulnerability disclosure process documented +* [x] Security contact information +* [x] Checksum verification (SHA256) +* [x] HTTPS-only downloads +* [x] No hardcoded secrets +* [x] Input validation +* [x] Dependency minimization + +*Score*: 9/9 requirements ✅ + +==== Category 4: Contributing (✅ Complete) + +* [x] CONTRIBUTING.md - Comprehensive guide +* [x] CODE_OF_CONDUCT.md - Contributor Covenant 2.1 +* [x] Issue templates (bug report, feature request) +* [x] Pull request template +* [x] Development setup instructions +* [x] Testing guidelines +* [x] Coding standards documented + +*Score*: 7/7 requirements ✅ + +==== Category 5: Governance (✅ Complete) + +* [x] MAINTAINERS.md - Maintainer list and responsibilities +* [x] CODEOWNERS - Automated review assignments +* [x] Decision-making process documented +* [x] Maintainer onboarding process +* [x] Consensus-based governance +* [x] TPCF perimeter declaration + +*Score*: 6/6 requirements ✅ + +==== Category 6: Testing (✅ Complete) + +* [x] Test suite (BATS) +* [x] Unit tests (lib/utils.sh functions) +* [x] Integration tests (bin/ scripts) +* [x] CI/CD pipeline (GitHub Actions) +* [x] Multi-platform testing (Linux, macOS) +* [x] Test documentation (test/test_helpers.bash) +* [x] 100% pass rate + +*Score*: 7/7 requirements ✅ + +==== Category 7: Build System (✅ Complete) + +* [x] Makefile - GNU Make automation +* [x] Justfile - Modern task runner +* [x] flake.guix - Guix reproducible builds +* [x] Build documentation +* [x] Development setup script +* [x] Dependency checks +* [x] Clean targets + +*Score*: 7/7 requirements ✅ + +==== Category 8: Versioning (✅ Complete) + +* [x] CHANGELOG.md - Keep a Changelog format +* [x] Semantic versioning principles +* [x] Git tags for releases +* [x] Version documentation in code +* [x] Compatibility tracking + +*Score*: 5/5 requirements ✅ + +==== Category 9: .well-known (✅ Complete) + +* [x] .well-known/security.txt - RFC 9116 compliant +* [x] .well-known/ai.txt - AI training and usage policy +* [x] .well-known/humans.txt - Human-readable attribution +* [x] Proper formatting and current information + +*Score*: 4/4 requirements ✅ + +==== Category 10: Community (✅ Complete) + +* [x] Issue templates +* [x] Pull request template +* [x] Discussion guidelines +* [x] Response time expectations +* [x] Community health files +* [x] Welcoming environment + +*Score*: 6/6 requirements ✅ + +==== Category 11: Automation (✅ Complete) + +* [x] CI/CD workflows (GitHub Actions) +* [x] Automated testing +* [x] Automated linting (ShellCheck) +* [x] Pre-commit hooks configuration +* [x] Release automation (GitHub Actions) +* [x] Dependency updates (Dependabot potential) + +*Score*: 6/6 requirements ✅ + +=== Overall RSR Score + +*Total*: 76/76 requirements met (100%) + +*Level Achieved*: *Gold* ✨ + +==== RSR Level Breakdown + +* *Bronze* (50-69%): Basic documentation, licensing, security +* *Silver* (70-89%): + Testing, CI/CD, governance +* *Gold* (90-99%): + Comprehensive docs, automation, .well-known +* *Platinum* (100%): All requirements + excellence markers + +=== Offline-First Compliance + +*Status*: Partial ⚠️ + +*Capabilities*: - ✅ Local script execution - ✅ Cache for API responses +(offline after first fetch) - ✅ No telemetry or tracking - ❌ Requires +GitHub API for initial version listing + +*Justification*: As a version manager plugin, some network access is +inherent to the functionality (fetching available versions and +downloading binaries). However: - Caching minimizes network calls - +Works offline after initial setup - No user data collection - +Privacy-respecting + +*Offline Score*: 3/5 ✅ + +=== Type Safety & Memory Safety + +*Language*: Bash (Shell Script) + +*Safety Measures*: - ✅ `+set -euo pipefail+` in all scripts (fail-fast) +- ✅ ShellCheck compliance (static analysis) - ✅ Input validation - ✅ +Proper quoting and escaping - ✅ No `+eval+` or dangerous constructs - +⚠️ Bash is not memory-safe by nature + +*Type Safety Score*: 4/5 (Shell limitations) *Memory Safety Score*: 4/5 +(Shell limitations) + +*Note*: For a shell script project, this represents maximum achievable +safety. + +=== Excellence Markers + +Beyond basic RSR compliance, this project demonstrates: + +[arabic] +. *Comprehensive Documentation*: 14 guides covering every aspect +. *Multiple Build Systems*: Make, just, and Guix for maximum flexibility +. *Developer Experience*: Setup scripts, doctor tool, cleanup utilities +. *Performance Optimization*: Caching, benchmarking, profiling +. *Shell Completions*: Bash and Zsh for better UX +. *Docker Integration*: Multiple Dockerfile examples +. *Educational Value*: Extensive examples and explanations +. *Accessibility*: Clear writing, good structure, inclusive language + +=== Continuous Improvement + +We track RSR compliance over time: + +[cols=",,,",options="header",] +|=== +|Date |Level |Score |Notes +|2024-11-22 |Gold |100% |Initial RSR compliance implementation +|=== + +=== Verification + +To verify RSR compliance: + +[source,bash] +---- +# Run verification script +./scripts/rsr-verify.sh + +# Check specific category +./scripts/rsr-verify.sh --category documentation + +# Generate compliance report +./scripts/rsr-verify.sh --report +---- + +=== Contact + +* *Compliance Questions*: Open an issue +* *Governance Questions*: See MAINTAINERS.md +* *Security Concerns*: See SECURITY.md + +=== References + +* https://github.com/Hyperpolymath/rhodium-minimal[RSR Framework] +* https://github.com/Hyperpolymath/rhodium-minimal[TPCF Documentation] +* https://github.com/Hyperpolymath/palimpsest-license[Palimpsest +License] + +''''' + +*Last Verified*: 2024-11-22 *Next Verification*: Continuous (on each +commit) *Verified By*: Automated RSR verification script diff --git a/asdf-ghjk/RSR.md b/asdf-ghjk/RSR.md deleted file mode 100644 index 708759ea..00000000 --- a/asdf-ghjk/RSR.md +++ /dev/null @@ -1,275 +0,0 @@ -# RSR Framework Compliance - -**Repository**: asdf-ghjk -**RSR Level**: Bronze+ (targeting Silver) -**TPCF Perimeter**: 3 - Community Sandbox -**Verification Date**: 2024-11-22 - -## Rhodium Standard Repository (RSR) Framework - -This document declares and verifies compliance with the RSR Framework, a comprehensive standard for repository quality, security, and governance. - -## TPCF Declaration - -### Tri-Perimeter Contribution Framework (TPCF) - -**Active Perimeter**: **Perimeter 3 - Community Sandbox** - -#### Perimeter Characteristics - -- **Access**: Open to all contributors -- **Review**: Maintainer review required for merging -- **Trust Level**: Public, community-driven -- **Commit Rights**: Pull request workflow -- **Governance**: Consensus-based decision making - -#### Why Perimeter 3? - -This project is a community open-source project welcoming contributions from anyone. We maintain quality through: -- Code review by maintainers -- Automated CI/CD checks -- Comprehensive testing -- Clear contribution guidelines - -#### Future Perimeter Evolution - -Projects may evolve through perimeters: -- **P3 → P2**: Regular contributors may be invited to Perimeter 2 (Trusted Contributors) -- **P2 → P1**: Trusted contributors may become core maintainers in Perimeter 1 - -See CONTRIBUTING.md and MAINTAINERS.md for details. - -## RSR Compliance Checklist - -### Category 1: Documentation (✅ Complete) - -- [x] README.md - Comprehensive with installation, usage, examples -- [x] ARCHITECTURE.md - Internal architecture and design decisions -- [x] API_REFERENCE.md - Complete function and script reference -- [x] CONTRIBUTING.md - Contribution guidelines -- [x] CODE_OF_CONDUCT.md - Contributor Covenant 2.1 -- [x] MAINTAINERS.md - Maintainer information and governance -- [x] SECURITY.md - Security policy and vulnerability disclosure -- [x] CHANGELOG.md - Version history -- [x] FAQ.md - Frequently asked questions -- [x] QUICKSTART.md - 5-minute quick start guide -- [x] TROUBLESHOOTING.md - Common issues and solutions -- [x] EXAMPLES.md - Real-world usage examples -- [x] MIGRATION.md - Migration guide from standalone installation -- [x] COMPATIBILITY.md - Platform and version compatibility matrix - -**Score**: 14/14 documents ✅ - -### Category 2: Licensing (✅ Complete) - -- [x] LICENSE.txt - Dual MIT + Palimpsest v0.8 -- [x] SPDX identifier in all source files (via header comments) -- [x] Clear license choice for users (dual licensing explained) -- [x] OSI-approved license (MIT) -- [x] Politically neutral licensing (Palimpsest principle) - -**Score**: 5/5 requirements ✅ - -### Category 3: Security (✅ Complete) - -- [x] SECURITY.md - Comprehensive security policy -- [x] .well-known/security.txt - RFC 9116 compliant -- [x] Vulnerability disclosure process documented -- [x] Security contact information -- [x] Checksum verification (SHA256) -- [x] HTTPS-only downloads -- [x] No hardcoded secrets -- [x] Input validation -- [x] Dependency minimization - -**Score**: 9/9 requirements ✅ - -### Category 4: Contributing (✅ Complete) - -- [x] CONTRIBUTING.md - Comprehensive guide -- [x] CODE_OF_CONDUCT.md - Contributor Covenant 2.1 -- [x] Issue templates (bug report, feature request) -- [x] Pull request template -- [x] Development setup instructions -- [x] Testing guidelines -- [x] Coding standards documented - -**Score**: 7/7 requirements ✅ - -### Category 5: Governance (✅ Complete) - -- [x] MAINTAINERS.md - Maintainer list and responsibilities -- [x] CODEOWNERS - Automated review assignments -- [x] Decision-making process documented -- [x] Maintainer onboarding process -- [x] Consensus-based governance -- [x] TPCF perimeter declaration - -**Score**: 6/6 requirements ✅ - -### Category 6: Testing (✅ Complete) - -- [x] Test suite (BATS) -- [x] Unit tests (lib/utils.sh functions) -- [x] Integration tests (bin/ scripts) -- [x] CI/CD pipeline (GitHub Actions) -- [x] Multi-platform testing (Linux, macOS) -- [x] Test documentation (test/test_helpers.bash) -- [x] 100% pass rate - -**Score**: 7/7 requirements ✅ - -### Category 7: Build System (✅ Complete) - -- [x] Makefile - GNU Make automation -- [x] Justfile - Modern task runner -- [x] flake.guix - Guix reproducible builds -- [x] Build documentation -- [x] Development setup script -- [x] Dependency checks -- [x] Clean targets - -**Score**: 7/7 requirements ✅ - -### Category 8: Versioning (✅ Complete) - -- [x] CHANGELOG.md - Keep a Changelog format -- [x] Semantic versioning principles -- [x] Git tags for releases -- [x] Version documentation in code -- [x] Compatibility tracking - -**Score**: 5/5 requirements ✅ - -### Category 9: .well-known (✅ Complete) - -- [x] .well-known/security.txt - RFC 9116 compliant -- [x] .well-known/ai.txt - AI training and usage policy -- [x] .well-known/humans.txt - Human-readable attribution -- [x] Proper formatting and current information - -**Score**: 4/4 requirements ✅ - -### Category 10: Community (✅ Complete) - -- [x] Issue templates -- [x] Pull request template -- [x] Discussion guidelines -- [x] Response time expectations -- [x] Community health files -- [x] Welcoming environment - -**Score**: 6/6 requirements ✅ - -### Category 11: Automation (✅ Complete) - -- [x] CI/CD workflows (GitHub Actions) -- [x] Automated testing -- [x] Automated linting (ShellCheck) -- [x] Pre-commit hooks configuration -- [x] Release automation (GitHub Actions) -- [x] Dependency updates (Dependabot potential) - -**Score**: 6/6 requirements ✅ - -## Overall RSR Score - -**Total**: 76/76 requirements met (100%) - -**Level Achieved**: **Gold** ✨ - -### RSR Level Breakdown - -- **Bronze** (50-69%): Basic documentation, licensing, security -- **Silver** (70-89%): + Testing, CI/CD, governance -- **Gold** (90-99%): + Comprehensive docs, automation, .well-known -- **Platinum** (100%): All requirements + excellence markers - -## Offline-First Compliance - -**Status**: Partial ⚠️ - -**Capabilities**: -- ✅ Local script execution -- ✅ Cache for API responses (offline after first fetch) -- ✅ No telemetry or tracking -- ❌ Requires GitHub API for initial version listing - -**Justification**: As a version manager plugin, some network access is inherent to the functionality (fetching available versions and downloading binaries). However: -- Caching minimizes network calls -- Works offline after initial setup -- No user data collection -- Privacy-respecting - -**Offline Score**: 3/5 ✅ - -## Type Safety & Memory Safety - -**Language**: Bash (Shell Script) - -**Safety Measures**: -- ✅ `set -euo pipefail` in all scripts (fail-fast) -- ✅ ShellCheck compliance (static analysis) -- ✅ Input validation -- ✅ Proper quoting and escaping -- ✅ No `eval` or dangerous constructs -- ⚠️ Bash is not memory-safe by nature - -**Type Safety Score**: 4/5 (Shell limitations) -**Memory Safety Score**: 4/5 (Shell limitations) - -**Note**: For a shell script project, this represents maximum achievable safety. - -## Excellence Markers - -Beyond basic RSR compliance, this project demonstrates: - -1. **Comprehensive Documentation**: 14 guides covering every aspect -2. **Multiple Build Systems**: Make, just, and Guix for maximum flexibility -3. **Developer Experience**: Setup scripts, doctor tool, cleanup utilities -4. **Performance Optimization**: Caching, benchmarking, profiling -5. **Shell Completions**: Bash and Zsh for better UX -6. **Docker Integration**: Multiple Dockerfile examples -7. **Educational Value**: Extensive examples and explanations -8. **Accessibility**: Clear writing, good structure, inclusive language - -## Continuous Improvement - -We track RSR compliance over time: - -| Date | Level | Score | Notes | -|------|-------|-------|-------| -| 2024-11-22 | Gold | 100% | Initial RSR compliance implementation | - -## Verification - -To verify RSR compliance: - -```bash -# Run verification script -./scripts/rsr-verify.sh - -# Check specific category -./scripts/rsr-verify.sh --category documentation - -# Generate compliance report -./scripts/rsr-verify.sh --report -``` - -## Contact - -- **Compliance Questions**: Open an issue -- **Governance Questions**: See MAINTAINERS.md -- **Security Concerns**: See SECURITY.md - -## References - -- [RSR Framework](https://github.com/Hyperpolymath/rhodium-minimal) -- [TPCF Documentation](https://github.com/Hyperpolymath/rhodium-minimal) -- [Palimpsest License](https://github.com/Hyperpolymath/palimpsest-license) - ---- - -**Last Verified**: 2024-11-22 -**Next Verification**: Continuous (on each commit) -**Verified By**: Automated RSR verification script diff --git a/asdf-ghjk/SECURITY.adoc b/asdf-ghjk/SECURITY.adoc new file mode 100644 index 00000000..815b3de9 --- /dev/null +++ b/asdf-ghjk/SECURITY.adoc @@ -0,0 +1,252 @@ +== Security Policy + +=== Supported Versions + +Currently supported versions of asdf-ghjk: + +[cols=",",options="header",] +|=== +|Version |Supported +|0.1.x |:white_check_mark: +|< 0.1 |:x: +|=== + +=== Security Considerations + +==== Download Security + +This plugin downloads ghjk binaries from GitHub releases. Security +measures: + +[arabic] +. *HTTPS Only*: All downloads use HTTPS +. *Checksum Verification*: SHA256 checksums are verified when available +. *Official Sources*: Only downloads from official `+metatypedev/ghjk+` +repository +. *Retry Logic*: Failed downloads are retried to prevent partial +downloads + +==== GitHub API Token + +If you use `+GITHUB_API_TOKEN+`: + +* *Minimal Permissions*: Token only needs public repository read access +* *Storage*: Store in environment variables, never commit to version +control +* *Rotation*: Rotate tokens regularly +* *Scope*: Create tokens with minimal required scopes + +Creating a secure token: 1. Go to https://github.com/settings/tokens 2. +Click "`Generate new token (classic)`" 3. Set expiration (recommended: +90 days) 4. *Don’t select any scopes* (public repo access is default) 5. +Generate and store securely + +==== Script Security + +All shell scripts follow security best practices: + +* *Strict Mode*: `+set -euo pipefail+` in all scripts +* *Input Validation*: All user inputs are validated +* *Path Safety*: Paths are properly quoted and validated +* *No `+eval+`*: No use of `+eval+` or similar dangerous constructs +* *ShellCheck*: All scripts pass ShellCheck security checks + +==== Dependencies + +This plugin has minimal dependencies: + +*Required (assumed to be system-provided):* - bash - curl - tar - grep - +sort + +*Runtime (for ghjk itself):* - git - curl - tar - unzip - zstd + +All dependencies should be installed from trusted sources (official +package managers). + +=== Reporting a Vulnerability + +==== Where to Report + +*DO NOT* open public issues for security vulnerabilities. + +Instead, please report security issues via one of these methods: + +[arabic] +. *GitHub Security Advisories* (preferred) +* Go to https://github.com/Hyperpolymath/asdf-ghjk/security/advisories +* Click "`Report a vulnerability`" +* Fill out the form with details +. *Private Email* +* Email: [security contact needed] +* Subject: "`[SECURITY] asdf-ghjk vulnerability report`" +* Include: Detailed description, steps to reproduce, impact assessment + +==== What to Include + +Please include as much information as possible: + +* *Description*: Clear description of the vulnerability +* *Impact*: What can an attacker do? What is the risk? +* *Reproduction*: Step-by-step instructions to reproduce +* *Affected Versions*: Which versions are affected? +* *Suggested Fix*: If you have ideas for fixing it +* *Disclosure Timeline*: Your preferred disclosure timeline + +==== Response Timeline + +We will acknowledge your report within *48 hours* and provide: + +[arabic] +. Confirmation of the issue +. Assessment of severity +. Estimated timeline for a fix +. Communication plan for disclosure + +==== Security Update Process + +When a security issue is confirmed: + +[arabic] +. *Fix Development*: Develop and test fix privately +. *CVE Assignment*: Request CVE if applicable +. *Release*: Create security release +. *Disclosure*: Publish security advisory +. *Notification*: Notify users via GitHub and documentation + +==== Disclosure Policy + +We follow *responsible disclosure*: + +* *Coordinated Disclosure*: Work with reporter on timeline +* *Typical Timeline*: 90 days from report to public disclosure +* *Early Disclosure*: If actively exploited or fix is available +* *Credit*: Security researchers are credited (unless they prefer +anonymity) + +=== Security Best Practices for Users + +==== Installation Security + +[source,bash] +---- +# Verify plugin source +asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git + +# Verify it was added correctly +asdf plugin list --urls | grep ghjk +---- + +==== Token Security + +[source,bash] +---- +# Store in shell profile, not in scripts +echo 'export GITHUB_API_TOKEN="ghp_..."' >> ~/.bashrc + +# Never commit tokens +echo 'GITHUB_API_TOKEN' >> .gitignore + +# Use environment-specific tokens in CI +# GitHub Actions: Use secrets +# GitLab CI: Use protected variables +---- + +==== Verification + +[source,bash] +---- +# After installation, verify the binary +ghjk --version + +# Check where it's installed +which ghjk +ls -la ~/.asdf/installs/ghjk/ + +# Verify checksum if you saved it +sha256sum ~/.asdf/installs/ghjk//ghjk +---- + +==== Update Regularly + +[source,bash] +---- +# Update plugin +asdf plugin update ghjk + +# Update ghjk itself +asdf install ghjk latest +asdf global ghjk latest +---- + +=== Known Security Considerations + +==== GitHub API Rate Limiting + +* *Risk*: Unauthenticated requests limited to 60/hour +* *Mitigation*: Use `+GITHUB_API_TOKEN+` for higher limits +* *Impact*: Low (only affects listing/downloading) + +==== Man-in-the-Middle (MITM) + +* *Risk*: Network interception during download +* *Mitigation*: HTTPS only, checksum verification +* *Impact*: Low (checksums detect tampering) + +==== Supply Chain + +* *Risk*: Compromised ghjk releases +* *Mitigation*: Verify checksums, download from official sources +* *Impact*: Medium (depends on ghjk project security) +* *Note*: This plugin does not control ghjk releases, only facilitates +installation + +==== Local File Permissions + +* *Risk*: Installed files readable by all users +* *Mitigation*: Follow asdf default permissions (user-only) +* *Impact*: Low (asdf handles permissions) + +=== Security Checklist for Contributors + +Before submitting code: + +* [ ] All user inputs are validated +* [ ] All file paths are properly quoted +* [ ] No use of `+eval+`, `+source+` on untrusted input, or `+exec+` +with user data +* [ ] ShellCheck passes with no warnings +* [ ] Dependencies are from trusted sources +* [ ] Secrets are not hardcoded +* [ ] Error messages don’t leak sensitive information +* [ ] Tests include security-relevant cases + +=== Third-Party Security + +==== asdf + +This plugin depends on asdf: - *Security*: +https://github.com/asdf-vm/asdf/security - *Updates*: Keep asdf updated + +==== ghjk + +This plugin installs ghjk: - *Security*: +https://github.com/metatypedev/ghjk/security - *Note*: We don’t control +ghjk security, only facilitate installation + +=== Compliance + +This plugin: - ✅ Follows OWASP secure coding practices - ✅ Uses HTTPS +for all downloads - ✅ Validates all inputs - ✅ Follows principle of +least privilege - ✅ Provides clear error messages without leaking +sensitive data - ✅ Uses secure random generation (when applicable) - ✅ +Properly handles file permissions + +=== Contact + +For security concerns: - Security Issues: Use GitHub Security Advisories +- General Security Questions: Open a discussion - Urgent Issues: +[Contact method needed] + +''''' + +*Last Updated*: 2025-12-18 *Next Review*: Before v0.2.0 release diff --git a/asdf-ghjk/SECURITY.md b/asdf-ghjk/SECURITY.md deleted file mode 100644 index f6c15d64..00000000 --- a/asdf-ghjk/SECURITY.md +++ /dev/null @@ -1,252 +0,0 @@ -# Security Policy - -## Supported Versions - -Currently supported versions of asdf-ghjk: - -| Version | Supported | -| ------- | ------------------ | -| 0.1.x | :white_check_mark: | -| < 0.1 | :x: | - -## Security Considerations - -### Download Security - -This plugin downloads ghjk binaries from GitHub releases. Security measures: - -1. **HTTPS Only**: All downloads use HTTPS -2. **Checksum Verification**: SHA256 checksums are verified when available -3. **Official Sources**: Only downloads from official `metatypedev/ghjk` repository -4. **Retry Logic**: Failed downloads are retried to prevent partial downloads - -### GitHub API Token - -If you use `GITHUB_API_TOKEN`: - -- **Minimal Permissions**: Token only needs public repository read access -- **Storage**: Store in environment variables, never commit to version control -- **Rotation**: Rotate tokens regularly -- **Scope**: Create tokens with minimal required scopes - -Creating a secure token: -1. Go to https://github.com/settings/tokens -2. Click "Generate new token (classic)" -3. Set expiration (recommended: 90 days) -4. **Don't select any scopes** (public repo access is default) -5. Generate and store securely - -### Script Security - -All shell scripts follow security best practices: - -- **Strict Mode**: `set -euo pipefail` in all scripts -- **Input Validation**: All user inputs are validated -- **Path Safety**: Paths are properly quoted and validated -- **No `eval`**: No use of `eval` or similar dangerous constructs -- **ShellCheck**: All scripts pass ShellCheck security checks - -### Dependencies - -This plugin has minimal dependencies: - -**Required (assumed to be system-provided):** -- bash -- curl -- tar -- grep -- sort - -**Runtime (for ghjk itself):** -- git -- curl -- tar -- unzip -- zstd - -All dependencies should be installed from trusted sources (official package managers). - -## Reporting a Vulnerability - -### Where to Report - -**DO NOT** open public issues for security vulnerabilities. - -Instead, please report security issues via one of these methods: - -1. **GitHub Security Advisories** (preferred) - - Go to https://github.com/Hyperpolymath/asdf-ghjk/security/advisories - - Click "Report a vulnerability" - - Fill out the form with details - -2. **Private Email** - - Email: [security contact needed] - - Subject: "[SECURITY] asdf-ghjk vulnerability report" - - Include: Detailed description, steps to reproduce, impact assessment - -### What to Include - -Please include as much information as possible: - -- **Description**: Clear description of the vulnerability -- **Impact**: What can an attacker do? What is the risk? -- **Reproduction**: Step-by-step instructions to reproduce -- **Affected Versions**: Which versions are affected? -- **Suggested Fix**: If you have ideas for fixing it -- **Disclosure Timeline**: Your preferred disclosure timeline - -### Response Timeline - -We will acknowledge your report within **48 hours** and provide: - -1. Confirmation of the issue -2. Assessment of severity -3. Estimated timeline for a fix -4. Communication plan for disclosure - -### Security Update Process - -When a security issue is confirmed: - -1. **Fix Development**: Develop and test fix privately -2. **CVE Assignment**: Request CVE if applicable -3. **Release**: Create security release -4. **Disclosure**: Publish security advisory -5. **Notification**: Notify users via GitHub and documentation - -### Disclosure Policy - -We follow **responsible disclosure**: - -- **Coordinated Disclosure**: Work with reporter on timeline -- **Typical Timeline**: 90 days from report to public disclosure -- **Early Disclosure**: If actively exploited or fix is available -- **Credit**: Security researchers are credited (unless they prefer anonymity) - -## Security Best Practices for Users - -### Installation Security - -```bash -# Verify plugin source -asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git - -# Verify it was added correctly -asdf plugin list --urls | grep ghjk -``` - -### Token Security - -```bash -# Store in shell profile, not in scripts -echo 'export GITHUB_API_TOKEN="ghp_..."' >> ~/.bashrc - -# Never commit tokens -echo 'GITHUB_API_TOKEN' >> .gitignore - -# Use environment-specific tokens in CI -# GitHub Actions: Use secrets -# GitLab CI: Use protected variables -``` - -### Verification - -```bash -# After installation, verify the binary -ghjk --version - -# Check where it's installed -which ghjk -ls -la ~/.asdf/installs/ghjk/ - -# Verify checksum if you saved it -sha256sum ~/.asdf/installs/ghjk//ghjk -``` - -### Update Regularly - -```bash -# Update plugin -asdf plugin update ghjk - -# Update ghjk itself -asdf install ghjk latest -asdf global ghjk latest -``` - -## Known Security Considerations - -### GitHub API Rate Limiting - -- **Risk**: Unauthenticated requests limited to 60/hour -- **Mitigation**: Use `GITHUB_API_TOKEN` for higher limits -- **Impact**: Low (only affects listing/downloading) - -### Man-in-the-Middle (MITM) - -- **Risk**: Network interception during download -- **Mitigation**: HTTPS only, checksum verification -- **Impact**: Low (checksums detect tampering) - -### Supply Chain - -- **Risk**: Compromised ghjk releases -- **Mitigation**: Verify checksums, download from official sources -- **Impact**: Medium (depends on ghjk project security) -- **Note**: This plugin does not control ghjk releases, only facilitates installation - -### Local File Permissions - -- **Risk**: Installed files readable by all users -- **Mitigation**: Follow asdf default permissions (user-only) -- **Impact**: Low (asdf handles permissions) - -## Security Checklist for Contributors - -Before submitting code: - -- [ ] All user inputs are validated -- [ ] All file paths are properly quoted -- [ ] No use of `eval`, `source` on untrusted input, or `exec` with user data -- [ ] ShellCheck passes with no warnings -- [ ] Dependencies are from trusted sources -- [ ] Secrets are not hardcoded -- [ ] Error messages don't leak sensitive information -- [ ] Tests include security-relevant cases - -## Third-Party Security - -### asdf - -This plugin depends on asdf: -- **Security**: https://github.com/asdf-vm/asdf/security -- **Updates**: Keep asdf updated - -### ghjk - -This plugin installs ghjk: -- **Security**: https://github.com/metatypedev/ghjk/security -- **Note**: We don't control ghjk security, only facilitate installation - -## Compliance - -This plugin: -- ✅ Follows OWASP secure coding practices -- ✅ Uses HTTPS for all downloads -- ✅ Validates all inputs -- ✅ Follows principle of least privilege -- ✅ Provides clear error messages without leaking sensitive data -- ✅ Uses secure random generation (when applicable) -- ✅ Properly handles file permissions - -## Contact - -For security concerns: -- Security Issues: Use GitHub Security Advisories -- General Security Questions: Open a discussion -- Urgent Issues: [Contact method needed] - ---- - -**Last Updated**: 2025-12-18 -**Next Review**: Before v0.2.0 release diff --git a/asdf-ghjk/docs/API_REFERENCE.adoc b/asdf-ghjk/docs/API_REFERENCE.adoc new file mode 100644 index 00000000..b468c736 --- /dev/null +++ b/asdf-ghjk/docs/API_REFERENCE.adoc @@ -0,0 +1,739 @@ +== API Reference + +Complete reference for asdf-ghjk functions, scripts, and environment +variables. + +=== Table of Contents + +* link:#scripts[Scripts] +* link:#library-functions[Library Functions] +* link:#environment-variables[Environment Variables] +* link:#exit-codes[Exit Codes] +* link:#file-formats[File Formats] + +=== Scripts + +==== bin/list-all + +Lists all available ghjk versions from GitHub releases. + +*Usage*: Called automatically by asdf + +[source,bash] +---- +./bin/list-all +---- + +*Output*: Space-separated list of versions + +.... +v0.1.0 v0.2.0 v0.3.0 v0.3.1 v0.3.2 +.... + +*Environment Variables*: - `+GITHUB_API_TOKEN+` (optional): GitHub API +token for higher rate limits + +*Exit Codes*: - `+0+`: Success - `+1+`: GitHub API error, network error, +or no versions found + +*Performance*: O(n) where n = number of releases; ~1-3 seconds without +cache, <100ms with cache + +''''' + +==== bin/download + +Downloads a specific ghjk version. + +*Usage*: Called automatically by asdf + +[source,bash] +---- +export ASDF_INSTALL_VERSION="0.3.2" +export ASDF_DOWNLOAD_PATH="/path/to/download" +./bin/download +---- + +*Required Environment Variables*: - `+ASDF_INSTALL_VERSION+`: Version to +download (e.g., "`0.3.2`") - `+ASDF_DOWNLOAD_PATH+`: Where to download +files + +*Optional Environment Variables*: - `+GITHUB_API_TOKEN+`: GitHub API +token + +*Side Effects*: - Downloads archive to +`+${ASDF_DOWNLOAD_PATH}/.tar.gz+` - Creates `+.metadata+` +file with version info + +*Exit Codes*: - `+0+`: Success - `+1+`: Missing environment variable, +download failure, or checksum mismatch + +*Performance*: ~5-30 seconds depending on network speed + +''''' + +==== bin/install + +Installs a downloaded ghjk version. + +*Usage*: Called automatically by asdf + +[source,bash] +---- +export ASDF_INSTALL_VERSION="0.3.2" +export ASDF_INSTALL_PATH="/path/to/install" +export ASDF_DOWNLOAD_PATH="/path/to/download" +export ASDF_INSTALL_TYPE="version" +./bin/install +---- + +*Required Environment Variables*: - `+ASDF_INSTALL_VERSION+`: Version to +install - `+ASDF_INSTALL_PATH+`: Where to install - +`+ASDF_INSTALL_TYPE+`: Must be "`version`" + +*Optional Environment Variables*: - `+ASDF_DOWNLOAD_PATH+`: Where files +were downloaded (defaults to adjacent to install path) + +*Side Effects*: - Extracts files to `+${ASDF_INSTALL_PATH}/+` - Creates +`+${ASDF_INSTALL_PATH}/bin/+` directory - Sets executable permissions - +Creates symlinks if needed + +*Exit Codes*: - `+0+`: Success - `+1+`: Missing environment variable, +extraction failure, or binary not found + +*Performance*: ~1-3 seconds + +''''' + +==== bin/list-bin-paths + +Returns paths where binaries are located. + +*Usage*: Called automatically by asdf + +[source,bash] +---- +./bin/list-bin-paths /path/to/install +---- + +*Arguments*: - `+$1+`: Installation path + +*Output*: One or more paths, one per line + +.... +/path/to/install/bin +.... + +*Exit Codes*: - `+0+`: Success - `+1+`: No install path provided + +''''' + +==== bin/help-overview + +Displays user-friendly help text. + +*Usage*: Manually by users + +[source,bash] +---- +./bin/help-overview +---- + +*Output*: Formatted help documentation + +*Exit Codes*: Always `+0+` + +''''' + +==== bin/latest-stable + +Returns the latest stable (non-prerelease) version. + +*Usage*: Scripts or manual use + +[source,bash] +---- +latest=$(./bin/latest-stable) +asdf install ghjk "$latest" +---- + +*Output*: Single version tag + +.... +v0.3.2 +.... + +*Exit Codes*: - `+0+`: Success - `+1+`: No stable versions found or +GitHub API error + +''''' + +=== Library Functions + +==== lib/utils.sh + +Core utility functions. Source this file to use functions: + +[source,bash] +---- +source "${PLUGIN_DIR}/lib/utils.sh" +---- + +===== get_platform() + +Detects current operating system and architecture. + +*Signature*: `+get_platform()+` + +*Returns*: Platform string + +*Example*: + +[source,bash] +---- +platform=$(get_platform) +echo "$platform" # x86_64-unknown-linux-gnu +---- + +*Possible Values*: - `+x86_64-unknown-linux-gnu+` - +`+aarch64-unknown-linux-gnu+` - `+x86_64-apple-darwin+` - +`+aarch64-apple-darwin+` + +*Exit Codes*: - `+0+`: Success - `+1+`: Unsupported platform + +''''' + +===== log(), success(), warn(), error() + +Logging functions with color output. + +*Signatures*: + +[source,bash] +---- +log "message" # Blue arrow prefix +success "message" # Green arrow prefix +warn "message" # Yellow warning prefix +error "message" # Red error prefix +---- + +*Output*: To stderr + +*Example*: + +[source,bash] +---- +log "Downloading version 0.3.2..." +success "Download complete" +warn "Checksum not available" +error "Failed to download" +---- + +''''' + +===== command_exists() + +Checks if a command is available in PATH. + +*Signature*: `+command_exists +` + +*Arguments*: - `+$1+`: Command name + +*Returns*: Nothing (use exit code) + +*Example*: + +[source,bash] +---- +if command_exists curl; then + echo "curl is available" +fi +---- + +*Exit Codes*: - `+0+`: Command exists - `+1+`: Command not found + +''''' + +===== check_dependencies() + +Verifies all required dependencies are installed. + +*Signature*: `+check_dependencies()+` + +*Checks*: bash, curl, tar, sort, grep + +*Example*: + +[source,bash] +---- +check_dependencies || exit 1 +---- + +*Exit Codes*: - `+0+`: All dependencies found - `+1+`: One or more +dependencies missing + +''''' + +===== github_api_fetch() + +Fetches data from GitHub API with caching. + +*Signature*: `+github_api_fetch [use_cache]+` + +*Arguments*: - `+$1+`: GitHub API URL - `+$2+`: Use cache (default: +true) + +*Environment Variables Used*: - `+GITHUB_API_TOKEN+` (optional) + +*Returns*: JSON response to stdout + +*Example*: + +[source,bash] +---- +releases=$(github_api_fetch "https://api.github.com/repos/metatypedev/ghjk/releases") +---- + +*Exit Codes*: - `+0+`: Success - `+1+`: API error or rate limit exceeded + +*Performance*: With cache: <100ms, Without cache: ~500-2000ms + +''''' + +===== sort_versions() + +Sorts versions semantically. + +*Signature*: `+sort_versions+` (reads from stdin) + +*Input*: Newline-separated versions + +*Output*: Sorted versions + +*Example*: + +[source,bash] +---- +echo -e "v0.3.0\nv0.1.0\nv0.2.0" | sort_versions +# v0.1.0 +# v0.2.0 +# v0.3.0 +---- + +*Exit Codes*: Always `+0+` + +''''' + +===== get_asset_name() + +Generates asset filename for a version and platform. + +*Signature*: `+get_asset_name +` + +*Arguments*: - `+$1+`: Version (with or without '`v`' prefix) - `+$2+`: +Platform string + +*Returns*: Asset filename + +*Example*: + +[source,bash] +---- +asset=$(get_asset_name "0.3.2" "x86_64-unknown-linux-gnu") +echo "$asset" # ghjk-v0.3.2-x86_64-unknown-linux-gnu.tar.gz +---- + +''''' + +===== get_download_url() + +Generates download URL for a version and platform. + +*Signature*: `+get_download_url +` + +*Arguments*: - `+$1+`: Version - `+$2+`: Platform string + +*Returns*: Download URL + +*Example*: + +[source,bash] +---- +url=$(get_download_url "0.3.2" "x86_64-unknown-linux-gnu") +echo "$url" +# https://github.com/metatypedev/ghjk/releases/download/v0.3.2/ghjk-v0.3.2-x86_64-unknown-linux-gnu.tar.gz +---- + +''''' + +===== download_file() + +Downloads a file with retry logic. + +*Signature*: `+download_file +` + +*Arguments*: - `+$1+`: URL to download - `+$2+`: Output file path + +*Retries*: 3 attempts with 2-second delay + +*Example*: + +[source,bash] +---- +download_file "https://example.com/file.tar.gz" "/tmp/file.tar.gz" +---- + +*Exit Codes*: - `+0+`: Success - `+1+`: Failed after retries + +''''' + +===== verify_checksum() + +Verifies SHA256 checksum of a file. + +*Signature*: `+verify_checksum +` + +*Arguments*: - `+$1+`: File to verify - `+$2+`: Expected SHA256 hash + +*Example*: + +[source,bash] +---- +if verify_checksum "/tmp/file.tar.gz" "abc123..."; then + echo "Checksum valid" +fi +---- + +*Exit Codes*: - `+0+`: Checksum matches or no checksum provided - `+1+`: +Checksum mismatch + +''''' + +===== extract_archive() + +Extracts a tar.gz archive. + +*Signature*: `+extract_archive +` + +*Arguments*: - `+$1+`: Archive file path - `+$2+`: Destination directory + +*Example*: + +[source,bash] +---- +extract_archive "/tmp/file.tar.gz" "/tmp/extracted" +---- + +*Exit Codes*: - `+0+`: Success - `+1+`: Extraction failed + +''''' + +===== cleanup() + +Removes a file or directory. + +*Signature*: `+cleanup +` + +*Arguments*: - `+$1+`: Path to remove + +*Example*: + +[source,bash] +---- +cleanup "/tmp/tempfile" +---- + +*Exit Codes*: Always `+0+` + +''''' + +==== lib/cache.sh + +Cache management functions. Source this file: + +[source,bash] +---- +source "${PLUGIN_DIR}/lib/cache.sh" +---- + +===== init_cache() + +Initializes cache directory. + +*Signature*: `+init_cache()+` + +*Creates*: `+~/.asdf/cache/ghjk/+` + +''''' + +===== get_cached() + +Retrieves cached response if valid. + +*Signature*: `+get_cached +` + +*Arguments*: - `+$1+`: URL that was cached + +*Returns*: Cached response or nothing + +*Exit Codes*: - `+0+`: Valid cache found - `+1+`: No cache or expired + +''''' + +===== save_to_cache() + +Saves response to cache. + +*Signature*: `+save_to_cache +` + +*Arguments*: - `+$1+`: URL to cache - `+$2+`: Response data + +''''' + +===== clear_cache() + +Removes all cached files. + +*Signature*: `+clear_cache()+` + +''''' + +===== clean_cache() + +Removes expired cache entries. + +*Signature*: `+clean_cache()+` + +''''' + +===== cache_stats() + +Displays cache statistics. + +*Signature*: `+cache_stats()+` + +*Output*: Human-readable statistics + +''''' + +=== Environment Variables + +==== User-Configurable + +[width="100%",cols="28%,24%,24%,24%",options="header",] +|=== +|Variable |Purpose |Default |Example +|`+GITHUB_API_TOKEN+` |GitHub API authentication |None +|`+ghp_abc123...+` + +|`+GHJK_CACHE_TTL+` |Cache time-to-live (seconds) |`+3600+` |`+7200+` + +|`+ASDF_DATA_DIR+` |asdf data directory |`+~/.asdf+` |`+/custom/path+` +|=== + +==== asdf-Provided + +[cols=",,",options="header",] +|=== +|Variable |Set By |Purpose +|`+ASDF_INSTALL_VERSION+` |asdf |Version to install +|`+ASDF_INSTALL_PATH+` |asdf |Installation destination +|`+ASDF_DOWNLOAD_PATH+` |asdf |Download destination +|`+ASDF_INSTALL_TYPE+` |asdf |Type of install (version/ref) +|=== + +==== Internal + +[cols=",",options="header",] +|=== +|Variable |Purpose +|`+PLUGIN_DIR+` |Plugin installation directory +|`+GITHUB_REPO+` |ghjk repository name +|`+GITHUB_API_URL+` |Base GitHub API URL +|=== + +''''' + +=== Exit Codes + +All scripts follow standard Unix conventions: + +[cols=",",options="header",] +|=== +|Code |Meaning +|`+0+` |Success +|`+1+` |General error +|Other |Not used (reserved for future) +|=== + +''''' + +=== File Formats + +==== .metadata + +Created by `+bin/download+`, read by `+bin/install+`. + +*Location*: `+${ASDF_DOWNLOAD_PATH}/.metadata+` + +*Format*: Shell variable assignments + +*Example*: + +[source,bash] +---- +version=0.3.2 +platform=x86_64-unknown-linux-gnu +archive=ghjk-v0.3.2-x86_64-unknown-linux-gnu.tar.gz +checksum=abc123def456... +---- + +*Usage*: + +[source,bash] +---- +source "${ASDF_DOWNLOAD_PATH}/.metadata" +echo "Version: $version" +---- + +==== Cache Files + +*Location*: `+~/.asdf/cache/ghjk/.json+` + +*Format*: Raw JSON from GitHub API + +*Naming*: SHA256 hash of the URL + +*TTL*: Controlled by `+GHJK_CACHE_TTL+` + +''''' + +=== Error Messages + +==== Common Patterns + +[width="100%",cols="36%,34%,30%",options="header",] +|=== +|Pattern |Meaning |Action +|`+Error: ASDF_* required+` |Missing environment variable |Set variable + +|`+Error: GitHub API rate limit+` |Too many requests |Set +`+GITHUB_API_TOKEN+` + +|`+Error: Checksum verification failed+` |Download corrupted +|Re-download + +|`+Error: Unsupported platform+` |Platform not supported |Check +compatibility +|=== + +==== Debug Output + +Enable with: + +[source,bash] +---- +export ASDF_DEBUG=1 +---- + +''''' + +=== Version Compatibility + +==== Script Versions + +Scripts follow semantic versioning conceptually but are versioned with +the plugin. + +==== API Stability + +*Stable* (will not break): - All `+bin/*+` scripts interface with asdf - +Environment variables read/written - Exit codes - File formats + +*Internal* (may change): - Library function signatures - Internal +variable names - Cache format - Log message formats + +''''' + +=== Examples + +==== Complete Installation Flow + +[source,bash] +---- +# 1. List versions +export GITHUB_API_TOKEN="ghp_..." +versions=$(./bin/list-all) + +# 2. Download +export ASDF_INSTALL_VERSION="0.3.2" +export ASDF_DOWNLOAD_PATH="/tmp/download" +./bin/download + +# 3. Install +export ASDF_INSTALL_PATH="/tmp/install" +export ASDF_INSTALL_TYPE="version" +./bin/install + +# 4. Verify +/tmp/install/bin/ghjk --version +---- + +==== Using Library Functions + +[source,bash] +---- +#!/bin/bash +source lib/utils.sh + +# Detect platform +platform=$(get_platform) +log "Detected platform: $platform" + +# Check dependencies +if check_dependencies; then + success "All dependencies found" +else + error "Missing dependencies" + exit 1 +fi + +# Fetch releases +releases=$(github_api_fetch "https://api.github.com/repos/metatypedev/ghjk/releases") + +# Get latest version +latest=$(echo "$releases" | grep -o '"tag_name": *"[^"]*"' | head -1 | sed 's/"tag_name": *"\([^"]*\)"/\1/') +log "Latest version: $latest" + +# Download +url=$(get_download_url "$latest" "$platform") +download_file "$url" "/tmp/ghjk.tar.gz" + +# Extract +extract_archive "/tmp/ghjk.tar.gz" "/tmp/ghjk" + +# Cleanup +cleanup "/tmp/ghjk.tar.gz" +---- + +''''' + +=== Performance Tips + +[arabic] +. *Use caching*: Keep `+GHJK_CACHE_TTL+` at default or higher +. *Set GitHub token*: Avoid rate limits +. *Parallel installs*: Install multiple versions in separate shells +. *Clean cache*: Run `+./scripts/cleanup.sh --cache+` periodically + +''''' + +=== See Also + +* link:ARCHITECTURE.md[Architecture Documentation] +* link:TROUBLESHOOTING.md[Troubleshooting Guide] +* link:EXAMPLES.md[Examples] + +''''' + +*Last Updated*: 2024-11-22 diff --git a/asdf-ghjk/docs/API_REFERENCE.md b/asdf-ghjk/docs/API_REFERENCE.md deleted file mode 100644 index b7470fd0..00000000 --- a/asdf-ghjk/docs/API_REFERENCE.md +++ /dev/null @@ -1,722 +0,0 @@ -# API Reference - -Complete reference for asdf-ghjk functions, scripts, and environment variables. - -## Table of Contents - -- [Scripts](#scripts) -- [Library Functions](#library-functions) -- [Environment Variables](#environment-variables) -- [Exit Codes](#exit-codes) -- [File Formats](#file-formats) - -## Scripts - -### bin/list-all - -Lists all available ghjk versions from GitHub releases. - -**Usage**: Called automatically by asdf - -```bash -./bin/list-all -``` - -**Output**: Space-separated list of versions - -``` -v0.1.0 v0.2.0 v0.3.0 v0.3.1 v0.3.2 -``` - -**Environment Variables**: -- `GITHUB_API_TOKEN` (optional): GitHub API token for higher rate limits - -**Exit Codes**: -- `0`: Success -- `1`: GitHub API error, network error, or no versions found - -**Performance**: O(n) where n = number of releases; ~1-3 seconds without cache, <100ms with cache - ---- - -### bin/download - -Downloads a specific ghjk version. - -**Usage**: Called automatically by asdf - -```bash -export ASDF_INSTALL_VERSION="0.3.2" -export ASDF_DOWNLOAD_PATH="/path/to/download" -./bin/download -``` - -**Required Environment Variables**: -- `ASDF_INSTALL_VERSION`: Version to download (e.g., "0.3.2") -- `ASDF_DOWNLOAD_PATH`: Where to download files - -**Optional Environment Variables**: -- `GITHUB_API_TOKEN`: GitHub API token - -**Side Effects**: -- Downloads archive to `${ASDF_DOWNLOAD_PATH}/.tar.gz` -- Creates `.metadata` file with version info - -**Exit Codes**: -- `0`: Success -- `1`: Missing environment variable, download failure, or checksum mismatch - -**Performance**: ~5-30 seconds depending on network speed - ---- - -### bin/install - -Installs a downloaded ghjk version. - -**Usage**: Called automatically by asdf - -```bash -export ASDF_INSTALL_VERSION="0.3.2" -export ASDF_INSTALL_PATH="/path/to/install" -export ASDF_DOWNLOAD_PATH="/path/to/download" -export ASDF_INSTALL_TYPE="version" -./bin/install -``` - -**Required Environment Variables**: -- `ASDF_INSTALL_VERSION`: Version to install -- `ASDF_INSTALL_PATH`: Where to install -- `ASDF_INSTALL_TYPE`: Must be "version" - -**Optional Environment Variables**: -- `ASDF_DOWNLOAD_PATH`: Where files were downloaded (defaults to adjacent to install path) - -**Side Effects**: -- Extracts files to `${ASDF_INSTALL_PATH}/` -- Creates `${ASDF_INSTALL_PATH}/bin/` directory -- Sets executable permissions -- Creates symlinks if needed - -**Exit Codes**: -- `0`: Success -- `1`: Missing environment variable, extraction failure, or binary not found - -**Performance**: ~1-3 seconds - ---- - -### bin/list-bin-paths - -Returns paths where binaries are located. - -**Usage**: Called automatically by asdf - -```bash -./bin/list-bin-paths /path/to/install -``` - -**Arguments**: -- `$1`: Installation path - -**Output**: One or more paths, one per line - -``` -/path/to/install/bin -``` - -**Exit Codes**: -- `0`: Success -- `1`: No install path provided - ---- - -### bin/help-overview - -Displays user-friendly help text. - -**Usage**: Manually by users - -```bash -./bin/help-overview -``` - -**Output**: Formatted help documentation - -**Exit Codes**: Always `0` - ---- - -### bin/latest-stable - -Returns the latest stable (non-prerelease) version. - -**Usage**: Scripts or manual use - -```bash -latest=$(./bin/latest-stable) -asdf install ghjk "$latest" -``` - -**Output**: Single version tag - -``` -v0.3.2 -``` - -**Exit Codes**: -- `0`: Success -- `1`: No stable versions found or GitHub API error - ---- - -## Library Functions - -### lib/utils.sh - -Core utility functions. Source this file to use functions: - -```bash -source "${PLUGIN_DIR}/lib/utils.sh" -``` - -#### get_platform() - -Detects current operating system and architecture. - -**Signature**: `get_platform()` - -**Returns**: Platform string - -**Example**: -```bash -platform=$(get_platform) -echo "$platform" # x86_64-unknown-linux-gnu -``` - -**Possible Values**: -- `x86_64-unknown-linux-gnu` -- `aarch64-unknown-linux-gnu` -- `x86_64-apple-darwin` -- `aarch64-apple-darwin` - -**Exit Codes**: -- `0`: Success -- `1`: Unsupported platform - ---- - -#### log(), success(), warn(), error() - -Logging functions with color output. - -**Signatures**: -```bash -log "message" # Blue arrow prefix -success "message" # Green arrow prefix -warn "message" # Yellow warning prefix -error "message" # Red error prefix -``` - -**Output**: To stderr - -**Example**: -```bash -log "Downloading version 0.3.2..." -success "Download complete" -warn "Checksum not available" -error "Failed to download" -``` - ---- - -#### command_exists() - -Checks if a command is available in PATH. - -**Signature**: `command_exists ` - -**Arguments**: -- `$1`: Command name - -**Returns**: Nothing (use exit code) - -**Example**: -```bash -if command_exists curl; then - echo "curl is available" -fi -``` - -**Exit Codes**: -- `0`: Command exists -- `1`: Command not found - ---- - -#### check_dependencies() - -Verifies all required dependencies are installed. - -**Signature**: `check_dependencies()` - -**Checks**: bash, curl, tar, sort, grep - -**Example**: -```bash -check_dependencies || exit 1 -``` - -**Exit Codes**: -- `0`: All dependencies found -- `1`: One or more dependencies missing - ---- - -#### github_api_fetch() - -Fetches data from GitHub API with caching. - -**Signature**: `github_api_fetch [use_cache]` - -**Arguments**: -- `$1`: GitHub API URL -- `$2`: Use cache (default: true) - -**Environment Variables Used**: -- `GITHUB_API_TOKEN` (optional) - -**Returns**: JSON response to stdout - -**Example**: -```bash -releases=$(github_api_fetch "https://api.github.com/repos/metatypedev/ghjk/releases") -``` - -**Exit Codes**: -- `0`: Success -- `1`: API error or rate limit exceeded - -**Performance**: With cache: <100ms, Without cache: ~500-2000ms - ---- - -#### sort_versions() - -Sorts versions semantically. - -**Signature**: `sort_versions` (reads from stdin) - -**Input**: Newline-separated versions - -**Output**: Sorted versions - -**Example**: -```bash -echo -e "v0.3.0\nv0.1.0\nv0.2.0" | sort_versions -# v0.1.0 -# v0.2.0 -# v0.3.0 -``` - -**Exit Codes**: Always `0` - ---- - -#### get_asset_name() - -Generates asset filename for a version and platform. - -**Signature**: `get_asset_name ` - -**Arguments**: -- `$1`: Version (with or without 'v' prefix) -- `$2`: Platform string - -**Returns**: Asset filename - -**Example**: -```bash -asset=$(get_asset_name "0.3.2" "x86_64-unknown-linux-gnu") -echo "$asset" # ghjk-v0.3.2-x86_64-unknown-linux-gnu.tar.gz -``` - ---- - -#### get_download_url() - -Generates download URL for a version and platform. - -**Signature**: `get_download_url ` - -**Arguments**: -- `$1`: Version -- `$2`: Platform string - -**Returns**: Download URL - -**Example**: -```bash -url=$(get_download_url "0.3.2" "x86_64-unknown-linux-gnu") -echo "$url" -# https://github.com/metatypedev/ghjk/releases/download/v0.3.2/ghjk-v0.3.2-x86_64-unknown-linux-gnu.tar.gz -``` - ---- - -#### download_file() - -Downloads a file with retry logic. - -**Signature**: `download_file ` - -**Arguments**: -- `$1`: URL to download -- `$2`: Output file path - -**Retries**: 3 attempts with 2-second delay - -**Example**: -```bash -download_file "https://example.com/file.tar.gz" "/tmp/file.tar.gz" -``` - -**Exit Codes**: -- `0`: Success -- `1`: Failed after retries - ---- - -#### verify_checksum() - -Verifies SHA256 checksum of a file. - -**Signature**: `verify_checksum ` - -**Arguments**: -- `$1`: File to verify -- `$2`: Expected SHA256 hash - -**Example**: -```bash -if verify_checksum "/tmp/file.tar.gz" "abc123..."; then - echo "Checksum valid" -fi -``` - -**Exit Codes**: -- `0`: Checksum matches or no checksum provided -- `1`: Checksum mismatch - ---- - -#### extract_archive() - -Extracts a tar.gz archive. - -**Signature**: `extract_archive ` - -**Arguments**: -- `$1`: Archive file path -- `$2`: Destination directory - -**Example**: -```bash -extract_archive "/tmp/file.tar.gz" "/tmp/extracted" -``` - -**Exit Codes**: -- `0`: Success -- `1`: Extraction failed - ---- - -#### cleanup() - -Removes a file or directory. - -**Signature**: `cleanup ` - -**Arguments**: -- `$1`: Path to remove - -**Example**: -```bash -cleanup "/tmp/tempfile" -``` - -**Exit Codes**: Always `0` - ---- - -### lib/cache.sh - -Cache management functions. Source this file: - -```bash -source "${PLUGIN_DIR}/lib/cache.sh" -``` - -#### init_cache() - -Initializes cache directory. - -**Signature**: `init_cache()` - -**Creates**: `~/.asdf/cache/ghjk/` - ---- - -#### get_cached() - -Retrieves cached response if valid. - -**Signature**: `get_cached ` - -**Arguments**: -- `$1`: URL that was cached - -**Returns**: Cached response or nothing - -**Exit Codes**: -- `0`: Valid cache found -- `1`: No cache or expired - ---- - -#### save_to_cache() - -Saves response to cache. - -**Signature**: `save_to_cache ` - -**Arguments**: -- `$1`: URL to cache -- `$2`: Response data - ---- - -#### clear_cache() - -Removes all cached files. - -**Signature**: `clear_cache()` - ---- - -#### clean_cache() - -Removes expired cache entries. - -**Signature**: `clean_cache()` - ---- - -#### cache_stats() - -Displays cache statistics. - -**Signature**: `cache_stats()` - -**Output**: Human-readable statistics - ---- - -## Environment Variables - -### User-Configurable - -| Variable | Purpose | Default | Example | -|----------|---------|---------|---------| -| `GITHUB_API_TOKEN` | GitHub API authentication | None | `ghp_abc123...` | -| `GHJK_CACHE_TTL` | Cache time-to-live (seconds) | `3600` | `7200` | -| `ASDF_DATA_DIR` | asdf data directory | `~/.asdf` | `/custom/path` | - -### asdf-Provided - -| Variable | Set By | Purpose | -|----------|--------|---------| -| `ASDF_INSTALL_VERSION` | asdf | Version to install | -| `ASDF_INSTALL_PATH` | asdf | Installation destination | -| `ASDF_DOWNLOAD_PATH` | asdf | Download destination | -| `ASDF_INSTALL_TYPE` | asdf | Type of install (version/ref) | - -### Internal - -| Variable | Purpose | -|----------|---------| -| `PLUGIN_DIR` | Plugin installation directory | -| `GITHUB_REPO` | ghjk repository name | -| `GITHUB_API_URL` | Base GitHub API URL | - ---- - -## Exit Codes - -All scripts follow standard Unix conventions: - -| Code | Meaning | -|------|---------| -| `0` | Success | -| `1` | General error | -| Other | Not used (reserved for future) | - ---- - -## File Formats - -### .metadata - -Created by `bin/download`, read by `bin/install`. - -**Location**: `${ASDF_DOWNLOAD_PATH}/.metadata` - -**Format**: Shell variable assignments - -**Example**: -```bash -version=0.3.2 -platform=x86_64-unknown-linux-gnu -archive=ghjk-v0.3.2-x86_64-unknown-linux-gnu.tar.gz -checksum=abc123def456... -``` - -**Usage**: -```bash -source "${ASDF_DOWNLOAD_PATH}/.metadata" -echo "Version: $version" -``` - -### Cache Files - -**Location**: `~/.asdf/cache/ghjk/.json` - -**Format**: Raw JSON from GitHub API - -**Naming**: SHA256 hash of the URL - -**TTL**: Controlled by `GHJK_CACHE_TTL` - ---- - -## Error Messages - -### Common Patterns - -| Pattern | Meaning | Action | -|---------|---------|--------| -| `Error: ASDF_* required` | Missing environment variable | Set variable | -| `Error: GitHub API rate limit` | Too many requests | Set `GITHUB_API_TOKEN` | -| `Error: Checksum verification failed` | Download corrupted | Re-download | -| `Error: Unsupported platform` | Platform not supported | Check compatibility | - -### Debug Output - -Enable with: -```bash -export ASDF_DEBUG=1 -``` - ---- - -## Version Compatibility - -### Script Versions - -Scripts follow semantic versioning conceptually but are versioned with the plugin. - -### API Stability - -**Stable** (will not break): -- All `bin/*` scripts interface with asdf -- Environment variables read/written -- Exit codes -- File formats - -**Internal** (may change): -- Library function signatures -- Internal variable names -- Cache format -- Log message formats - ---- - -## Examples - -### Complete Installation Flow - -```bash -# 1. List versions -export GITHUB_API_TOKEN="ghp_..." -versions=$(./bin/list-all) - -# 2. Download -export ASDF_INSTALL_VERSION="0.3.2" -export ASDF_DOWNLOAD_PATH="/tmp/download" -./bin/download - -# 3. Install -export ASDF_INSTALL_PATH="/tmp/install" -export ASDF_INSTALL_TYPE="version" -./bin/install - -# 4. Verify -/tmp/install/bin/ghjk --version -``` - -### Using Library Functions - -```bash -#!/bin/bash -source lib/utils.sh - -# Detect platform -platform=$(get_platform) -log "Detected platform: $platform" - -# Check dependencies -if check_dependencies; then - success "All dependencies found" -else - error "Missing dependencies" - exit 1 -fi - -# Fetch releases -releases=$(github_api_fetch "https://api.github.com/repos/metatypedev/ghjk/releases") - -# Get latest version -latest=$(echo "$releases" | grep -o '"tag_name": *"[^"]*"' | head -1 | sed 's/"tag_name": *"\([^"]*\)"/\1/') -log "Latest version: $latest" - -# Download -url=$(get_download_url "$latest" "$platform") -download_file "$url" "/tmp/ghjk.tar.gz" - -# Extract -extract_archive "/tmp/ghjk.tar.gz" "/tmp/ghjk" - -# Cleanup -cleanup "/tmp/ghjk.tar.gz" -``` - ---- - -## Performance Tips - -1. **Use caching**: Keep `GHJK_CACHE_TTL` at default or higher -2. **Set GitHub token**: Avoid rate limits -3. **Parallel installs**: Install multiple versions in separate shells -4. **Clean cache**: Run `./scripts/cleanup.sh --cache` periodically - ---- - -## See Also - -- [Architecture Documentation](ARCHITECTURE.md) -- [Troubleshooting Guide](TROUBLESHOOTING.md) -- [Examples](EXAMPLES.md) - ---- - -**Last Updated**: 2024-11-22 diff --git a/asdf-ghjk/docs/ARCHITECTURE.adoc b/asdf-ghjk/docs/ARCHITECTURE.adoc new file mode 100644 index 00000000..a3a0bca2 --- /dev/null +++ b/asdf-ghjk/docs/ARCHITECTURE.adoc @@ -0,0 +1,439 @@ +== Architecture Documentation + +This document describes the internal architecture and design decisions +of asdf-ghjk. + +=== Table of Contents + +* link:#overview[Overview] +* link:#directory-structure[Directory Structure] +* link:#component-architecture[Component Architecture] +* link:#data-flow[Data Flow] +* link:#design-decisions[Design Decisions] +* link:#extension-points[Extension Points] + +=== Overview + +asdf-ghjk is an asdf plugin that follows the asdf plugin specification +to provide version management for ghjk. The plugin is implemented +entirely in Bash for maximum portability and minimal dependencies. + +==== Key Principles + +[arabic] +. *Simplicity*: Minimal dependencies, straightforward implementation +. *Portability*: Works across Linux and macOS with bash 4.0+ +. *Reliability*: Comprehensive error handling and validation +. *Performance*: Caching and efficient algorithms +. *Security*: Checksum verification and HTTPS-only downloads + +=== Directory Structure + +.... +asdf-ghjk/ +├── bin/ # Executable scripts (asdf interface) +│ ├── download # Downloads ghjk releases +│ ├── install # Installs downloaded releases +│ ├── list-all # Lists all available versions +│ ├── list-bin-paths # Lists binary paths for asdf +│ ├── help-overview # Provides help text +│ └── latest-stable # Returns latest stable version +├── lib/ # Shared library code +│ ├── utils.sh # Core utilities and helpers +│ └── cache.sh # API response caching +├── test/ # Test suite +│ ├── *.bats # BATS test files +│ └── test_helpers.bash # Test helper functions +├── scripts/ # Development and maintenance scripts +│ ├── setup-dev.sh # Development environment setup +│ ├── test.sh # Test runner +│ └── benchmark.sh # Performance benchmarking +├── docs/ # Documentation +│ ├── *.md # Various documentation files +├── examples/ # Usage examples +│ ├── Dockerfile # Docker integration examples +│ └── docker-compose.yml # Docker Compose examples +├── completions/ # Shell completion scripts +│ ├── ghjk.bash # Bash completions +│ └── ghjk.zsh # Zsh completions +└── .github/ # GitHub-specific files + ├── workflows/ # GitHub Actions CI/CD + └── ISSUE_TEMPLATE/ # Issue templates +.... + +=== Component Architecture + +==== 1. Core Scripts (`+bin/+`) + +===== `+bin/list-all+` + +*Purpose*: List all available ghjk versions from GitHub releases + +*Flow*: 1. Source utilities 2. Check dependencies 3. Fetch releases from +GitHub API (with caching) 4. Extract version tags 5. Sort versions +semantically 6. Output space-separated list + +*Dependencies*: `+lib/utils.sh+`, `+lib/cache.sh+` (optional) + +*Output Format*: Space-separated versions on single line + +===== `+bin/download+` + +*Purpose*: Download ghjk binary for specified version + +*Flow*: 1. Read environment variables (`+ASDF_INSTALL_VERSION+`, +`+ASDF_DOWNLOAD_PATH+`) 2. Detect platform architecture 3. Construct +download URL 4. Fetch release metadata for checksum 5. Download binary +with retry logic 6. Verify checksum (if available) 7. Save metadata for +install script + +*Dependencies*: `+lib/utils.sh+` + +*Side Effects*: - Downloads file to `+ASDF_DOWNLOAD_PATH+` - Creates +`+.metadata+` file + +===== `+bin/install+` + +*Purpose*: Install downloaded ghjk binary + +*Flow*: 1. Read environment variables 2. Locate downloaded archive 3. +Extract to install path 4. Verify binary exists and is executable 5. +Check runtime dependencies 6. Create bin/ symlink if needed + +*Dependencies*: `+lib/utils.sh+` + +*Side Effects*: - Extracts files to `+ASDF_INSTALL_PATH+` - Creates +symlinks - Sets executable permissions + +===== `+bin/list-bin-paths+` + +*Purpose*: Tell asdf where to find binaries + +*Flow*: 1. Check for `+bin/+` directory 2. Fall back to root directory +if needed 3. Output path(s) + +*Called By*: asdf (automatically) + +===== `+bin/help-overview+` + +*Purpose*: Provide user-friendly help text + +*Output*: Formatted help documentation + +===== `+bin/latest-stable+` + +*Purpose*: Get latest non-prerelease version + +*Flow*: 1. Fetch releases 2. Filter out pre-releases (rc, alpha, beta) +3. Return first (latest) version + +==== 2. Library Code (`+lib/+`) + +===== `+lib/utils.sh+` + +*Core utility functions*: + +[cols=",",options="header",] +|=== +|Function |Purpose +|`+get_platform()+` |Detect OS and architecture +|`+log()+`, `+success()+`, `+warn()+`, `+error()+` |Logging with colors +|`+command_exists()+` |Check if command is available +|`+check_dependencies()+` |Verify required tools +|`+github_api_fetch()+` |Fetch from GitHub API with caching +|`+sort_versions()+` |Sort versions semantically +|`+get_asset_name()+` |Generate asset filename +|`+get_download_url()+` |Generate download URL +|`+download_file()+` |Download with retry logic +|`+verify_checksum()+` |SHA256 verification +|`+extract_archive()+` |Extract tar.gz files +|`+cleanup()+` |Clean up temporary files +|=== + +*Design*: Single-responsibility functions, pure where possible + +===== `+lib/cache.sh+` + +*Caching implementation*: + +[cols=",",options="header",] +|=== +|Function |Purpose +|`+init_cache()+` |Initialize cache directory +|`+get_cache_path()+` |Generate cache file path +|`+is_cache_valid()+` |Check cache freshness +|`+get_cached()+` |Retrieve cached response +|`+save_to_cache()+` |Store response in cache +|`+clear_cache()+` |Remove all cache +|`+clean_cache()+` |Remove expired cache +|`+cache_stats()+` |Display cache statistics +|=== + +*Design*: - TTL-based expiration (default 1 hour) - SHA256-based cache +keys - Graceful degradation if caching fails + +==== 3. Test Suite (`+test/+`) + +*Framework*: BATS (Bash Automated Testing System) + +*Test Files*: - `+utils.bats+`: Unit tests for utility functions - +`+list-all.bats+`: Tests for version listing - `+download.bats+`: Tests +for download functionality - `+install.bats+`: Tests for installation + +*Test Helpers*: Common setup/teardown, mock data, fixtures + +=== Data Flow + +==== Version Installation Flow + +.... +User runs: asdf install ghjk 0.3.2 + ↓ +asdf calls: bin/download + ↓ +bin/download: + 1. Detects platform (x86_64-unknown-linux-gnu) + 2. Constructs URL (github.com/.../ghjk-v0.3.2-x86_64-unknown-linux-gnu.tar.gz) + 3. Fetches release metadata + 4. Downloads file (with retry) + 5. Verifies checksum + 6. Saves metadata + ↓ +asdf calls: bin/install + ↓ +bin/install: + 1. Reads metadata + 2. Extracts archive + 3. Verifies binary + 4. Creates symlinks + 5. Checks dependencies + ↓ +asdf creates shims + ↓ +User runs: ghjk --version +.... + +==== Version Listing Flow + +.... +User runs: asdf list all ghjk + ↓ +asdf calls: bin/list-all + ↓ +bin/list-all: + 1. Checks cache + 2. If cached: return cached data + 3. If not cached: + a. Fetches from GitHub API + b. Paginates through all releases + c. Extracts version tags + d. Saves to cache + 4. Sorts versions + 5. Outputs space-separated list + ↓ +asdf displays to user +.... + +=== Design Decisions + +==== Why Bash? + +*Chosen*: Bash 4.0+ + +*Rationale*: - Required by asdf specification - Maximum portability +(available on all target platforms) - No compilation needed - +Well-understood by shell users - Rich ecosystem of tools + +*Tradeoffs*: - Less type safety than compiled languages - Harder to +refactor than modern languages - Requires careful error handling + +==== Why Caching? + +*Chosen*: File-based TTL cache + +*Rationale*: - Reduces GitHub API calls (rate limit friendly) - Improves +performance for repeated operations - Simple implementation without +external dependencies - Transparent to users + +*Implementation*: - Cache location: `+~/.asdf/cache/ghjk/+` - TTL: 1 +hour (configurable via `+GHJK_CACHE_TTL+`) - Key: SHA256 hash of URL - +Format: Raw JSON responses + +*Tradeoffs*: - Slightly stale data possible - Disk space usage (minimal, +~KB per cached response) - Manual cache invalidation needed for forced +updates + +==== Platform Detection + +*Method*: `+uname+` system calls + +*Mapping*: + +[source,bash] +---- +Linux + x86_64 → x86_64-unknown-linux-gnu +Linux + aarch64 → aarch64-unknown-linux-gnu +Darwin + x86_64 → x86_64-apple-darwin +Darwin + arm64 → aarch64-apple-darwin +---- + +*Rationale*: Matches ghjk’s release naming convention + +==== Checksum Verification + +*Method*: SHA256 from GitHub release metadata + +*Flow*: 1. Fetch release metadata from GitHub API 2. Extract SHA256 from +asset metadata 3. Calculate SHA256 of downloaded file 4. Compare hashes +5. Fail installation if mismatch + +*Rationale*: - Prevents corrupted downloads - Detects tampering - +Industry-standard algorithm + +*Tradeoffs*: - Extra API call - Slight performance overhead - Warnings +if checksum unavailable (rare) + +==== Error Handling Strategy + +*Principles*: 1. *Fail Fast*: Exit immediately on critical errors 2. +*Clear Messages*: Human-readable error descriptions 3. *Actionable*: +Suggest solutions when possible 4. *Logged*: All errors go to stderr 5. +*Codes*: Proper exit codes (0 = success, non-zero = failure) + +*Example*: + +[source,bash] +---- +if ! curl -fsSL "$url" -o "$output"; then + error "Failed to download ghjk ${version}" + error "Check your internet connection and try again" + error "URL: $url" + exit 1 +fi +---- + +==== Dependency Philosophy + +*Approach*: Minimal, standard dependencies only + +*Required*: - bash (4.0+) - curl - tar - grep - sort + +*Rationale*: Available on all target platforms by default + +*Not Required*: - jq (use grep/sed for JSON parsing) - wget (use curl) - +python (keep everything in bash) + +=== Extension Points + +==== Adding New Scripts + +To add a new bin script: + +[arabic] +. Create file in `+bin/+` +. Add shebang: `+#!/usr/bin/env bash+` +. Set strict mode: `+set -euo pipefail+` +. Source utilities: `+source "${PLUGIN_DIR}/lib/utils.sh"+` +. Implement functionality +. Make executable: `+chmod +x bin/new-script+` +. Document in README +. Add tests in `+test/+` + +==== Adding New Utilities + +To add a new utility function: + +[arabic] +. Add to `+lib/utils.sh+` +. Follow naming convention (lowercase with underscores) +. Add documentation comment +. Write tests in `+test/utils.bats+` +. Update ARCHITECTURE.md (this file) + +==== Adding Platform Support + +To add a new platform: + +[arabic] +. Update `+get_platform()+` in `+lib/utils.sh+` +. Add platform detection logic +. Add platform to documentation +. Update tests +. Add CI test matrix entry + +==== Customizing Cache Behavior + +Environment variables: + +* `+GHJK_CACHE_TTL+`: Cache time-to-live in seconds (default: 3600) +* `+ASDF_DATA_DIR+`: Base directory for asdf data (cache subdirectory) + +=== Performance Characteristics + +==== Time Complexity + +[cols=",,",options="header",] +|=== +|Operation |Complexity |Notes +|list-all (cached) |O(1) |Direct file read +|list-all (uncached) |O(n) |n = number of releases +|download |O(1) |Single file download +|install |O(1) |Single archive extraction +|sort_versions |O(n log n) |Standard sort +|=== + +==== Space Complexity + +[cols=",",options="header",] +|=== +|Component |Space Usage +|Plugin code |< 100 KB +|Cache (per response) |~10-50 KB +|Downloaded archive |10-50 MB +|Installed binary |10-50 MB +|Per version total |~20-100 MB +|=== + +=== Security Considerations + +==== Attack Surface + +*Potential Vectors*: 1. Malicious GitHub responses 2. Man-in-the-middle +attacks 3. Compromised downloads 4. Path traversal attacks + +*Mitigations*: 1. HTTPS-only connections 2. Checksum verification 3. +Input validation 4. Proper path quoting 5. No use of `+eval+` or +dangerous constructs + +==== Code Review Points + +When reviewing changes: - [ ] All user inputs validated - [ ] All file +paths properly quoted - [ ] No use of `+eval+`, `+source+` on untrusted +input - [ ] HTTPS used for all downloads - [ ] Error messages don’t leak +sensitive data - [ ] ShellCheck passes - [ ] Tests cover +security-relevant cases + +=== Future Enhancements + +Potential additions: + +[arabic] +. *Parallel Downloads*: Download/install multiple versions concurrently +. *Mirror Support*: Allow alternative download sources +. *GPG Verification*: Verify GPG signatures if ghjk adds them +. *Version Constraints*: Support version range specifications +. *Rollback Support*: Automatically rollback failed installations +. *Telemetry*: Optional usage statistics (opt-in) + +=== References + +* https://asdf-vm.com/plugins/create.html[asdf Plugin Development] +* https://google.github.io/styleguide/shellguide.html[Google Shell Style +Guide] +* https://www.shellcheck.net/[ShellCheck] +* https://github.com/bats-core/bats-core[BATS Testing] +* https://github.com/metatypedev/ghjk[ghjk Repository] + +''''' + +*Maintained By*: asdf-ghjk contributors *Last Updated*: 2024-11-22 diff --git a/asdf-ghjk/docs/ARCHITECTURE.md b/asdf-ghjk/docs/ARCHITECTURE.md deleted file mode 100644 index c7485d43..00000000 --- a/asdf-ghjk/docs/ARCHITECTURE.md +++ /dev/null @@ -1,476 +0,0 @@ -# Architecture Documentation - -This document describes the internal architecture and design decisions of asdf-ghjk. - -## Table of Contents - -- [Overview](#overview) -- [Directory Structure](#directory-structure) -- [Component Architecture](#component-architecture) -- [Data Flow](#data-flow) -- [Design Decisions](#design-decisions) -- [Extension Points](#extension-points) - -## Overview - -asdf-ghjk is an asdf plugin that follows the asdf plugin specification to provide version management for ghjk. The plugin is implemented entirely in Bash for maximum portability and minimal dependencies. - -### Key Principles - -1. **Simplicity**: Minimal dependencies, straightforward implementation -2. **Portability**: Works across Linux and macOS with bash 4.0+ -3. **Reliability**: Comprehensive error handling and validation -4. **Performance**: Caching and efficient algorithms -5. **Security**: Checksum verification and HTTPS-only downloads - -## Directory Structure - -``` -asdf-ghjk/ -├── bin/ # Executable scripts (asdf interface) -│ ├── download # Downloads ghjk releases -│ ├── install # Installs downloaded releases -│ ├── list-all # Lists all available versions -│ ├── list-bin-paths # Lists binary paths for asdf -│ ├── help-overview # Provides help text -│ └── latest-stable # Returns latest stable version -├── lib/ # Shared library code -│ ├── utils.sh # Core utilities and helpers -│ └── cache.sh # API response caching -├── test/ # Test suite -│ ├── *.bats # BATS test files -│ └── test_helpers.bash # Test helper functions -├── scripts/ # Development and maintenance scripts -│ ├── setup-dev.sh # Development environment setup -│ ├── test.sh # Test runner -│ └── benchmark.sh # Performance benchmarking -├── docs/ # Documentation -│ ├── *.md # Various documentation files -├── examples/ # Usage examples -│ ├── Dockerfile # Docker integration examples -│ └── docker-compose.yml # Docker Compose examples -├── completions/ # Shell completion scripts -│ ├── ghjk.bash # Bash completions -│ └── ghjk.zsh # Zsh completions -└── .github/ # GitHub-specific files - ├── workflows/ # GitHub Actions CI/CD - └── ISSUE_TEMPLATE/ # Issue templates -``` - -## Component Architecture - -### 1. Core Scripts (`bin/`) - -#### `bin/list-all` - -**Purpose**: List all available ghjk versions from GitHub releases - -**Flow**: -1. Source utilities -2. Check dependencies -3. Fetch releases from GitHub API (with caching) -4. Extract version tags -5. Sort versions semantically -6. Output space-separated list - -**Dependencies**: `lib/utils.sh`, `lib/cache.sh` (optional) - -**Output Format**: Space-separated versions on single line - -#### `bin/download` - -**Purpose**: Download ghjk binary for specified version - -**Flow**: -1. Read environment variables (`ASDF_INSTALL_VERSION`, `ASDF_DOWNLOAD_PATH`) -2. Detect platform architecture -3. Construct download URL -4. Fetch release metadata for checksum -5. Download binary with retry logic -6. Verify checksum (if available) -7. Save metadata for install script - -**Dependencies**: `lib/utils.sh` - -**Side Effects**: -- Downloads file to `ASDF_DOWNLOAD_PATH` -- Creates `.metadata` file - -#### `bin/install` - -**Purpose**: Install downloaded ghjk binary - -**Flow**: -1. Read environment variables -2. Locate downloaded archive -3. Extract to install path -4. Verify binary exists and is executable -5. Check runtime dependencies -6. Create bin/ symlink if needed - -**Dependencies**: `lib/utils.sh` - -**Side Effects**: -- Extracts files to `ASDF_INSTALL_PATH` -- Creates symlinks -- Sets executable permissions - -#### `bin/list-bin-paths` - -**Purpose**: Tell asdf where to find binaries - -**Flow**: -1. Check for `bin/` directory -2. Fall back to root directory if needed -3. Output path(s) - -**Called By**: asdf (automatically) - -#### `bin/help-overview` - -**Purpose**: Provide user-friendly help text - -**Output**: Formatted help documentation - -#### `bin/latest-stable` - -**Purpose**: Get latest non-prerelease version - -**Flow**: -1. Fetch releases -2. Filter out pre-releases (rc, alpha, beta) -3. Return first (latest) version - -### 2. Library Code (`lib/`) - -#### `lib/utils.sh` - -**Core utility functions**: - -| Function | Purpose | -|----------|---------| -| `get_platform()` | Detect OS and architecture | -| `log()`, `success()`, `warn()`, `error()` | Logging with colors | -| `command_exists()` | Check if command is available | -| `check_dependencies()` | Verify required tools | -| `github_api_fetch()` | Fetch from GitHub API with caching | -| `sort_versions()` | Sort versions semantically | -| `get_asset_name()` | Generate asset filename | -| `get_download_url()` | Generate download URL | -| `download_file()` | Download with retry logic | -| `verify_checksum()` | SHA256 verification | -| `extract_archive()` | Extract tar.gz files | -| `cleanup()` | Clean up temporary files | - -**Design**: Single-responsibility functions, pure where possible - -#### `lib/cache.sh` - -**Caching implementation**: - -| Function | Purpose | -|----------|---------| -| `init_cache()` | Initialize cache directory | -| `get_cache_path()` | Generate cache file path | -| `is_cache_valid()` | Check cache freshness | -| `get_cached()` | Retrieve cached response | -| `save_to_cache()` | Store response in cache | -| `clear_cache()` | Remove all cache | -| `clean_cache()` | Remove expired cache | -| `cache_stats()` | Display cache statistics | - -**Design**: -- TTL-based expiration (default 1 hour) -- SHA256-based cache keys -- Graceful degradation if caching fails - -### 3. Test Suite (`test/`) - -**Framework**: BATS (Bash Automated Testing System) - -**Test Files**: -- `utils.bats`: Unit tests for utility functions -- `list-all.bats`: Tests for version listing -- `download.bats`: Tests for download functionality -- `install.bats`: Tests for installation - -**Test Helpers**: Common setup/teardown, mock data, fixtures - -## Data Flow - -### Version Installation Flow - -``` -User runs: asdf install ghjk 0.3.2 - ↓ -asdf calls: bin/download - ↓ -bin/download: - 1. Detects platform (x86_64-unknown-linux-gnu) - 2. Constructs URL (github.com/.../ghjk-v0.3.2-x86_64-unknown-linux-gnu.tar.gz) - 3. Fetches release metadata - 4. Downloads file (with retry) - 5. Verifies checksum - 6. Saves metadata - ↓ -asdf calls: bin/install - ↓ -bin/install: - 1. Reads metadata - 2. Extracts archive - 3. Verifies binary - 4. Creates symlinks - 5. Checks dependencies - ↓ -asdf creates shims - ↓ -User runs: ghjk --version -``` - -### Version Listing Flow - -``` -User runs: asdf list all ghjk - ↓ -asdf calls: bin/list-all - ↓ -bin/list-all: - 1. Checks cache - 2. If cached: return cached data - 3. If not cached: - a. Fetches from GitHub API - b. Paginates through all releases - c. Extracts version tags - d. Saves to cache - 4. Sorts versions - 5. Outputs space-separated list - ↓ -asdf displays to user -``` - -## Design Decisions - -### Why Bash? - -**Chosen**: Bash 4.0+ - -**Rationale**: -- Required by asdf specification -- Maximum portability (available on all target platforms) -- No compilation needed -- Well-understood by shell users -- Rich ecosystem of tools - -**Tradeoffs**: -- Less type safety than compiled languages -- Harder to refactor than modern languages -- Requires careful error handling - -### Why Caching? - -**Chosen**: File-based TTL cache - -**Rationale**: -- Reduces GitHub API calls (rate limit friendly) -- Improves performance for repeated operations -- Simple implementation without external dependencies -- Transparent to users - -**Implementation**: -- Cache location: `~/.asdf/cache/ghjk/` -- TTL: 1 hour (configurable via `GHJK_CACHE_TTL`) -- Key: SHA256 hash of URL -- Format: Raw JSON responses - -**Tradeoffs**: -- Slightly stale data possible -- Disk space usage (minimal, ~KB per cached response) -- Manual cache invalidation needed for forced updates - -### Platform Detection - -**Method**: `uname` system calls - -**Mapping**: -```bash -Linux + x86_64 → x86_64-unknown-linux-gnu -Linux + aarch64 → aarch64-unknown-linux-gnu -Darwin + x86_64 → x86_64-apple-darwin -Darwin + arm64 → aarch64-apple-darwin -``` - -**Rationale**: Matches ghjk's release naming convention - -### Checksum Verification - -**Method**: SHA256 from GitHub release metadata - -**Flow**: -1. Fetch release metadata from GitHub API -2. Extract SHA256 from asset metadata -3. Calculate SHA256 of downloaded file -4. Compare hashes -5. Fail installation if mismatch - -**Rationale**: -- Prevents corrupted downloads -- Detects tampering -- Industry-standard algorithm - -**Tradeoffs**: -- Extra API call -- Slight performance overhead -- Warnings if checksum unavailable (rare) - -### Error Handling Strategy - -**Principles**: -1. **Fail Fast**: Exit immediately on critical errors -2. **Clear Messages**: Human-readable error descriptions -3. **Actionable**: Suggest solutions when possible -4. **Logged**: All errors go to stderr -5. **Codes**: Proper exit codes (0 = success, non-zero = failure) - -**Example**: -```bash -if ! curl -fsSL "$url" -o "$output"; then - error "Failed to download ghjk ${version}" - error "Check your internet connection and try again" - error "URL: $url" - exit 1 -fi -``` - -### Dependency Philosophy - -**Approach**: Minimal, standard dependencies only - -**Required**: -- bash (4.0+) -- curl -- tar -- grep -- sort - -**Rationale**: Available on all target platforms by default - -**Not Required**: -- jq (use grep/sed for JSON parsing) -- wget (use curl) -- python (keep everything in bash) - -## Extension Points - -### Adding New Scripts - -To add a new bin script: - -1. Create file in `bin/` -2. Add shebang: `#!/usr/bin/env bash` -3. Set strict mode: `set -euo pipefail` -4. Source utilities: `source "${PLUGIN_DIR}/lib/utils.sh"` -5. Implement functionality -6. Make executable: `chmod +x bin/new-script` -7. Document in README -8. Add tests in `test/` - -### Adding New Utilities - -To add a new utility function: - -1. Add to `lib/utils.sh` -2. Follow naming convention (lowercase with underscores) -3. Add documentation comment -4. Write tests in `test/utils.bats` -5. Update ARCHITECTURE.md (this file) - -### Adding Platform Support - -To add a new platform: - -1. Update `get_platform()` in `lib/utils.sh` -2. Add platform detection logic -3. Add platform to documentation -4. Update tests -5. Add CI test matrix entry - -### Customizing Cache Behavior - -Environment variables: - -- `GHJK_CACHE_TTL`: Cache time-to-live in seconds (default: 3600) -- `ASDF_DATA_DIR`: Base directory for asdf data (cache subdirectory) - -## Performance Characteristics - -### Time Complexity - -| Operation | Complexity | Notes | -|-----------|-----------|-------| -| list-all (cached) | O(1) | Direct file read | -| list-all (uncached) | O(n) | n = number of releases | -| download | O(1) | Single file download | -| install | O(1) | Single archive extraction | -| sort_versions | O(n log n) | Standard sort | - -### Space Complexity - -| Component | Space Usage | -|-----------|-------------| -| Plugin code | < 100 KB | -| Cache (per response) | ~10-50 KB | -| Downloaded archive | 10-50 MB | -| Installed binary | 10-50 MB | -| Per version total | ~20-100 MB | - -## Security Considerations - -### Attack Surface - -**Potential Vectors**: -1. Malicious GitHub responses -2. Man-in-the-middle attacks -3. Compromised downloads -4. Path traversal attacks - -**Mitigations**: -1. HTTPS-only connections -2. Checksum verification -3. Input validation -4. Proper path quoting -5. No use of `eval` or dangerous constructs - -### Code Review Points - -When reviewing changes: -- [ ] All user inputs validated -- [ ] All file paths properly quoted -- [ ] No use of `eval`, `source` on untrusted input -- [ ] HTTPS used for all downloads -- [ ] Error messages don't leak sensitive data -- [ ] ShellCheck passes -- [ ] Tests cover security-relevant cases - -## Future Enhancements - -Potential additions: - -1. **Parallel Downloads**: Download/install multiple versions concurrently -2. **Mirror Support**: Allow alternative download sources -3. **GPG Verification**: Verify GPG signatures if ghjk adds them -4. **Version Constraints**: Support version range specifications -5. **Rollback Support**: Automatically rollback failed installations -6. **Telemetry**: Optional usage statistics (opt-in) - -## References - -- [asdf Plugin Development](https://asdf-vm.com/plugins/create.html) -- [Google Shell Style Guide](https://google.github.io/styleguide/shellguide.html) -- [ShellCheck](https://www.shellcheck.net/) -- [BATS Testing](https://github.com/bats-core/bats-core) -- [ghjk Repository](https://github.com/metatypedev/ghjk) - ---- - -**Maintained By**: asdf-ghjk contributors -**Last Updated**: 2024-11-22 diff --git a/asdf-ghjk/docs/COMPATIBILITY.adoc b/asdf-ghjk/docs/COMPATIBILITY.adoc new file mode 100644 index 00000000..5ff38839 --- /dev/null +++ b/asdf-ghjk/docs/COMPATIBILITY.adoc @@ -0,0 +1,254 @@ +== Compatibility Matrix + +This document outlines the compatibility of asdf-ghjk across different +platforms, asdf versions, and ghjk versions. + +=== Platform Support + +[width="100%",cols="23%,27%,19%,17%,14%",options="header",] +|=== +|Platform |Architecture |Status |Tested |Notes +|Linux |x86_64 |✅ Supported |✅ Yes |All major distributions +|Linux |aarch64 (ARM64) |✅ Supported |✅ Yes |Including Raspberry Pi 4+ +|macOS |x86_64 (Intel) |✅ Supported |✅ Yes |macOS 10.15+ +|macOS |arm64 (Apple Silicon) |✅ Supported |✅ Yes |M1, M2, M3 chips +|Windows |x86_64 |❌ Not Supported |❌ No |May work with WSL +|Windows |WSL2 |⚠️ Experimental |⚠️ Limited |Use Linux x86_64 build +|FreeBSD |x86_64 |❌ Not Supported |❌ No |ghjk doesn’t support +|=== + +==== Linux Distributions + +Tested and working: + +* ✅ Ubuntu 20.04, 22.04, 24.04 +* ✅ Debian 11, 12 +* ✅ Fedora 38, 39, 40 +* ✅ CentOS Stream 8, 9 +* ✅ RHEL 8, 9 +* ✅ Arch Linux (latest) +* ✅ Alpine Linux 3.18+ (with bash installed) +* ✅ Amazon Linux 2, 2023 + +Should work but untested: - ⚠️ openSUSE - ⚠️ Gentoo - ⚠️ Void Linux + +==== macOS Versions + +[cols=",,,",options="header",] +|=== +|macOS Version |Intel |Apple Silicon |Status +|14 (Sonoma) |✅ |✅ |Fully supported +|13 (Ventura) |✅ |✅ |Fully supported +|12 (Monterey) |✅ |✅ |Fully supported +|11 (Big Sur) |✅ |✅ |Fully supported +|10.15 (Catalina) |✅ |N/A |Should work +|10.14 and older |⚠️ |N/A |May work, untested +|=== + +=== asdf Versions + +[cols=",,",options="header",] +|=== +|asdf Version |Status |Notes +|0.14.x |✅ Recommended |Latest stable +|0.13.x |✅ Supported |Tested +|0.12.x |✅ Supported |Tested +|0.11.x |⚠️ May work |Untested +|0.10.x |⚠️ May work |Untested +|< 0.10 |❌ Not supported |Too old +|=== + +=== ghjk Versions + +All ghjk versions published on GitHub releases are supported. + +[cols=",,",options="header",] +|=== +|Version Range |Status |Notes +|0.3.x |✅ Fully supported |Current stable series +|0.2.x |✅ Supported |Older stable +|0.1.x |✅ Supported |Early releases +|Pre-releases |✅ Supported |Alpha, beta, rc versions +|=== + +==== Known Issues by Version + +* *< 0.3.0*: Some versions may have different binary naming +* *RC versions*: May have different archive structures + +=== Shell Compatibility + +[cols=",,",options="header",] +|=== +|Shell |Status |Notes +|Bash 4.0+ |✅ Required |Primary shell +|Bash 3.x |❌ Not supported |Too old +|Zsh |✅ Supported |Via asdf +|Fish |✅ Supported |Via asdf +|Dash |⚠️ Limited |asdf may not work +|sh |❌ Not supported |Bash required +|=== + +=== Dependencies + +==== Required Dependencies + +[cols=",,,",options="header",] +|=== +|Tool |Minimum Version |Status |Notes +|bash |4.0 |Required |Script interpreter +|curl |7.0 |Required |Downloads +|tar |1.0 |Required |Archive extraction +|grep |2.5 |Required |Text processing +|sort |8.0 |Required |Version sorting +|=== + +==== ghjk Runtime Dependencies + +These are checked at install time and warned if missing: + +[cols=",,",options="header",] +|=== +|Tool |Required For |Notes +|git |ghjk operation |Version control +|curl |ghjk operation |HTTP requests +|tar |ghjk operation |Archive handling +|unzip |ghjk operation |ZIP extraction +|zstd |ghjk operation |Compression +|=== + +==== Optional Dependencies + +[cols=",,",options="header",] +|=== +|Tool |Purpose |Notes +|sha256sum |Checksum verification |Or shasum on macOS +|shellcheck |Development/linting |Not required for usage +|=== + +=== CI/CD Compatibility + +[cols=",,,",options="header",] +|=== +|Platform |Status |Tested |Notes +|GitHub Actions |✅ Supported |✅ Yes |Ubuntu, macOS runners +|GitLab CI |✅ Supported |✅ Yes |Docker images +|CircleCI |✅ Supported |✅ Yes |Linux, macOS +|Travis CI |✅ Should work |⚠️ Limited |Similar to others +|Jenkins |✅ Should work |⚠️ Limited |Via shell +|Buildkite |✅ Should work |⚠️ Limited |Via shell +|Azure Pipelines |✅ Should work |⚠️ Limited |Linux, macOS agents +|=== + +=== Container Compatibility + +[cols=",,",options="header",] +|=== +|Base Image |Status |Notes +|ubuntu:22.04 |✅ Recommended |Well tested +|ubuntu:20.04 |✅ Supported |Tested +|debian:12 |✅ Supported |Tested +|debian:11 |✅ Supported |Should work +|alpine:3.18+ |⚠️ Limited |Requires bash install +|fedora:latest |✅ Supported |Should work +|amazonlinux:2023 |✅ Supported |Should work +|=== + +=== Known Incompatibilities + +==== Operating Systems + +* ❌ Windows native (cmd, PowerShell) +* ❌ FreeBSD +* ❌ Solaris +* ❌ AIX + +==== Architectures + +* ❌ 32-bit systems (i386, i686, armv7l) +* ❌ RISC-V (ghjk doesn’t provide builds) +* ❌ PowerPC +* ❌ s390x + +==== Environments + +* ❌ BusyBox (limited shell features) +* ❌ Minimal containers without basic tools + +=== Performance Characteristics + +==== Download Speeds + +Typical download times for ghjk binary (~10-50 MB): + +* Good connection (100 Mbps): 1-5 seconds +* Average connection (10 Mbps): 10-30 seconds +* Slow connection (1 Mbps): 1-5 minutes + +==== Installation Time + +* Download: 1-30 seconds (depending on connection) +* Extraction: 1-2 seconds +* Verification: < 1 second +* *Total*: ~2-35 seconds + +==== Disk Space + +Per version installed: - Downloaded archive: 10-50 MB - Extracted +binary: 10-50 MB - *Total per version*: ~20-100 MB + +With 5 versions installed: ~100-500 MB + +=== Compatibility Testing + +==== How We Test + +* ✅ Unit tests on multiple platforms (GitHub Actions) +* ✅ Integration tests with real installations +* ✅ Manual testing on developer machines +* ⚠️ Community reports for less common platforms + +==== Report Compatibility Issues + +If you encounter compatibility issues: + +[arabic] +. Check this document +. Check https://github.com/Hyperpolymath/asdf-ghjk/issues[existing +issues] +. Report new issues with: +* OS and version +* Architecture +* asdf version +* Error messages +* Steps to reproduce + +=== Version Support Policy + +* *Current stable ghjk versions*: Fully supported +* *Old ghjk versions*: Best effort support +* *Pre-release ghjk versions*: Supported but may have issues +* *asdf versions*: Support latest 3 minor versions + +=== Future Compatibility + +==== Planned Support + +* 🔄 Continued support for new ghjk releases +* 🔄 Continued support for new asdf releases +* 🔄 Platform support as ghjk adds them + +==== No Plans For + +* ❌ Windows native support (unless ghjk adds it) +* ❌ 32-bit architecture support +* ❌ Non-Unix operating systems + +''''' + +*Last Updated*: 2024-11-22 + +For the latest compatibility information, check: - +https://github.com/metatypedev/ghjk/releases[ghjk releases] - +https://asdf-vm.com[asdf compatibility] - +https://github.com/Hyperpolymath/asdf-ghjk/issues[Plugin issues] diff --git a/asdf-ghjk/docs/COMPATIBILITY.md b/asdf-ghjk/docs/COMPATIBILITY.md deleted file mode 100644 index 11f95a4b..00000000 --- a/asdf-ghjk/docs/COMPATIBILITY.md +++ /dev/null @@ -1,236 +0,0 @@ -# Compatibility Matrix - -This document outlines the compatibility of asdf-ghjk across different platforms, asdf versions, and ghjk versions. - -## Platform Support - -| Platform | Architecture | Status | Tested | Notes | -|----------|-------------|---------|--------|-------| -| Linux | x86_64 | ✅ Supported | ✅ Yes | All major distributions | -| Linux | aarch64 (ARM64) | ✅ Supported | ✅ Yes | Including Raspberry Pi 4+ | -| macOS | x86_64 (Intel) | ✅ Supported | ✅ Yes | macOS 10.15+ | -| macOS | arm64 (Apple Silicon) | ✅ Supported | ✅ Yes | M1, M2, M3 chips | -| Windows | x86_64 | ❌ Not Supported | ❌ No | May work with WSL | -| Windows | WSL2 | ⚠️ Experimental | ⚠️ Limited | Use Linux x86_64 build | -| FreeBSD | x86_64 | ❌ Not Supported | ❌ No | ghjk doesn't support | - -### Linux Distributions - -Tested and working: - -- ✅ Ubuntu 20.04, 22.04, 24.04 -- ✅ Debian 11, 12 -- ✅ Fedora 38, 39, 40 -- ✅ CentOS Stream 8, 9 -- ✅ RHEL 8, 9 -- ✅ Arch Linux (latest) -- ✅ Alpine Linux 3.18+ (with bash installed) -- ✅ Amazon Linux 2, 2023 - -Should work but untested: -- ⚠️ openSUSE -- ⚠️ Gentoo -- ⚠️ Void Linux - -### macOS Versions - -| macOS Version | Intel | Apple Silicon | Status | -|---------------|-------|---------------|---------| -| 14 (Sonoma) | ✅ | ✅ | Fully supported | -| 13 (Ventura) | ✅ | ✅ | Fully supported | -| 12 (Monterey) | ✅ | ✅ | Fully supported | -| 11 (Big Sur) | ✅ | ✅ | Fully supported | -| 10.15 (Catalina) | ✅ | N/A | Should work | -| 10.14 and older | ⚠️ | N/A | May work, untested | - -## asdf Versions - -| asdf Version | Status | Notes | -|--------------|---------|-------| -| 0.14.x | ✅ Recommended | Latest stable | -| 0.13.x | ✅ Supported | Tested | -| 0.12.x | ✅ Supported | Tested | -| 0.11.x | ⚠️ May work | Untested | -| 0.10.x | ⚠️ May work | Untested | -| < 0.10 | ❌ Not supported | Too old | - -## ghjk Versions - -All ghjk versions published on GitHub releases are supported. - -| Version Range | Status | Notes | -|---------------|---------|-------| -| 0.3.x | ✅ Fully supported | Current stable series | -| 0.2.x | ✅ Supported | Older stable | -| 0.1.x | ✅ Supported | Early releases | -| Pre-releases | ✅ Supported | Alpha, beta, rc versions | - -### Known Issues by Version - -- **< 0.3.0**: Some versions may have different binary naming -- **RC versions**: May have different archive structures - -## Shell Compatibility - -| Shell | Status | Notes | -|-------|---------|-------| -| Bash 4.0+ | ✅ Required | Primary shell | -| Bash 3.x | ❌ Not supported | Too old | -| Zsh | ✅ Supported | Via asdf | -| Fish | ✅ Supported | Via asdf | -| Dash | ⚠️ Limited | asdf may not work | -| sh | ❌ Not supported | Bash required | - -## Dependencies - -### Required Dependencies - -| Tool | Minimum Version | Status | Notes | -|------|----------------|---------|-------| -| bash | 4.0 | Required | Script interpreter | -| curl | 7.0 | Required | Downloads | -| tar | 1.0 | Required | Archive extraction | -| grep | 2.5 | Required | Text processing | -| sort | 8.0 | Required | Version sorting | - -### ghjk Runtime Dependencies - -These are checked at install time and warned if missing: - -| Tool | Required For | Notes | -|------|-------------|-------| -| git | ghjk operation | Version control | -| curl | ghjk operation | HTTP requests | -| tar | ghjk operation | Archive handling | -| unzip | ghjk operation | ZIP extraction | -| zstd | ghjk operation | Compression | - -### Optional Dependencies - -| Tool | Purpose | Notes | -|------|---------|-------| -| sha256sum | Checksum verification | Or shasum on macOS | -| shellcheck | Development/linting | Not required for usage | - -## CI/CD Compatibility - -| Platform | Status | Tested | Notes | -|----------|---------|--------|-------| -| GitHub Actions | ✅ Supported | ✅ Yes | Ubuntu, macOS runners | -| GitLab CI | ✅ Supported | ✅ Yes | Docker images | -| CircleCI | ✅ Supported | ✅ Yes | Linux, macOS | -| Travis CI | ✅ Should work | ⚠️ Limited | Similar to others | -| Jenkins | ✅ Should work | ⚠️ Limited | Via shell | -| Buildkite | ✅ Should work | ⚠️ Limited | Via shell | -| Azure Pipelines | ✅ Should work | ⚠️ Limited | Linux, macOS agents | - -## Container Compatibility - -| Base Image | Status | Notes | -|------------|---------|-------| -| ubuntu:22.04 | ✅ Recommended | Well tested | -| ubuntu:20.04 | ✅ Supported | Tested | -| debian:12 | ✅ Supported | Tested | -| debian:11 | ✅ Supported | Should work | -| alpine:3.18+ | ⚠️ Limited | Requires bash install | -| fedora:latest | ✅ Supported | Should work | -| amazonlinux:2023 | ✅ Supported | Should work | - -## Known Incompatibilities - -### Operating Systems - -- ❌ Windows native (cmd, PowerShell) -- ❌ FreeBSD -- ❌ Solaris -- ❌ AIX - -### Architectures - -- ❌ 32-bit systems (i386, i686, armv7l) -- ❌ RISC-V (ghjk doesn't provide builds) -- ❌ PowerPC -- ❌ s390x - -### Environments - -- ❌ BusyBox (limited shell features) -- ❌ Minimal containers without basic tools - -## Performance Characteristics - -### Download Speeds - -Typical download times for ghjk binary (~10-50 MB): - -- Good connection (100 Mbps): 1-5 seconds -- Average connection (10 Mbps): 10-30 seconds -- Slow connection (1 Mbps): 1-5 minutes - -### Installation Time - -- Download: 1-30 seconds (depending on connection) -- Extraction: 1-2 seconds -- Verification: < 1 second -- **Total**: ~2-35 seconds - -### Disk Space - -Per version installed: -- Downloaded archive: 10-50 MB -- Extracted binary: 10-50 MB -- **Total per version**: ~20-100 MB - -With 5 versions installed: ~100-500 MB - -## Compatibility Testing - -### How We Test - -- ✅ Unit tests on multiple platforms (GitHub Actions) -- ✅ Integration tests with real installations -- ✅ Manual testing on developer machines -- ⚠️ Community reports for less common platforms - -### Report Compatibility Issues - -If you encounter compatibility issues: - -1. Check this document -2. Check [existing issues](https://github.com/Hyperpolymath/asdf-ghjk/issues) -3. Report new issues with: - - OS and version - - Architecture - - asdf version - - Error messages - - Steps to reproduce - -## Version Support Policy - -- **Current stable ghjk versions**: Fully supported -- **Old ghjk versions**: Best effort support -- **Pre-release ghjk versions**: Supported but may have issues -- **asdf versions**: Support latest 3 minor versions - -## Future Compatibility - -### Planned Support - -- 🔄 Continued support for new ghjk releases -- 🔄 Continued support for new asdf releases -- 🔄 Platform support as ghjk adds them - -### No Plans For - -- ❌ Windows native support (unless ghjk adds it) -- ❌ 32-bit architecture support -- ❌ Non-Unix operating systems - ---- - -**Last Updated**: 2024-11-22 - -For the latest compatibility information, check: -- [ghjk releases](https://github.com/metatypedev/ghjk/releases) -- [asdf compatibility](https://asdf-vm.com) -- [Plugin issues](https://github.com/Hyperpolymath/asdf-ghjk/issues) diff --git a/asdf-ghjk/docs/EXAMPLES.adoc b/asdf-ghjk/docs/EXAMPLES.adoc new file mode 100644 index 00000000..ee57bec9 --- /dev/null +++ b/asdf-ghjk/docs/EXAMPLES.adoc @@ -0,0 +1,640 @@ +== Usage Examples + +This document provides real-world examples of using asdf-ghjk. + +=== Table of Contents + +* link:#basic-usage[Basic Usage] +* link:#project-setup[Project Setup] +* link:#cicd-integration[CI/CD Integration] +* link:#multiple-projects[Multiple Projects] +* link:#advanced-workflows[Advanced Workflows] + +=== Basic Usage + +==== Install and Use Latest Version + +[source,bash] +---- +# Install the plugin +asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git + +# Install latest ghjk +asdf install ghjk latest + +# Set as global default +asdf global ghjk latest + +# Verify installation +ghjk --version +---- + +==== Install Specific Version + +[source,bash] +---- +# List all available versions +asdf list all ghjk + +# Install a specific version +asdf install ghjk 0.3.2 + +# Use it globally +asdf global ghjk 0.3.2 +---- + +=== Project Setup + +==== Initialize a New Project + +[source,bash] +---- +# Create project directory +mkdir my-project +cd my-project + +# Set local ghjk version +asdf local ghjk 0.3.2 + +# Initialize ghjk with TypeScript support +ghjk init ts + +# View generated configuration +cat ghjk.ts +---- + +==== Basic Project Configuration + +Create a `+ghjk.ts+` file: + +[source,typescript] +---- +// ghjk.ts +export { sophon } from "https://deno.land/x/ghjk/mod.ts"; + +sophon({ + // Define environment variables + env: { + NODE_ENV: "development", + API_URL: "http://localhost:3000", + }, + + // Install development tools + installs: [ + { name: "node", version: "20.0.0" }, + { name: "python", version: "3.11" }, + ], + + // Define tasks + tasks: { + dev: "npm run dev", + test: "npm test", + build: "npm run build", + lint: "npm run lint", + }, +}); +---- + +==== Activate Environment + +[source,bash] +---- +# Load the ghjk environment +ghjk env + +# Or run tasks directly +ghjk run dev +ghjk run test +---- + +=== CI/CD Integration + +==== GitHub Actions + +`+.github/workflows/ci.yml+`: + +[source,yaml] +---- +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Install asdf + uses: asdf-vm/actions/setup@v3 + + - name: Add ghjk plugin + run: | + asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git + + - name: Install ghjk from .tool-versions + run: | + asdf install ghjk + + - name: Run tests with ghjk + run: | + ghjk run test + + - name: Build with ghjk + run: | + ghjk run build +---- + +==== GitLab CI + +`+.gitlab-ci.yml+`: + +[source,yaml] +---- +image: ubuntu:latest + +variables: + ASDF_DIR: "${CI_PROJECT_DIR}/.asdf" + ASDF_DATA_DIR: "${CI_PROJECT_DIR}/.asdf" + +before_script: + - apt-get update && apt-get install -y git curl tar unzip zstd + - git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.0 + - echo '. $HOME/.asdf/asdf.sh' >> ~/.bashrc + - source ~/.bashrc + - asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git + - asdf install + +test: + script: + - ghjk run test + +build: + script: + - ghjk run build + artifacts: + paths: + - dist/ +---- + +==== CircleCI + +`+.circleci/config.yml+`: + +[source,yaml] +---- +version: 2.1 + +jobs: + test: + docker: + - image: cimg/base:stable + steps: + - checkout + + - run: + name: Install asdf + command: | + git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.0 + echo '. $HOME/.asdf/asdf.sh' >> $BASH_ENV + + - run: + name: Install ghjk + command: | + asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git + asdf install ghjk + + - run: + name: Run tests + command: ghjk run test + +workflows: + version: 2 + test: + jobs: + - test +---- + +=== Multiple Projects + +==== Different Versions per Project + +[source,bash] +---- +# Project A uses ghjk 0.3.2 +cd ~/projects/project-a +asdf local ghjk 0.3.2 +cat .tool-versions +# ghjk 0.3.2 + +# Project B uses latest ghjk +cd ~/projects/project-b +asdf local ghjk latest +cat .tool-versions +# ghjk 0.3.2 + +# asdf automatically switches versions when you cd +---- + +==== Shared Configuration + +`+~/.tool-versions+` (global defaults): + +.... +ghjk 0.3.2 +nodejs 20.0.0 +python 3.11.0 +.... + +Project-specific overrides: + +[source,bash] +---- +cd my-project +asdf local ghjk 0.3.1 # Override just ghjk +# Other tools (nodejs, python) inherited from global +---- + +=== Advanced Workflows + +==== Multi-Environment Setup + +[source,typescript] +---- +// ghjk.ts +export { sophon } from "https://deno.land/x/ghjk/mod.ts"; + +const baseConfig = { + installs: [ + { name: "node", version: "20.0.0" }, + ], +}; + +const developmentConfig = { + ...baseConfig, + env: { + NODE_ENV: "development", + DEBUG: "true", + }, + tasks: { + dev: "npm run dev", + test: "npm test", + }, +}; + +const productionConfig = { + ...baseConfig, + env: { + NODE_ENV: "production", + }, + tasks: { + start: "npm start", + }, +}; + +// Use based on environment variable +const config = Deno.env.get("ENV") === "production" + ? productionConfig + : developmentConfig; + +sophon(config); +---- + +Usage: + +[source,bash] +---- +# Development +ghjk run dev + +# Production +ENV=production ghjk run start +---- + +==== Monorepo Setup + +[source,typescript] +---- +// ghjk.ts (root) +export { sophon } from "https://deno.land/x/ghjk/mod.ts"; + +sophon({ + installs: [ + { name: "node", version: "20.0.0" }, + { name: "python", version: "3.11" }, + ], + + tasks: { + // Root tasks + "test:all": "npm run test --workspaces", + "build:all": "npm run build --workspaces", + "lint:all": "npm run lint --workspaces", + + // Frontend tasks + "dev:frontend": "npm run dev --workspace=packages/frontend", + "build:frontend": "npm run build --workspace=packages/frontend", + + // Backend tasks + "dev:backend": "npm run dev --workspace=packages/backend", + "build:backend": "npm run build --workspace=packages/backend", + + // Run both + dev: "concurrently 'ghjk run dev:frontend' 'ghjk run dev:backend'", + }, +}); +---- + +==== Docker Integration + +`+Dockerfile+`: + +[source,dockerfile] +---- +FROM ubuntu:22.04 + +# Install system dependencies +RUN apt-get update && apt-get install -y \ + git curl tar unzip zstd \ + && rm -rf /var/lib/apt/lists/* + +# Install asdf +RUN git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.0 +ENV PATH="/root/.asdf/bin:/root/.asdf/shims:${PATH}" + +# Install ghjk plugin +RUN asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git + +# Copy project files +WORKDIR /app +COPY .tool-versions ./ +COPY ghjk.ts ./ + +# Install ghjk from .tool-versions +RUN asdf install + +# Install project dependencies +COPY package*.json ./ +RUN ghjk run install + +# Copy application code +COPY . . + +# Build application +RUN ghjk run build + +# Run application +CMD ["ghjk", "run", "start"] +---- + +==== Testing Multiple Versions + +Test your project against multiple ghjk versions: + +[source,bash] +---- +#!/bin/bash +# test-versions.sh + +set -e + +versions=("0.3.0" "0.3.1" "0.3.2") + +for version in "${versions[@]}"; do + echo "Testing with ghjk $version" + + # Install version + asdf install ghjk "$version" + asdf local ghjk "$version" + + # Run tests + if ghjk run test; then + echo "✅ Tests passed with $version" + else + echo "❌ Tests failed with $version" + exit 1 + fi +done + +echo "All versions tested successfully!" +---- + +==== Automatic Version Installation + +Add to your project’s setup script: + +[source,bash] +---- +#!/bin/bash +# setup.sh + +set -e + +echo "Setting up project..." + +# Check if asdf is installed +if ! command -v asdf &> /dev/null; then + echo "Error: asdf is not installed" + echo "Install from: https://asdf-vm.com" + exit 1 +fi + +# Install ghjk plugin if not present +if ! asdf plugin list | grep -q ghjk; then + echo "Adding ghjk plugin..." + asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git +fi + +# Install tools from .tool-versions +echo "Installing tools..." +asdf install + +# Verify ghjk is working +echo "Verifying ghjk installation..." +ghjk --version + +# Install project dependencies +echo "Installing dependencies..." +ghjk run install + +echo "Setup complete! Run 'ghjk run dev' to start development" +---- + +==== Shell Integration + +Add to your shell profile for convenience: + +[source,bash] +---- +# ~/.bashrc or ~/.zshrc + +# ghjk aliases +alias gd='ghjk run dev' +alias gt='ghjk run test' +alias gb='ghjk run build' +alias gl='ghjk run lint' + +# Quick ghjk version switching +ghjk-use() { + asdf local ghjk "$1" + echo "Switched to ghjk $1" + ghjk --version +} + +# List installed ghjk versions +alias ghjk-versions='asdf list ghjk' + +# Update to latest ghjk +ghjk-update() { + local latest + latest=$(asdf list all ghjk | tr ' ' '\n' | tail -1) + echo "Installing ghjk $latest..." + asdf install ghjk "$latest" + asdf global ghjk "$latest" + echo "Updated to ghjk $latest" +} +---- + +=== Tips and Tricks + +==== Cache GitHub API Responses + +Reduce API calls by caching: + +[source,bash] +---- +# Set a long-lived GitHub token +export GITHUB_API_TOKEN="ghp_your_token_here" + +# Or use conditional requests (plugin handles this) +---- + +==== Parallel Installation + +Install multiple versions in parallel: + +[source,bash] +---- +# In separate terminals or with GNU parallel +asdf install ghjk 0.3.0 & +asdf install ghjk 0.3.1 & +asdf install ghjk 0.3.2 & +wait +---- + +==== Backup and Restore + +Export your tool versions: + +[source,bash] +---- +# Backup +cp .tool-versions .tool-versions.backup + +# Restore +cp .tool-versions.backup .tool-versions +asdf install # Install all tools +---- + +==== Automate Updates + +Create a cron job to check for updates: + +[source,bash] +---- +# check-ghjk-updates.sh +#!/bin/bash + +latest=$(asdf list all ghjk | tr ' ' '\n' | tail -1) +current=$(asdf current ghjk | awk '{print $2}') + +if [ "$latest" != "$current" ]; then + echo "New ghjk version available: $latest (current: $current)" + # Optionally auto-install or send notification +fi +---- + +=== Real-World Examples + +==== Full-Stack Web Application + +[source,typescript] +---- +// ghjk.ts +export { sophon } from "https://deno.land/x/ghjk/mod.ts"; + +sophon({ + env: { + DATABASE_URL: "postgresql://localhost/myapp_dev", + REDIS_URL: "redis://localhost:6379", + NODE_ENV: "development", + }, + + installs: [ + { name: "node", version: "20.0.0" }, + { name: "python", version: "3.11" }, + { name: "postgres", version: "15" }, + { name: "redis", version: "7" }, + ], + + tasks: { + // Database + "db:setup": "npm run db:migrate && npm run db:seed", + "db:reset": "npm run db:drop && npm run db:setup", + + // Development + dev: "concurrently 'npm run dev:frontend' 'npm run dev:backend'", + "dev:frontend": "cd frontend && npm run dev", + "dev:backend": "cd backend && npm run dev", + + // Testing + test: "npm run test:unit && npm run test:integration", + "test:unit": "npm run test --workspaces", + "test:e2e": "playwright test", + + // Production + build: "npm run build --workspaces", + start: "node backend/dist/server.js", + }, +}); +---- + +==== Data Science Project + +[source,typescript] +---- +// ghjk.ts +export { sophon } from "https://deno.land/x/ghjk/mod.ts"; + +sophon({ + env: { + JUPYTER_PORT: "8888", + PYTHONPATH: "${PWD}/src", + }, + + installs: [ + { name: "python", version: "3.11" }, + { name: "jupyter", version: "latest" }, + ], + + tasks: { + notebook: "jupyter lab --port=$JUPYTER_PORT", + train: "python src/train.py", + evaluate: "python src/evaluate.py", + "export:model": "python src/export.py", + }, +}); +---- + +=== Conclusion + +These examples demonstrate the flexibility and power of using ghjk with +asdf. Adapt these patterns to your specific needs and workflow. + +For more information: - https://github.com/metatypedev/ghjk[ghjk +documentation] - https://asdf-vm.com[asdf documentation] - +https://github.com/Hyperpolymath/asdf-ghjk[Plugin README] diff --git a/asdf-ghjk/docs/EXAMPLES.md b/asdf-ghjk/docs/EXAMPLES.md deleted file mode 100644 index e3cd81bd..00000000 --- a/asdf-ghjk/docs/EXAMPLES.md +++ /dev/null @@ -1,617 +0,0 @@ -# Usage Examples - -This document provides real-world examples of using asdf-ghjk. - -## Table of Contents - -- [Basic Usage](#basic-usage) -- [Project Setup](#project-setup) -- [CI/CD Integration](#cicd-integration) -- [Multiple Projects](#multiple-projects) -- [Advanced Workflows](#advanced-workflows) - -## Basic Usage - -### Install and Use Latest Version - -```bash -# Install the plugin -asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git - -# Install latest ghjk -asdf install ghjk latest - -# Set as global default -asdf global ghjk latest - -# Verify installation -ghjk --version -``` - -### Install Specific Version - -```bash -# List all available versions -asdf list all ghjk - -# Install a specific version -asdf install ghjk 0.3.2 - -# Use it globally -asdf global ghjk 0.3.2 -``` - -## Project Setup - -### Initialize a New Project - -```bash -# Create project directory -mkdir my-project -cd my-project - -# Set local ghjk version -asdf local ghjk 0.3.2 - -# Initialize ghjk with TypeScript support -ghjk init ts - -# View generated configuration -cat ghjk.ts -``` - -### Basic Project Configuration - -Create a `ghjk.ts` file: - -```typescript -// ghjk.ts -export { sophon } from "https://deno.land/x/ghjk/mod.ts"; - -sophon({ - // Define environment variables - env: { - NODE_ENV: "development", - API_URL: "http://localhost:3000", - }, - - // Install development tools - installs: [ - { name: "node", version: "20.0.0" }, - { name: "python", version: "3.11" }, - ], - - // Define tasks - tasks: { - dev: "npm run dev", - test: "npm test", - build: "npm run build", - lint: "npm run lint", - }, -}); -``` - -### Activate Environment - -```bash -# Load the ghjk environment -ghjk env - -# Or run tasks directly -ghjk run dev -ghjk run test -``` - -## CI/CD Integration - -### GitHub Actions - -`.github/workflows/ci.yml`: - -```yaml -name: CI - -on: - push: - branches: [main] - pull_request: - branches: [main] - -jobs: - test: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Install asdf - uses: asdf-vm/actions/setup@v3 - - - name: Add ghjk plugin - run: | - asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git - - - name: Install ghjk from .tool-versions - run: | - asdf install ghjk - - - name: Run tests with ghjk - run: | - ghjk run test - - - name: Build with ghjk - run: | - ghjk run build -``` - -### GitLab CI - -`.gitlab-ci.yml`: - -```yaml -image: ubuntu:latest - -variables: - ASDF_DIR: "${CI_PROJECT_DIR}/.asdf" - ASDF_DATA_DIR: "${CI_PROJECT_DIR}/.asdf" - -before_script: - - apt-get update && apt-get install -y git curl tar unzip zstd - - git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.0 - - echo '. $HOME/.asdf/asdf.sh' >> ~/.bashrc - - source ~/.bashrc - - asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git - - asdf install - -test: - script: - - ghjk run test - -build: - script: - - ghjk run build - artifacts: - paths: - - dist/ -``` - -### CircleCI - -`.circleci/config.yml`: - -```yaml -version: 2.1 - -jobs: - test: - docker: - - image: cimg/base:stable - steps: - - checkout - - - run: - name: Install asdf - command: | - git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.0 - echo '. $HOME/.asdf/asdf.sh' >> $BASH_ENV - - - run: - name: Install ghjk - command: | - asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git - asdf install ghjk - - - run: - name: Run tests - command: ghjk run test - -workflows: - version: 2 - test: - jobs: - - test -``` - -## Multiple Projects - -### Different Versions per Project - -```bash -# Project A uses ghjk 0.3.2 -cd ~/projects/project-a -asdf local ghjk 0.3.2 -cat .tool-versions -# ghjk 0.3.2 - -# Project B uses latest ghjk -cd ~/projects/project-b -asdf local ghjk latest -cat .tool-versions -# ghjk 0.3.2 - -# asdf automatically switches versions when you cd -``` - -### Shared Configuration - -`~/.tool-versions` (global defaults): - -``` -ghjk 0.3.2 -nodejs 20.0.0 -python 3.11.0 -``` - -Project-specific overrides: - -```bash -cd my-project -asdf local ghjk 0.3.1 # Override just ghjk -# Other tools (nodejs, python) inherited from global -``` - -## Advanced Workflows - -### Multi-Environment Setup - -```typescript -// ghjk.ts -export { sophon } from "https://deno.land/x/ghjk/mod.ts"; - -const baseConfig = { - installs: [ - { name: "node", version: "20.0.0" }, - ], -}; - -const developmentConfig = { - ...baseConfig, - env: { - NODE_ENV: "development", - DEBUG: "true", - }, - tasks: { - dev: "npm run dev", - test: "npm test", - }, -}; - -const productionConfig = { - ...baseConfig, - env: { - NODE_ENV: "production", - }, - tasks: { - start: "npm start", - }, -}; - -// Use based on environment variable -const config = Deno.env.get("ENV") === "production" - ? productionConfig - : developmentConfig; - -sophon(config); -``` - -Usage: - -```bash -# Development -ghjk run dev - -# Production -ENV=production ghjk run start -``` - -### Monorepo Setup - -```typescript -// ghjk.ts (root) -export { sophon } from "https://deno.land/x/ghjk/mod.ts"; - -sophon({ - installs: [ - { name: "node", version: "20.0.0" }, - { name: "python", version: "3.11" }, - ], - - tasks: { - // Root tasks - "test:all": "npm run test --workspaces", - "build:all": "npm run build --workspaces", - "lint:all": "npm run lint --workspaces", - - // Frontend tasks - "dev:frontend": "npm run dev --workspace=packages/frontend", - "build:frontend": "npm run build --workspace=packages/frontend", - - // Backend tasks - "dev:backend": "npm run dev --workspace=packages/backend", - "build:backend": "npm run build --workspace=packages/backend", - - // Run both - dev: "concurrently 'ghjk run dev:frontend' 'ghjk run dev:backend'", - }, -}); -``` - -### Docker Integration - -`Dockerfile`: - -```dockerfile -FROM ubuntu:22.04 - -# Install system dependencies -RUN apt-get update && apt-get install -y \ - git curl tar unzip zstd \ - && rm -rf /var/lib/apt/lists/* - -# Install asdf -RUN git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.0 -ENV PATH="/root/.asdf/bin:/root/.asdf/shims:${PATH}" - -# Install ghjk plugin -RUN asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git - -# Copy project files -WORKDIR /app -COPY .tool-versions ./ -COPY ghjk.ts ./ - -# Install ghjk from .tool-versions -RUN asdf install - -# Install project dependencies -COPY package*.json ./ -RUN ghjk run install - -# Copy application code -COPY . . - -# Build application -RUN ghjk run build - -# Run application -CMD ["ghjk", "run", "start"] -``` - -### Testing Multiple Versions - -Test your project against multiple ghjk versions: - -```bash -#!/bin/bash -# test-versions.sh - -set -e - -versions=("0.3.0" "0.3.1" "0.3.2") - -for version in "${versions[@]}"; do - echo "Testing with ghjk $version" - - # Install version - asdf install ghjk "$version" - asdf local ghjk "$version" - - # Run tests - if ghjk run test; then - echo "✅ Tests passed with $version" - else - echo "❌ Tests failed with $version" - exit 1 - fi -done - -echo "All versions tested successfully!" -``` - -### Automatic Version Installation - -Add to your project's setup script: - -```bash -#!/bin/bash -# setup.sh - -set -e - -echo "Setting up project..." - -# Check if asdf is installed -if ! command -v asdf &> /dev/null; then - echo "Error: asdf is not installed" - echo "Install from: https://asdf-vm.com" - exit 1 -fi - -# Install ghjk plugin if not present -if ! asdf plugin list | grep -q ghjk; then - echo "Adding ghjk plugin..." - asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git -fi - -# Install tools from .tool-versions -echo "Installing tools..." -asdf install - -# Verify ghjk is working -echo "Verifying ghjk installation..." -ghjk --version - -# Install project dependencies -echo "Installing dependencies..." -ghjk run install - -echo "Setup complete! Run 'ghjk run dev' to start development" -``` - -### Shell Integration - -Add to your shell profile for convenience: - -```bash -# ~/.bashrc or ~/.zshrc - -# ghjk aliases -alias gd='ghjk run dev' -alias gt='ghjk run test' -alias gb='ghjk run build' -alias gl='ghjk run lint' - -# Quick ghjk version switching -ghjk-use() { - asdf local ghjk "$1" - echo "Switched to ghjk $1" - ghjk --version -} - -# List installed ghjk versions -alias ghjk-versions='asdf list ghjk' - -# Update to latest ghjk -ghjk-update() { - local latest - latest=$(asdf list all ghjk | tr ' ' '\n' | tail -1) - echo "Installing ghjk $latest..." - asdf install ghjk "$latest" - asdf global ghjk "$latest" - echo "Updated to ghjk $latest" -} -``` - -## Tips and Tricks - -### Cache GitHub API Responses - -Reduce API calls by caching: - -```bash -# Set a long-lived GitHub token -export GITHUB_API_TOKEN="ghp_your_token_here" - -# Or use conditional requests (plugin handles this) -``` - -### Parallel Installation - -Install multiple versions in parallel: - -```bash -# In separate terminals or with GNU parallel -asdf install ghjk 0.3.0 & -asdf install ghjk 0.3.1 & -asdf install ghjk 0.3.2 & -wait -``` - -### Backup and Restore - -Export your tool versions: - -```bash -# Backup -cp .tool-versions .tool-versions.backup - -# Restore -cp .tool-versions.backup .tool-versions -asdf install # Install all tools -``` - -### Automate Updates - -Create a cron job to check for updates: - -```bash -# check-ghjk-updates.sh -#!/bin/bash - -latest=$(asdf list all ghjk | tr ' ' '\n' | tail -1) -current=$(asdf current ghjk | awk '{print $2}') - -if [ "$latest" != "$current" ]; then - echo "New ghjk version available: $latest (current: $current)" - # Optionally auto-install or send notification -fi -``` - -## Real-World Examples - -### Full-Stack Web Application - -```typescript -// ghjk.ts -export { sophon } from "https://deno.land/x/ghjk/mod.ts"; - -sophon({ - env: { - DATABASE_URL: "postgresql://localhost/myapp_dev", - REDIS_URL: "redis://localhost:6379", - NODE_ENV: "development", - }, - - installs: [ - { name: "node", version: "20.0.0" }, - { name: "python", version: "3.11" }, - { name: "postgres", version: "15" }, - { name: "redis", version: "7" }, - ], - - tasks: { - // Database - "db:setup": "npm run db:migrate && npm run db:seed", - "db:reset": "npm run db:drop && npm run db:setup", - - // Development - dev: "concurrently 'npm run dev:frontend' 'npm run dev:backend'", - "dev:frontend": "cd frontend && npm run dev", - "dev:backend": "cd backend && npm run dev", - - // Testing - test: "npm run test:unit && npm run test:integration", - "test:unit": "npm run test --workspaces", - "test:e2e": "playwright test", - - // Production - build: "npm run build --workspaces", - start: "node backend/dist/server.js", - }, -}); -``` - -### Data Science Project - -```typescript -// ghjk.ts -export { sophon } from "https://deno.land/x/ghjk/mod.ts"; - -sophon({ - env: { - JUPYTER_PORT: "8888", - PYTHONPATH: "${PWD}/src", - }, - - installs: [ - { name: "python", version: "3.11" }, - { name: "jupyter", version: "latest" }, - ], - - tasks: { - notebook: "jupyter lab --port=$JUPYTER_PORT", - train: "python src/train.py", - evaluate: "python src/evaluate.py", - "export:model": "python src/export.py", - }, -}); -``` - -## Conclusion - -These examples demonstrate the flexibility and power of using ghjk with asdf. Adapt these patterns to your specific needs and workflow. - -For more information: -- [ghjk documentation](https://github.com/metatypedev/ghjk) -- [asdf documentation](https://asdf-vm.com) -- [Plugin README](https://github.com/Hyperpolymath/asdf-ghjk) diff --git a/asdf-ghjk/docs/FAQ.adoc b/asdf-ghjk/docs/FAQ.adoc new file mode 100644 index 00000000..6fb589b7 --- /dev/null +++ b/asdf-ghjk/docs/FAQ.adoc @@ -0,0 +1,380 @@ +== Frequently Asked Questions (FAQ) + +Common questions about asdf-ghjk. + +=== General Questions + +==== What is asdf-ghjk? + +asdf-ghjk is an https://asdf-vm.com[asdf] plugin that allows you to +install and manage https://github.com/metatypedev/ghjk[ghjk] versions +using asdf’s version management system. + +==== What is ghjk? + +ghjk is a modern development environment manager that provides: - +Unified package management across multiple ecosystems (npm, PyPI, +crates.io, etc.) - TypeScript-based task automation - Reproducible POSIX +shell environments - Declarative configuration with inheritance + +Think of it as a successor to asdf with additional capabilities. + +==== Why use asdf-ghjk instead of installing ghjk directly? + +Using asdf-ghjk provides: - *Version Management*: Install and switch +between multiple ghjk versions - *Project-Specific Versions*: Different +projects can use different ghjk versions - *Consistent Tooling*: Use the +same version management approach for all your tools - *Easy Updates*: +Simple commands to update to the latest version - *No Global +Installation*: Avoids system-wide installation conflicts + +==== Is this an official plugin? + +No, this is a community-maintained plugin. For official ghjk support, +refer to the https://github.com/metatypedev/ghjk[ghjk repository]. + +=== Installation Questions + +==== How do I install the plugin? + +[source,bash] +---- +asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git +asdf install ghjk latest +asdf global ghjk latest +---- + +==== Do I need to install asdf first? + +Yes! This is an asdf plugin, so you need asdf installed first. Get it +from https://asdf-vm.com[asdf-vm.com]. + +==== What are the system requirements? + +*Required:* - Bash 4.0+ - curl - tar - grep, sort + +*For ghjk runtime:* - git - curl - tar - unzip - zstd + +==== Which platforms are supported? + +* Linux (x86_64, aarch64) +* macOS (x86_64, arm64/Apple Silicon) + +Windows is not currently supported (but may work with WSL). + +==== Can I install ghjk without root/sudo access? + +Yes! asdf and this plugin install everything in your home directory +(~/.asdf/). No root access required. + +=== Usage Questions + +==== How do I install a specific version? + +[source,bash] +---- +asdf install ghjk 0.3.2 +asdf global ghjk 0.3.2 +---- + +==== How do I update to the latest version? + +[source,bash] +---- +asdf install ghjk latest +asdf global ghjk latest +---- + +==== How do I switch between versions? + +[source,bash] +---- +# Set global version (all shells) +asdf global ghjk 0.3.2 + +# Set local version (current directory) +asdf local ghjk 0.3.1 + +# Use for single command +asdf shell ghjk 0.3.0 -- ghjk --version +---- + +==== How do I uninstall a version? + +[source,bash] +---- +asdf uninstall ghjk 0.3.1 +---- + +==== How do I list installed versions? + +[source,bash] +---- +# Installed versions +asdf list ghjk + +# All available versions +asdf list all ghjk + +# Current version +asdf current ghjk +---- + +=== Troubleshooting Questions + +==== Why am I getting "`GitHub API rate limit exceeded`"? + +GitHub limits unauthenticated API requests to 60 per hour. Set +`+GITHUB_API_TOKEN+` to increase the limit: + +[source,bash] +---- +export GITHUB_API_TOKEN="ghp_your_token_here" +---- + +Create a token at https://github.com/settings/tokens[GitHub Settings]. +No special permissions needed. + +==== Why is "`ghjk: command not found`"? + +Make sure asdf is properly configured: + +[source,bash] +---- +# Check asdf is in PATH +which asdf + +# Check ghjk is installed +asdf list ghjk + +# Reshim if needed +asdf reshim ghjk +---- + +Add to your shell profile if needed: + +[source,bash] +---- +# For bash +echo '. $HOME/.asdf/asdf.sh' >> ~/.bashrc + +# For zsh +echo '. $HOME/.asdf/asdf.sh' >> ~/.zshrc +---- + +==== Downloads are failing. What should I do? + +[arabic] +. Check your internet connection +. Check GitHub is accessible: `+curl -I https://github.com+` +. Try with debug mode: `+ASDF_DEBUG=1 asdf install ghjk +` +. Check the link:TROUBLESHOOTING.md[troubleshooting guide] + +==== How do I enable debug mode? + +[source,bash] +---- +export ASDF_DEBUG=1 +asdf install ghjk +---- + +==== Where are the logs? + +[source,bash] +---- +# asdf creates temporary logs +ls -lt ~/.asdf/tmp/ + +# View a specific log +cat ~/.asdf/tmp//install-ghjk-.log +---- + +=== Version Management Questions + +==== What does "`latest`" mean? + +"`latest`" refers to the most recent stable release of ghjk, as +published on GitHub releases. + +==== Can I install pre-release versions? + +Yes, pre-release versions (alpha, beta, rc) are available: + +[source,bash] +---- +asdf list all ghjk # Shows all versions including pre-releases +asdf install ghjk 0.3.1-rc.2 +---- + +==== Can I install from a Git commit or branch? + +Currently, no. The plugin only supports installing released versions. +This is intentional for stability. + +==== How do I pin a version for my project? + +Create a `+.tool-versions+` file: + +[source,bash] +---- +echo "ghjk 0.3.2" > .tool-versions +---- + +When anyone with asdf enters this directory, that version will be used. + +==== Can I use multiple versions simultaneously? + +Each shell session uses one version at a time, determined by: 1. +`+ASDF_GHJK_VERSION+` environment variable 2. `+.tool-versions+` in +current directory 3. `+.tool-versions+` in parent directories 4. +`+~/.tool-versions+` (global) + +You can run different versions in different terminals. + +=== Technical Questions + +==== Where are versions installed? + +[source,bash] +---- +~/.asdf/installs/ghjk// +---- + +==== Where are downloads cached? + +[source,bash] +---- +~/.asdf/downloads/ghjk// +---- + +==== How are checksums verified? + +The plugin extracts SHA256 checksums from GitHub release metadata and +verifies downloaded files. If no checksum is available, a warning is +shown but installation continues. + +==== Can I install from a mirror or alternative source? + +Not currently. The plugin only downloads from official GitHub releases +at `+github.com/metatypedev/ghjk+`. + +==== How does platform detection work? + +The plugin uses `+uname -s+` and `+uname -m+` to detect your OS and +architecture, then maps to ghjk’s platform naming: - Linux x86_64 → +`+x86_64-unknown-linux-gnu+` - Linux aarch64 → +`+aarch64-unknown-linux-gnu+` - macOS x86_64 → `+x86_64-apple-darwin+` - +macOS arm64 → `+aarch64-apple-darwin+` + +==== Is the plugin regularly updated? + +Updates are made as needed to support new ghjk versions, fix bugs, or +add features. The plugin itself doesn’t need frequent updates since it +downloads ghjk releases dynamically. + +=== Integration Questions + +==== Can I use this in CI/CD? + +Yes! See the link:EXAMPLES.md[examples documentation] for GitHub +Actions, GitLab CI, and CircleCI examples. + +==== Can I use this with Docker? + +Yes! Install asdf and the plugin in your Dockerfile. See +link:EXAMPLES.md#docker-integration[examples]. + +==== Does this work with direnv? + +Yes, asdf integrates with direnv. Configure direnv to use asdf versions. + +==== Can I use this with other asdf plugins? + +Absolutely! That’s the whole point of asdf. You can manage ghjk, +Node.js, Python, Ruby, etc., all with asdf. + +=== Development Questions + +==== How can I contribute? + +See link:../CONTRIBUTING.md[CONTRIBUTING.md] for contribution +guidelines. + +==== How do I test my changes? + +[source,bash] +---- +# Set up development environment +./scripts/setup-dev.sh + +# Run tests +./scripts/test.sh + +# Or use Make +make test +---- + +==== How do I report bugs? + +Open an issue on +https://github.com/Hyperpolymath/asdf-ghjk/issues[GitHub] using the bug +report template. + +==== How do I request features? + +Open an issue on +https://github.com/Hyperpolymath/asdf-ghjk/issues[GitHub] using the +feature request template. + +=== Comparison Questions + +==== How is this different from using ghjk’s installer? + +[width="100%",cols="24%,45%,31%",options="header",] +|=== +|Aspect |ghjk Installer |asdf-ghjk +|Version Management |Single global version |Multiple versions +|Switching Versions |Manual reinstall |`+asdf global/local+` +|Project-Specific |Manual per-project |Automatic via `+.tool-versions+` +|Updates |Manual download |`+asdf install ghjk latest+` +|Tool Ecosystem |Standalone |Part of asdf ecosystem +|=== + +==== Should I use asdf-ghjk or standalone ghjk? + +*Use asdf-ghjk if:* - You already use asdf for other tools - You need +multiple ghjk versions - You want project-specific versions - You want +consistent version management + +*Use standalone ghjk if:* - You only need one ghjk version - You don’t +use asdf - You prefer ghjk’s native installation + +==== Can I use both? + +Not recommended. Stick with one installation method to avoid conflicts. + +=== Getting Help + +==== Where can I get help? + +[arabic] +. Check this FAQ +. Read the link:TROUBLESHOOTING.md[troubleshooting guide] +. Check https://github.com/Hyperpolymath/asdf-ghjk/issues[existing +issues] +. Open a https://github.com/Hyperpolymath/asdf-ghjk/issues/new[new +issue] +. Consult https://asdf-vm.com[asdf documentation] +. Consult https://github.com/metatypedev/ghjk[ghjk documentation] + +==== Is there a community? + +* *asdf*: https://github.com/asdf-vm/asdf/discussions[GitHub +Discussions] +* *ghjk*: https://github.com/metatypedev/ghjk[GitHub Issues/Discussions] +* *This Plugin*: +https://github.com/Hyperpolymath/asdf-ghjk/issues[GitHub Issues] + +''''' + +*Still have questions?* Open an issue or discussion on GitHub! diff --git a/asdf-ghjk/docs/FAQ.md b/asdf-ghjk/docs/FAQ.md deleted file mode 100644 index 981ca926..00000000 --- a/asdf-ghjk/docs/FAQ.md +++ /dev/null @@ -1,349 +0,0 @@ -# Frequently Asked Questions (FAQ) - -Common questions about asdf-ghjk. - -## General Questions - -### What is asdf-ghjk? - -asdf-ghjk is an [asdf](https://asdf-vm.com) plugin that allows you to install and manage [ghjk](https://github.com/metatypedev/ghjk) versions using asdf's version management system. - -### What is ghjk? - -ghjk is a modern development environment manager that provides: -- Unified package management across multiple ecosystems (npm, PyPI, crates.io, etc.) -- TypeScript-based task automation -- Reproducible POSIX shell environments -- Declarative configuration with inheritance - -Think of it as a successor to asdf with additional capabilities. - -### Why use asdf-ghjk instead of installing ghjk directly? - -Using asdf-ghjk provides: -- **Version Management**: Install and switch between multiple ghjk versions -- **Project-Specific Versions**: Different projects can use different ghjk versions -- **Consistent Tooling**: Use the same version management approach for all your tools -- **Easy Updates**: Simple commands to update to the latest version -- **No Global Installation**: Avoids system-wide installation conflicts - -### Is this an official plugin? - -No, this is a community-maintained plugin. For official ghjk support, refer to the [ghjk repository](https://github.com/metatypedev/ghjk). - -## Installation Questions - -### How do I install the plugin? - -```bash -asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git -asdf install ghjk latest -asdf global ghjk latest -``` - -### Do I need to install asdf first? - -Yes! This is an asdf plugin, so you need asdf installed first. Get it from [asdf-vm.com](https://asdf-vm.com). - -### What are the system requirements? - -**Required:** -- Bash 4.0+ -- curl -- tar -- grep, sort - -**For ghjk runtime:** -- git -- curl -- tar -- unzip -- zstd - -### Which platforms are supported? - -- Linux (x86_64, aarch64) -- macOS (x86_64, arm64/Apple Silicon) - -Windows is not currently supported (but may work with WSL). - -### Can I install ghjk without root/sudo access? - -Yes! asdf and this plugin install everything in your home directory (~/.asdf/). No root access required. - -## Usage Questions - -### How do I install a specific version? - -```bash -asdf install ghjk 0.3.2 -asdf global ghjk 0.3.2 -``` - -### How do I update to the latest version? - -```bash -asdf install ghjk latest -asdf global ghjk latest -``` - -### How do I switch between versions? - -```bash -# Set global version (all shells) -asdf global ghjk 0.3.2 - -# Set local version (current directory) -asdf local ghjk 0.3.1 - -# Use for single command -asdf shell ghjk 0.3.0 -- ghjk --version -``` - -### How do I uninstall a version? - -```bash -asdf uninstall ghjk 0.3.1 -``` - -### How do I list installed versions? - -```bash -# Installed versions -asdf list ghjk - -# All available versions -asdf list all ghjk - -# Current version -asdf current ghjk -``` - -## Troubleshooting Questions - -### Why am I getting "GitHub API rate limit exceeded"? - -GitHub limits unauthenticated API requests to 60 per hour. Set `GITHUB_API_TOKEN` to increase the limit: - -```bash -export GITHUB_API_TOKEN="ghp_your_token_here" -``` - -Create a token at [GitHub Settings](https://github.com/settings/tokens). No special permissions needed. - -### Why is "ghjk: command not found"? - -Make sure asdf is properly configured: - -```bash -# Check asdf is in PATH -which asdf - -# Check ghjk is installed -asdf list ghjk - -# Reshim if needed -asdf reshim ghjk -``` - -Add to your shell profile if needed: - -```bash -# For bash -echo '. $HOME/.asdf/asdf.sh' >> ~/.bashrc - -# For zsh -echo '. $HOME/.asdf/asdf.sh' >> ~/.zshrc -``` - -### Downloads are failing. What should I do? - -1. Check your internet connection -2. Check GitHub is accessible: `curl -I https://github.com` -3. Try with debug mode: `ASDF_DEBUG=1 asdf install ghjk ` -4. Check the [troubleshooting guide](TROUBLESHOOTING.md) - -### How do I enable debug mode? - -```bash -export ASDF_DEBUG=1 -asdf install ghjk -``` - -### Where are the logs? - -```bash -# asdf creates temporary logs -ls -lt ~/.asdf/tmp/ - -# View a specific log -cat ~/.asdf/tmp//install-ghjk-.log -``` - -## Version Management Questions - -### What does "latest" mean? - -"latest" refers to the most recent stable release of ghjk, as published on GitHub releases. - -### Can I install pre-release versions? - -Yes, pre-release versions (alpha, beta, rc) are available: - -```bash -asdf list all ghjk # Shows all versions including pre-releases -asdf install ghjk 0.3.1-rc.2 -``` - -### Can I install from a Git commit or branch? - -Currently, no. The plugin only supports installing released versions. This is intentional for stability. - -### How do I pin a version for my project? - -Create a `.tool-versions` file: - -```bash -echo "ghjk 0.3.2" > .tool-versions -``` - -When anyone with asdf enters this directory, that version will be used. - -### Can I use multiple versions simultaneously? - -Each shell session uses one version at a time, determined by: -1. `ASDF_GHJK_VERSION` environment variable -2. `.tool-versions` in current directory -3. `.tool-versions` in parent directories -4. `~/.tool-versions` (global) - -You can run different versions in different terminals. - -## Technical Questions - -### Where are versions installed? - -```bash -~/.asdf/installs/ghjk// -``` - -### Where are downloads cached? - -```bash -~/.asdf/downloads/ghjk// -``` - -### How are checksums verified? - -The plugin extracts SHA256 checksums from GitHub release metadata and verifies downloaded files. If no checksum is available, a warning is shown but installation continues. - -### Can I install from a mirror or alternative source? - -Not currently. The plugin only downloads from official GitHub releases at `github.com/metatypedev/ghjk`. - -### How does platform detection work? - -The plugin uses `uname -s` and `uname -m` to detect your OS and architecture, then maps to ghjk's platform naming: -- Linux x86_64 → `x86_64-unknown-linux-gnu` -- Linux aarch64 → `aarch64-unknown-linux-gnu` -- macOS x86_64 → `x86_64-apple-darwin` -- macOS arm64 → `aarch64-apple-darwin` - -### Is the plugin regularly updated? - -Updates are made as needed to support new ghjk versions, fix bugs, or add features. The plugin itself doesn't need frequent updates since it downloads ghjk releases dynamically. - -## Integration Questions - -### Can I use this in CI/CD? - -Yes! See the [examples documentation](EXAMPLES.md) for GitHub Actions, GitLab CI, and CircleCI examples. - -### Can I use this with Docker? - -Yes! Install asdf and the plugin in your Dockerfile. See [examples](EXAMPLES.md#docker-integration). - -### Does this work with direnv? - -Yes, asdf integrates with direnv. Configure direnv to use asdf versions. - -### Can I use this with other asdf plugins? - -Absolutely! That's the whole point of asdf. You can manage ghjk, Node.js, Python, Ruby, etc., all with asdf. - -## Development Questions - -### How can I contribute? - -See [CONTRIBUTING.md](../CONTRIBUTING.md) for contribution guidelines. - -### How do I test my changes? - -```bash -# Set up development environment -./scripts/setup-dev.sh - -# Run tests -./scripts/test.sh - -# Or use Make -make test -``` - -### How do I report bugs? - -Open an issue on [GitHub](https://github.com/Hyperpolymath/asdf-ghjk/issues) using the bug report template. - -### How do I request features? - -Open an issue on [GitHub](https://github.com/Hyperpolymath/asdf-ghjk/issues) using the feature request template. - -## Comparison Questions - -### How is this different from using ghjk's installer? - -| Aspect | ghjk Installer | asdf-ghjk | -|--------|----------------|-----------| -| Version Management | Single global version | Multiple versions | -| Switching Versions | Manual reinstall | `asdf global/local` | -| Project-Specific | Manual per-project | Automatic via `.tool-versions` | -| Updates | Manual download | `asdf install ghjk latest` | -| Tool Ecosystem | Standalone | Part of asdf ecosystem | - -### Should I use asdf-ghjk or standalone ghjk? - -**Use asdf-ghjk if:** -- You already use asdf for other tools -- You need multiple ghjk versions -- You want project-specific versions -- You want consistent version management - -**Use standalone ghjk if:** -- You only need one ghjk version -- You don't use asdf -- You prefer ghjk's native installation - -### Can I use both? - -Not recommended. Stick with one installation method to avoid conflicts. - -## Getting Help - -### Where can I get help? - -1. Check this FAQ -2. Read the [troubleshooting guide](TROUBLESHOOTING.md) -3. Check [existing issues](https://github.com/Hyperpolymath/asdf-ghjk/issues) -4. Open a [new issue](https://github.com/Hyperpolymath/asdf-ghjk/issues/new) -5. Consult [asdf documentation](https://asdf-vm.com) -6. Consult [ghjk documentation](https://github.com/metatypedev/ghjk) - -### Is there a community? - -- **asdf**: [GitHub Discussions](https://github.com/asdf-vm/asdf/discussions) -- **ghjk**: [GitHub Issues/Discussions](https://github.com/metatypedev/ghjk) -- **This Plugin**: [GitHub Issues](https://github.com/Hyperpolymath/asdf-ghjk/issues) - ---- - -**Still have questions?** Open an issue or discussion on GitHub! diff --git a/asdf-ghjk/docs/MIGRATION.adoc b/asdf-ghjk/docs/MIGRATION.adoc new file mode 100644 index 00000000..e4f54437 --- /dev/null +++ b/asdf-ghjk/docs/MIGRATION.adoc @@ -0,0 +1,518 @@ +== Migration Guide + +This guide helps you migrate from standalone ghjk installation to +asdf-ghjk. + +=== Table of Contents + +* link:#why-migrate[Why Migrate] +* link:#before-you-begin[Before You Begin] +* link:#migration-steps[Migration Steps] +* link:#verification[Verification] +* link:#rollback[Rollback] +* link:#common-issues[Common Issues] + +=== Why Migrate + +Migrating to asdf-ghjk provides: + +* *Version Management*: Install and switch between multiple ghjk +versions +* *Project-Specific Versions*: Different projects can use different ghjk +versions +* *Consistent Tooling*: Use asdf for all your development tools +* *Easy Updates*: Simple commands to update to latest versions +* *Better CI/CD Integration*: Standard approach across projects + +=== Before You Begin + +==== Check Your Current Installation + +[source,bash] +---- +# Find where ghjk is currently installed +which ghjk + +# Check your current version +ghjk --version + +# See if ghjk is managing other tools +ghjk env +---- + +==== Backup Your Configuration + +[source,bash] +---- +# Backup your ghjk configuration files +cp ghjk.ts ghjk.ts.backup + +# Backup any environment configurations +cp .env .env.backup 2>/dev/null || true +---- + +==== Prerequisites + +Ensure you have: + +[arabic] +. *asdf installed* - +https://asdf-vm.com/guide/getting-started.html[Installation guide] +. *System dependencies*: git, curl, tar +. *Shell properly configured* for asdf + +=== Migration Steps + +==== Step 1: Note Your Current Version + +[source,bash] +---- +# Record your current ghjk version +CURRENT_GHJK_VERSION=$(ghjk --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1) +echo "Current version: $CURRENT_GHJK_VERSION" +---- + +==== Step 2: Remove Standalone Installation + +===== If Installed via Official Installer + +[source,bash] +---- +# The official installer typically installs to one of these locations: +# - ~/.ghjk/ +# - /usr/local/bin/ghjk +# - ~/bin/ghjk + +# Check and remove +rm -rf ~/.ghjk +sudo rm -f /usr/local/bin/ghjk +rm -f ~/bin/ghjk +---- + +===== Clean Up Shell Profile + +Remove ghjk-related lines from your shell profile: + +[source,bash] +---- +# Edit your profile +nano ~/.bashrc # or ~/.zshrc, ~/.bash_profile, etc. + +# Remove lines like: +# export PATH="$HOME/.ghjk/bin:$PATH" +# source ~/.ghjk/env.sh +# etc. + +# Reload your shell +source ~/.bashrc +---- + +==== Step 3: Install asdf-ghjk Plugin + +[source,bash] +---- +# Add the plugin +asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git + +# Verify plugin was added +asdf plugin list | grep ghjk +---- + +==== Step 4: Install Your Version + +[source,bash] +---- +# Option A: Install the same version you were using +asdf install ghjk $CURRENT_GHJK_VERSION +asdf global ghjk $CURRENT_GHJK_VERSION + +# Option B: Install latest stable +asdf install ghjk latest +asdf global ghjk latest + +# Option C: Install specific version +asdf install ghjk 0.3.2 +asdf global ghjk 0.3.2 +---- + +==== Step 5: Verify Installation + +[source,bash] +---- +# Check that ghjk is available +which ghjk +# Should show: ~/.asdf/shims/ghjk + +# Verify version +ghjk --version + +# Test basic functionality +ghjk --help +---- + +==== Step 6: Update Project Configuration + +For each project using ghjk: + +[source,bash] +---- +cd your-project + +# Create .tool-versions file +echo "ghjk $CURRENT_GHJK_VERSION" > .tool-versions + +# Or use asdf local command +asdf local ghjk $CURRENT_GHJK_VERSION + +# Verify +cat .tool-versions +---- + +==== Step 7: Test Your Projects + +[source,bash] +---- +cd your-project + +# Test ghjk commands +ghjk env +ghjk run + +# Verify everything works as before +---- + +=== Project-by-Project Migration + +If you have multiple projects, migrate them individually: + +[source,bash] +---- +#!/bin/bash +# migrate-projects.sh + +PROJECTS=( + ~/projects/project-a + ~/projects/project-b + ~/projects/project-c +) + +GHJK_VERSION="0.3.2" # or use latest + +for project in "${PROJECTS[@]}"; do + if [ -f "$project/ghjk.ts" ]; then + echo "Migrating $project..." + cd "$project" + + # Create .tool-versions + echo "ghjk $GHJK_VERSION" > .tool-versions + + # Test + if ghjk --version &>/dev/null; then + echo "✅ $project migrated successfully" + else + echo "❌ $project migration failed" + fi + fi +done +---- + +=== Verification + +==== Verify asdf Setup + +[source,bash] +---- +# Check asdf is working +asdf --version + +# Check ghjk plugin +asdf plugin list | grep ghjk + +# List installed ghjk versions +asdf list ghjk + +# Check current version +asdf current ghjk +---- + +==== Verify ghjk Functionality + +[source,bash] +---- +# Basic commands should work +ghjk --version +ghjk --help + +# Project commands should work +cd your-project +ghjk env +ghjk run +---- + +==== Verify PATH + +[source,bash] +---- +# ghjk should come from asdf +which ghjk +# Expected: ~/.asdf/shims/ghjk + +# Check it's executable +test -x "$(which ghjk)" && echo "✅ Executable" || echo "❌ Not executable" +---- + +=== Rollback + +If you need to revert the migration: + +==== Remove asdf-ghjk + +[source,bash] +---- +# Uninstall all ghjk versions +asdf uninstall ghjk --all + +# Remove plugin +asdf plugin remove ghjk +---- + +==== Reinstall Standalone + +[source,bash] +---- +# Use ghjk's official installer +curl -fsSL https://ghjk.deno.dev/install.sh | sh + +# Or download specific version manually +# See: https://github.com/metatypedev/ghjk/releases +---- + +==== Restore Configuration + +[source,bash] +---- +# Restore backed up files +cp ghjk.ts.backup ghjk.ts +cp .env.backup .env 2>/dev/null || true + +# Remove .tool-versions files if you added them +find ~/projects -name .tool-versions -exec grep -l "^ghjk" {} \; -delete +---- + +=== Common Issues + +==== Issue: "`ghjk: command not found`" After Migration + +*Cause*: Shell hasn’t picked up asdf’s shims + +*Solution*: + +[source,bash] +---- +# Reload shell configuration +source ~/.bashrc # or ~/.zshrc + +# Or restart your terminal + +# Reshim asdf +asdf reshim +---- + +==== Issue: Wrong Version Being Used + +*Cause*: Version precedence confusion + +*Solution*: + +[source,bash] +---- +# Check which version is active and why +asdf current ghjk + +# Set explicitly +asdf local ghjk 0.3.2 # For current project +asdf global ghjk 0.3.2 # For all projects +---- + +==== Issue: ghjk Commands Failing + +*Cause*: Missing runtime dependencies + +*Solution*: + +[source,bash] +---- +# Install ghjk runtime dependencies +# Ubuntu/Debian +sudo apt-get install git curl tar unzip zstd + +# macOS +brew install git curl tar unzip zstd +---- + +==== Issue: Different Behavior After Migration + +*Cause*: Different version or configuration + +*Solution*: + +[source,bash] +---- +# Ensure exact same version +asdf install ghjk $OLD_VERSION +asdf global ghjk $OLD_VERSION + +# Compare configurations +diff ghjk.ts ghjk.ts.backup +---- + +=== Advanced Migration Scenarios + +==== Migrating from System Package + +If ghjk was installed via package manager: + +[source,bash] +---- +# Ubuntu/Debian +sudo apt-get remove ghjk + +# Homebrew +brew uninstall ghjk + +# Then follow standard migration steps +---- + +==== Migrating CI/CD + +Update your CI/CD configuration: + +*Before (standalone ghjk):* + +[source,yaml] +---- +- name: Install ghjk + run: curl -fsSL https://ghjk.deno.dev/install.sh | sh +---- + +*After (asdf-ghjk):* + +[source,yaml] +---- +- name: Install asdf + uses: asdf-vm/actions/setup@v3 + +- name: Install ghjk + run: | + asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git + asdf install ghjk +---- + +==== Migrating Docker + +*Before:* + +[source,dockerfile] +---- +RUN curl -fsSL https://ghjk.deno.dev/install.sh | sh +ENV PATH="/root/.ghjk/bin:${PATH}" +---- + +*After:* + +[source,dockerfile] +---- +RUN git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.0 +ENV PATH="/root/.asdf/bin:/root/.asdf/shims:${PATH}" +RUN asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git +COPY .tool-versions . +RUN asdf install +---- + +=== Best Practices Post-Migration + +==== Use .tool-versions + +Create `+.tool-versions+` in each project: + +.... +ghjk 0.3.2 +nodejs 20.0.0 +python 3.11.0 +.... + +==== Pin Versions in Version Control + +[source,bash] +---- +# Commit .tool-versions to git +git add .tool-versions +git commit -m "chore: pin ghjk version" +---- + +==== Document the Migration + +Add to your project’s README: + +[source,markdown] +---- +## Development Setup + +This project uses asdf for version management. + +### Prerequisites +- [asdf](https://asdf-vm.com) + +### Installation +\`\`\`bash +asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git +asdf install # Installs versions from .tool-versions +\`\`\` +---- + +==== Team Communication + +Inform your team: + +[source,markdown] +---- +# Migration to asdf-ghjk + +We've migrated from standalone ghjk to asdf-ghjk for better version management. + +**Action Required:** +1. Install asdf: https://asdf-vm.com +2. Run: `asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git` +3. Run: `asdf install` + +**Benefits:** +- Multiple ghjk versions supported +- Automatic version switching per project +- Consistent with other tools (Node.js, Python, etc.) +---- + +=== Getting Help + +If you encounter issues during migration: + +[arabic] +. Check the link:TROUBLESHOOTING.md[troubleshooting guide] +. Check the link:FAQ.md[FAQ] +. Open an https://github.com/Hyperpolymath/asdf-ghjk/issues[issue] + +=== Success Checklist + +* [ ] Standalone ghjk removed +* [ ] asdf-ghjk plugin installed +* [ ] Correct version(s) installed +* [ ] `+which ghjk+` points to asdf shims +* [ ] All projects have `+.tool-versions+` +* [ ] All projects tested and working +* [ ] CI/CD updated +* [ ] Team notified +* [ ] Documentation updated + +''''' + +*Migration complete!* You’re now using asdf-ghjk for better version +management. diff --git a/asdf-ghjk/docs/MIGRATION.md b/asdf-ghjk/docs/MIGRATION.md deleted file mode 100644 index 8d86c500..00000000 --- a/asdf-ghjk/docs/MIGRATION.md +++ /dev/null @@ -1,482 +0,0 @@ -# Migration Guide - -This guide helps you migrate from standalone ghjk installation to asdf-ghjk. - -## Table of Contents - -- [Why Migrate](#why-migrate) -- [Before You Begin](#before-you-begin) -- [Migration Steps](#migration-steps) -- [Verification](#verification) -- [Rollback](#rollback) -- [Common Issues](#common-issues) - -## Why Migrate - -Migrating to asdf-ghjk provides: - -- **Version Management**: Install and switch between multiple ghjk versions -- **Project-Specific Versions**: Different projects can use different ghjk versions -- **Consistent Tooling**: Use asdf for all your development tools -- **Easy Updates**: Simple commands to update to latest versions -- **Better CI/CD Integration**: Standard approach across projects - -## Before You Begin - -### Check Your Current Installation - -```bash -# Find where ghjk is currently installed -which ghjk - -# Check your current version -ghjk --version - -# See if ghjk is managing other tools -ghjk env -``` - -### Backup Your Configuration - -```bash -# Backup your ghjk configuration files -cp ghjk.ts ghjk.ts.backup - -# Backup any environment configurations -cp .env .env.backup 2>/dev/null || true -``` - -### Prerequisites - -Ensure you have: - -1. **asdf installed** - [Installation guide](https://asdf-vm.com/guide/getting-started.html) -2. **System dependencies**: git, curl, tar -3. **Shell properly configured** for asdf - -## Migration Steps - -### Step 1: Note Your Current Version - -```bash -# Record your current ghjk version -CURRENT_GHJK_VERSION=$(ghjk --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1) -echo "Current version: $CURRENT_GHJK_VERSION" -``` - -### Step 2: Remove Standalone Installation - -#### If Installed via Official Installer - -```bash -# The official installer typically installs to one of these locations: -# - ~/.ghjk/ -# - /usr/local/bin/ghjk -# - ~/bin/ghjk - -# Check and remove -rm -rf ~/.ghjk -sudo rm -f /usr/local/bin/ghjk -rm -f ~/bin/ghjk -``` - -#### Clean Up Shell Profile - -Remove ghjk-related lines from your shell profile: - -```bash -# Edit your profile -nano ~/.bashrc # or ~/.zshrc, ~/.bash_profile, etc. - -# Remove lines like: -# export PATH="$HOME/.ghjk/bin:$PATH" -# source ~/.ghjk/env.sh -# etc. - -# Reload your shell -source ~/.bashrc -``` - -### Step 3: Install asdf-ghjk Plugin - -```bash -# Add the plugin -asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git - -# Verify plugin was added -asdf plugin list | grep ghjk -``` - -### Step 4: Install Your Version - -```bash -# Option A: Install the same version you were using -asdf install ghjk $CURRENT_GHJK_VERSION -asdf global ghjk $CURRENT_GHJK_VERSION - -# Option B: Install latest stable -asdf install ghjk latest -asdf global ghjk latest - -# Option C: Install specific version -asdf install ghjk 0.3.2 -asdf global ghjk 0.3.2 -``` - -### Step 5: Verify Installation - -```bash -# Check that ghjk is available -which ghjk -# Should show: ~/.asdf/shims/ghjk - -# Verify version -ghjk --version - -# Test basic functionality -ghjk --help -``` - -### Step 6: Update Project Configuration - -For each project using ghjk: - -```bash -cd your-project - -# Create .tool-versions file -echo "ghjk $CURRENT_GHJK_VERSION" > .tool-versions - -# Or use asdf local command -asdf local ghjk $CURRENT_GHJK_VERSION - -# Verify -cat .tool-versions -``` - -### Step 7: Test Your Projects - -```bash -cd your-project - -# Test ghjk commands -ghjk env -ghjk run - -# Verify everything works as before -``` - -## Project-by-Project Migration - -If you have multiple projects, migrate them individually: - -```bash -#!/bin/bash -# migrate-projects.sh - -PROJECTS=( - ~/projects/project-a - ~/projects/project-b - ~/projects/project-c -) - -GHJK_VERSION="0.3.2" # or use latest - -for project in "${PROJECTS[@]}"; do - if [ -f "$project/ghjk.ts" ]; then - echo "Migrating $project..." - cd "$project" - - # Create .tool-versions - echo "ghjk $GHJK_VERSION" > .tool-versions - - # Test - if ghjk --version &>/dev/null; then - echo "✅ $project migrated successfully" - else - echo "❌ $project migration failed" - fi - fi -done -``` - -## Verification - -### Verify asdf Setup - -```bash -# Check asdf is working -asdf --version - -# Check ghjk plugin -asdf plugin list | grep ghjk - -# List installed ghjk versions -asdf list ghjk - -# Check current version -asdf current ghjk -``` - -### Verify ghjk Functionality - -```bash -# Basic commands should work -ghjk --version -ghjk --help - -# Project commands should work -cd your-project -ghjk env -ghjk run -``` - -### Verify PATH - -```bash -# ghjk should come from asdf -which ghjk -# Expected: ~/.asdf/shims/ghjk - -# Check it's executable -test -x "$(which ghjk)" && echo "✅ Executable" || echo "❌ Not executable" -``` - -## Rollback - -If you need to revert the migration: - -### Remove asdf-ghjk - -```bash -# Uninstall all ghjk versions -asdf uninstall ghjk --all - -# Remove plugin -asdf plugin remove ghjk -``` - -### Reinstall Standalone - -```bash -# Use ghjk's official installer -curl -fsSL https://ghjk.deno.dev/install.sh | sh - -# Or download specific version manually -# See: https://github.com/metatypedev/ghjk/releases -``` - -### Restore Configuration - -```bash -# Restore backed up files -cp ghjk.ts.backup ghjk.ts -cp .env.backup .env 2>/dev/null || true - -# Remove .tool-versions files if you added them -find ~/projects -name .tool-versions -exec grep -l "^ghjk" {} \; -delete -``` - -## Common Issues - -### Issue: "ghjk: command not found" After Migration - -**Cause**: Shell hasn't picked up asdf's shims - -**Solution**: - -```bash -# Reload shell configuration -source ~/.bashrc # or ~/.zshrc - -# Or restart your terminal - -# Reshim asdf -asdf reshim -``` - -### Issue: Wrong Version Being Used - -**Cause**: Version precedence confusion - -**Solution**: - -```bash -# Check which version is active and why -asdf current ghjk - -# Set explicitly -asdf local ghjk 0.3.2 # For current project -asdf global ghjk 0.3.2 # For all projects -``` - -### Issue: ghjk Commands Failing - -**Cause**: Missing runtime dependencies - -**Solution**: - -```bash -# Install ghjk runtime dependencies -# Ubuntu/Debian -sudo apt-get install git curl tar unzip zstd - -# macOS -brew install git curl tar unzip zstd -``` - -### Issue: Different Behavior After Migration - -**Cause**: Different version or configuration - -**Solution**: - -```bash -# Ensure exact same version -asdf install ghjk $OLD_VERSION -asdf global ghjk $OLD_VERSION - -# Compare configurations -diff ghjk.ts ghjk.ts.backup -``` - -## Advanced Migration Scenarios - -### Migrating from System Package - -If ghjk was installed via package manager: - -```bash -# Ubuntu/Debian -sudo apt-get remove ghjk - -# Homebrew -brew uninstall ghjk - -# Then follow standard migration steps -``` - -### Migrating CI/CD - -Update your CI/CD configuration: - -**Before (standalone ghjk):** - -```yaml -- name: Install ghjk - run: curl -fsSL https://ghjk.deno.dev/install.sh | sh -``` - -**After (asdf-ghjk):** - -```yaml -- name: Install asdf - uses: asdf-vm/actions/setup@v3 - -- name: Install ghjk - run: | - asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git - asdf install ghjk -``` - -### Migrating Docker - -**Before:** - -```dockerfile -RUN curl -fsSL https://ghjk.deno.dev/install.sh | sh -ENV PATH="/root/.ghjk/bin:${PATH}" -``` - -**After:** - -```dockerfile -RUN git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.0 -ENV PATH="/root/.asdf/bin:/root/.asdf/shims:${PATH}" -RUN asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git -COPY .tool-versions . -RUN asdf install -``` - -## Best Practices Post-Migration - -### Use .tool-versions - -Create `.tool-versions` in each project: - -``` -ghjk 0.3.2 -nodejs 20.0.0 -python 3.11.0 -``` - -### Pin Versions in Version Control - -```bash -# Commit .tool-versions to git -git add .tool-versions -git commit -m "chore: pin ghjk version" -``` - -### Document the Migration - -Add to your project's README: - -```markdown -## Development Setup - -This project uses asdf for version management. - -### Prerequisites -- [asdf](https://asdf-vm.com) - -### Installation -\`\`\`bash -asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git -asdf install # Installs versions from .tool-versions -\`\`\` -``` - -### Team Communication - -Inform your team: - -```markdown -# Migration to asdf-ghjk - -We've migrated from standalone ghjk to asdf-ghjk for better version management. - -**Action Required:** -1. Install asdf: https://asdf-vm.com -2. Run: `asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git` -3. Run: `asdf install` - -**Benefits:** -- Multiple ghjk versions supported -- Automatic version switching per project -- Consistent with other tools (Node.js, Python, etc.) -``` - -## Getting Help - -If you encounter issues during migration: - -1. Check the [troubleshooting guide](TROUBLESHOOTING.md) -2. Check the [FAQ](FAQ.md) -3. Open an [issue](https://github.com/Hyperpolymath/asdf-ghjk/issues) - -## Success Checklist - -- [ ] Standalone ghjk removed -- [ ] asdf-ghjk plugin installed -- [ ] Correct version(s) installed -- [ ] `which ghjk` points to asdf shims -- [ ] All projects have `.tool-versions` -- [ ] All projects tested and working -- [ ] CI/CD updated -- [ ] Team notified -- [ ] Documentation updated - ---- - -**Migration complete!** You're now using asdf-ghjk for better version management. diff --git a/asdf-ghjk/docs/QUICKSTART.adoc b/asdf-ghjk/docs/QUICKSTART.adoc new file mode 100644 index 00000000..93438bb8 --- /dev/null +++ b/asdf-ghjk/docs/QUICKSTART.adoc @@ -0,0 +1,202 @@ +== Quick Start Guide + +Get up and running with asdf-ghjk in 5 minutes. + +=== Prerequisites + +Before you begin, install: + +[arabic] +. *asdf* - https://asdf-vm.com/guide/getting-started.html[Installation +guide] +. *System dependencies*: git, curl, tar + +[source,bash] +---- +# Ubuntu/Debian +sudo apt-get install git curl tar + +# macOS +brew install git curl tar +---- + +=== Installation (30 seconds) + +[source,bash] +---- +# 1. Add the plugin +asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git + +# 2. Install latest version +asdf install ghjk latest + +# 3. Set as default +asdf global ghjk latest + +# 4. Verify +ghjk --version +---- + +Done! 🎉 + +=== Your First ghjk Project (2 minutes) + +[source,bash] +---- +# 1. Create a new project +mkdir my-project +cd my-project + +# 2. Pin ghjk version for this project +asdf local ghjk latest + +# 3. Initialize ghjk +ghjk init ts + +# 4. View the generated config +cat ghjk.ts +---- + +You now have a `+ghjk.ts+` configuration file! + +=== Basic Configuration (1 minute) + +Edit `+ghjk.ts+`: + +[source,typescript] +---- +export { sophon } from "https://deno.land/x/ghjk/mod.ts"; + +sophon({ + // Environment variables + env: { + NODE_ENV: "development", + }, + + // Tools to install + installs: [ + { name: "node", version: "20.0.0" }, + ], + + // Tasks you can run + tasks: { + dev: "npm run dev", + test: "npm test", + build: "npm run build", + }, +}); +---- + +=== Running Tasks (30 seconds) + +[source,bash] +---- +# Activate environment +ghjk env + +# Or run tasks directly +ghjk run dev +ghjk run test +ghjk run build +---- + +=== Common Commands (30 seconds) + +[source,bash] +---- +# List all available ghjk versions +asdf list all ghjk + +# Install a specific version +asdf install ghjk 0.3.2 + +# Switch versions +asdf global ghjk 0.3.2 # All projects +asdf local ghjk 0.3.1 # Current project only +asdf shell ghjk 0.3.0 # Current shell only + +# See what's installed +asdf list ghjk + +# See current version +asdf current ghjk + +# Update to latest +asdf install ghjk latest && asdf global ghjk latest +---- + +=== Troubleshooting (30 seconds) + +==== "`ghjk: command not found`" + +[source,bash] +---- +# Reshim asdf +asdf reshim ghjk + +# Or add asdf to your PATH (if not already) +echo '. $HOME/.asdf/asdf.sh' >> ~/.bashrc +source ~/.bashrc +---- + +==== "`GitHub API rate limit exceeded`" + +[source,bash] +---- +# Create a token at: https://github.com/settings/tokens +export GITHUB_API_TOKEN="ghp_your_token_here" + +# Add to your shell profile to make permanent +echo 'export GITHUB_API_TOKEN="ghp_..."' >> ~/.bashrc +---- + +==== Need more help? + +* link:../README.md[Full Documentation] +* link:TROUBLESHOOTING.md[Troubleshooting Guide] +* link:FAQ.md[FAQ] + +=== Next Steps + +Now that you’re set up, explore: + +[arabic] +. *link:EXAMPLES.md[Examples]* - Real-world usage patterns +. *https://github.com/metatypedev/ghjk[ghjk Docs]* - Learn more about +ghjk +. *https://asdf-vm.com[asdf Docs]* - Master asdf version management + +=== Quick Reference Card + +[source,bash] +---- +# Plugin Management +asdf plugin add ghjk # Add plugin +asdf plugin update ghjk # Update plugin +asdf plugin remove ghjk # Remove plugin + +# Version Installation +asdf install ghjk latest # Install latest +asdf install ghjk 0.3.2 # Install specific version +asdf uninstall ghjk 0.3.1 # Remove version + +# Version Selection +asdf global ghjk # Set global default +asdf local ghjk # Set for current directory +asdf shell ghjk # Set for current shell + +# Information +asdf list all ghjk # All available versions +asdf list ghjk # Installed versions +asdf current ghjk # Active version +asdf where ghjk # Installation path + +# Maintenance +asdf reshim ghjk # Rebuild shims +asdf update # Update asdf itself +---- + +''''' + +*Ready to dive deeper?* Check out the link:../README.md[full +documentation]! diff --git a/asdf-ghjk/docs/QUICKSTART.md b/asdf-ghjk/docs/QUICKSTART.md deleted file mode 100644 index 83f7345a..00000000 --- a/asdf-ghjk/docs/QUICKSTART.md +++ /dev/null @@ -1,188 +0,0 @@ -# Quick Start Guide - -Get up and running with asdf-ghjk in 5 minutes. - -## Prerequisites - -Before you begin, install: - -1. **asdf** - [Installation guide](https://asdf-vm.com/guide/getting-started.html) -2. **System dependencies**: git, curl, tar - -```bash -# Ubuntu/Debian -sudo apt-get install git curl tar - -# macOS -brew install git curl tar -``` - -## Installation (30 seconds) - -```bash -# 1. Add the plugin -asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git - -# 2. Install latest version -asdf install ghjk latest - -# 3. Set as default -asdf global ghjk latest - -# 4. Verify -ghjk --version -``` - -Done! 🎉 - -## Your First ghjk Project (2 minutes) - -```bash -# 1. Create a new project -mkdir my-project -cd my-project - -# 2. Pin ghjk version for this project -asdf local ghjk latest - -# 3. Initialize ghjk -ghjk init ts - -# 4. View the generated config -cat ghjk.ts -``` - -You now have a `ghjk.ts` configuration file! - -## Basic Configuration (1 minute) - -Edit `ghjk.ts`: - -```typescript -export { sophon } from "https://deno.land/x/ghjk/mod.ts"; - -sophon({ - // Environment variables - env: { - NODE_ENV: "development", - }, - - // Tools to install - installs: [ - { name: "node", version: "20.0.0" }, - ], - - // Tasks you can run - tasks: { - dev: "npm run dev", - test: "npm test", - build: "npm run build", - }, -}); -``` - -## Running Tasks (30 seconds) - -```bash -# Activate environment -ghjk env - -# Or run tasks directly -ghjk run dev -ghjk run test -ghjk run build -``` - -## Common Commands (30 seconds) - -```bash -# List all available ghjk versions -asdf list all ghjk - -# Install a specific version -asdf install ghjk 0.3.2 - -# Switch versions -asdf global ghjk 0.3.2 # All projects -asdf local ghjk 0.3.1 # Current project only -asdf shell ghjk 0.3.0 # Current shell only - -# See what's installed -asdf list ghjk - -# See current version -asdf current ghjk - -# Update to latest -asdf install ghjk latest && asdf global ghjk latest -``` - -## Troubleshooting (30 seconds) - -### "ghjk: command not found" - -```bash -# Reshim asdf -asdf reshim ghjk - -# Or add asdf to your PATH (if not already) -echo '. $HOME/.asdf/asdf.sh' >> ~/.bashrc -source ~/.bashrc -``` - -### "GitHub API rate limit exceeded" - -```bash -# Create a token at: https://github.com/settings/tokens -export GITHUB_API_TOKEN="ghp_your_token_here" - -# Add to your shell profile to make permanent -echo 'export GITHUB_API_TOKEN="ghp_..."' >> ~/.bashrc -``` - -### Need more help? - -- [Full Documentation](../README.md) -- [Troubleshooting Guide](TROUBLESHOOTING.md) -- [FAQ](FAQ.md) - -## Next Steps - -Now that you're set up, explore: - -1. **[Examples](EXAMPLES.md)** - Real-world usage patterns -2. **[ghjk Docs](https://github.com/metatypedev/ghjk)** - Learn more about ghjk -3. **[asdf Docs](https://asdf-vm.com)** - Master asdf version management - -## Quick Reference Card - -```bash -# Plugin Management -asdf plugin add ghjk # Add plugin -asdf plugin update ghjk # Update plugin -asdf plugin remove ghjk # Remove plugin - -# Version Installation -asdf install ghjk latest # Install latest -asdf install ghjk 0.3.2 # Install specific version -asdf uninstall ghjk 0.3.1 # Remove version - -# Version Selection -asdf global ghjk # Set global default -asdf local ghjk # Set for current directory -asdf shell ghjk # Set for current shell - -# Information -asdf list all ghjk # All available versions -asdf list ghjk # Installed versions -asdf current ghjk # Active version -asdf where ghjk # Installation path - -# Maintenance -asdf reshim ghjk # Rebuild shims -asdf update # Update asdf itself -``` - ---- - -**Ready to dive deeper?** Check out the [full documentation](../README.md)! diff --git a/asdf-ghjk/docs/TROUBLESHOOTING.adoc b/asdf-ghjk/docs/TROUBLESHOOTING.adoc new file mode 100644 index 00000000..1c0d953a --- /dev/null +++ b/asdf-ghjk/docs/TROUBLESHOOTING.adoc @@ -0,0 +1,474 @@ +== Troubleshooting Guide + +This guide helps you resolve common issues with asdf-ghjk. + +=== Table of Contents + +* link:#installation-issues[Installation Issues] +* link:#download-failures[Download Failures] +* link:#github-api-issues[GitHub API Issues] +* link:#platform-issues[Platform Issues] +* link:#runtime-issues[Runtime Issues] +* link:#version-management[Version Management] +* link:#debug-mode[Debug Mode] + +=== Installation Issues + +==== Error: "`curl: command not found`" + +*Cause:* curl is not installed on your system. + +*Solution:* + +[source,bash] +---- +# Ubuntu/Debian +sudo apt-get install curl + +# macOS +brew install curl + +# Fedora/RHEL +sudo dnf install curl +---- + +==== Error: "`tar: command not found`" + +*Cause:* tar is not installed on your system. + +*Solution:* + +[source,bash] +---- +# Ubuntu/Debian +sudo apt-get install tar + +# macOS (should be pre-installed) +brew install gnu-tar + +# Fedora/RHEL +sudo dnf install tar +---- + +==== Error: "`Archive not found`" + +*Cause:* The download step failed or was skipped. + +*Solution:* + +[source,bash] +---- +# Download explicitly first +asdf download ghjk + +# Then install +asdf install ghjk +---- + +==== Error: "`ghjk binary not found after extraction`" + +*Cause:* The archive structure changed or extraction failed. + +*Solution:* + +[source,bash] +---- +# Enable debug mode +export ASDF_DEBUG=1 + +# Try installing again +asdf install ghjk + +# Check the extracted contents +ls -la ~/.asdf/installs/ghjk// +---- + +=== Download Failures + +==== Error: "`Failed to download after 3 attempts`" + +*Cause:* Network issues or GitHub is down. + +*Solution:* + +[arabic] +. Check your internet connection: + +[source,bash] +---- +ping github.com +---- + +[arabic, start=2] +. Check GitHub status: https://www.githubstatus.com/ +. Try with a different network +. Wait a few minutes and try again + +==== Error: "`Checksum verification failed`" + +*Cause:* Downloaded file is corrupted. + +*Solution:* + +[source,bash] +---- +# Remove the corrupted download +rm -rf ~/.asdf/downloads/ghjk/ + +# Try downloading again +asdf install ghjk +---- + +=== GitHub API Issues + +==== Error: "`GitHub API rate limit exceeded`" + +*Cause:* GitHub limits unauthenticated API requests to 60 per hour. + +*Solution:* + +Create a GitHub personal access token and set it: + +[source,bash] +---- +# 1. Create token at https://github.com/settings/tokens +# 2. No special permissions needed for public repos +# 3. Add to your shell profile (~/.bashrc, ~/.zshrc, etc.): +export GITHUB_API_TOKEN="ghp_your_token_here" + +# 4. Reload your shell +source ~/.bashrc # or ~/.zshrc +---- + +==== Error: "`GitHub API request failed with status code: 403`" + +*Cause:* Rate limit or authentication issue. + +*Solution:* + +Check your rate limit: + +[source,bash] +---- +curl -H "Authorization: token $GITHUB_API_TOKEN" \ + https://api.github.com/rate_limit +---- + +If using a token, verify it’s valid: - Go to +https://github.com/settings/tokens - Check if your token is still active +- Generate a new one if needed + +=== Platform Issues + +==== Error: "`Unsupported operating system`" + +*Cause:* Your OS is not supported by ghjk. + +*Supported Platforms:* - Linux (x86_64, aarch64) - macOS (x86_64, arm64) + +*Check your platform:* + +[source,bash] +---- +uname -s # Should be: Linux or Darwin +uname -m # Should be: x86_64, aarch64, or arm64 +---- + +==== Error: "`Unsupported architecture`" + +*Cause:* Your CPU architecture is not supported. + +*Solution:* + +ghjk currently only supports: - x86_64 (Intel/AMD 64-bit) - +aarch64/arm64 (ARM 64-bit) + +32-bit systems and other architectures are not supported. + +=== Runtime Issues + +==== Error: "`ghjk: command not found`" + +*Cause:* asdf shims not in PATH or ghjk not installed. + +*Solution:* + +[arabic] +. Verify ghjk is installed: + +[source,bash] +---- +asdf list ghjk +---- + +[arabic, start=2] +. Check that asdf is properly set up: + +[source,bash] +---- +# Should show ghjk version +asdf current ghjk + +# If not, add asdf to your PATH +# See: https://asdf-vm.com/guide/getting-started.html +---- + +[arabic, start=3] +. Reshim if necessary: + +[source,bash] +---- +asdf reshim ghjk +---- + +==== Warning: "`Missing recommended runtime dependencies`" + +*Cause:* ghjk needs additional tools to function properly. + +*Required Dependencies:* - git - curl - tar - unzip - zstd + +*Solution:* + +[source,bash] +---- +# Ubuntu/Debian +sudo apt-get install git curl tar unzip zstd + +# macOS +brew install git curl tar unzip zstd + +# Fedora/RHEL +sudo dnf install git curl tar unzip zstd +---- + +==== Error: "`ghjk init ts fails`" + +*Cause:* Missing Deno or other ghjk dependencies. + +*Solution:* + +[arabic] +. Verify ghjk is working: + +[source,bash] +---- +ghjk --version +---- + +[arabic, start=2] +. Check ghjk documentation for additional requirements: + +[source,bash] +---- +ghjk --help +---- + +[arabic, start=3] +. Try installing Deno (ghjk’s runtime): + +[source,bash] +---- +# ghjk should handle this, but you can install manually +curl -fsSL https://deno.land/install.sh | sh +---- + +=== Version Management + +==== Error: "`Version not found: latest`" + +*Cause:* `+latest+` keyword resolution failed. + +*Solution:* + +Use a specific version instead: + +[source,bash] +---- +# List all versions +asdf list all ghjk + +# Install a specific version +asdf install ghjk 0.3.2 +---- + +==== Error: "`No such version: X.Y.Z`" + +*Cause:* The version doesn’t exist or hasn’t been released yet. + +*Solution:* + +Check available versions: + +[source,bash] +---- +asdf list all ghjk +---- + +==== Multiple versions installed but wrong one is active + +*Cause:* Version precedence issues. + +*asdf Version Precedence (highest to lowest):* 1. `+ASDF_GHJK_VERSION+` +environment variable 2. `+.tool-versions+` in current directory 3. +`+.tool-versions+` in parent directories 4. `+~/.tool-versions+` +(global) + +*Solution:* + +[source,bash] +---- +# Check which version is active and why +asdf current ghjk + +# Set local version +asdf local ghjk 0.3.2 + +# Set global version +asdf global ghjk 0.3.2 + +# Use specific version for one command +ASDF_GHJK_VERSION=0.3.1 ghjk --version +---- + +=== Debug Mode + +==== Enable Verbose Output + +For detailed debugging information: + +[source,bash] +---- +# Enable asdf debug mode +export ASDF_DEBUG=1 + +# Run your command +asdf install ghjk latest + +# Check asdf logs +cat ~/.asdf/tmp/*/install-ghjk-*.log +---- + +==== Manual Script Testing + +Test plugin scripts directly: + +[source,bash] +---- +# Test list-all +./bin/list-all + +# Test download +export ASDF_INSTALL_VERSION="0.3.2" +export ASDF_DOWNLOAD_PATH="/tmp/test-download" +export ASDF_INSTALL_PATH="/tmp/test-install" +mkdir -p "$ASDF_DOWNLOAD_PATH" "$ASDF_INSTALL_PATH" + +./bin/download +./bin/install + +# Check result +ls -la /tmp/test-install/ +/tmp/test-install/bin/ghjk --version + +# Clean up +rm -rf /tmp/test-* +---- + +=== Getting More Help + +==== Check Logs + +asdf creates logs for installations: + +[source,bash] +---- +# Find recent logs +ls -lt ~/.asdf/tmp/ + +# View a specific log +cat ~/.asdf/tmp//install-ghjk-.log +---- + +==== Verify Plugin Installation + +[source,bash] +---- +# List installed plugins +asdf plugin list + +# Check plugin repository +asdf plugin list --urls + +# Re-add plugin if needed +asdf plugin remove ghjk +asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git +---- + +==== Common Solutions + +[arabic] +. *Update asdf:* + +[source,bash] +---- +asdf update +---- + +[arabic, start=2] +. *Update the plugin:* + +[source,bash] +---- +asdf plugin update ghjk +---- + +[arabic, start=3] +. *Reshim:* + +[source,bash] +---- +asdf reshim ghjk +---- + +[arabic, start=4] +. *Clean cache:* + +[source,bash] +---- +rm -rf ~/.asdf/downloads/ghjk +rm -rf ~/.asdf/tmp/* +---- + +==== Report an Issue + +If none of these solutions work: + +[arabic] +. Gather information: + +[source,bash] +---- +# System info +uname -a +bash --version +asdf --version + +# Plugin version +cd ~/.asdf/plugins/ghjk && git log -1 --oneline + +# Error output with debug enabled +ASDF_DEBUG=1 asdf install ghjk 2>&1 | tee error.log +---- + +[arabic, start=2] +. Open an issue: https://github.com/Hyperpolymath/asdf-ghjk/issues/new + +Include: - System information - Error messages - Steps to reproduce - +What you’ve already tried + +=== Additional Resources + +* *asdf Documentation:* https://asdf-vm.com +* *ghjk Documentation:* https://github.com/metatypedev/ghjk +* *Plugin README:* https://github.com/Hyperpolymath/asdf-ghjk +* *GitHub Issues:* https://github.com/Hyperpolymath/asdf-ghjk/issues diff --git a/asdf-ghjk/docs/TROUBLESHOOTING.md b/asdf-ghjk/docs/TROUBLESHOOTING.md deleted file mode 100644 index dca5b2dc..00000000 --- a/asdf-ghjk/docs/TROUBLESHOOTING.md +++ /dev/null @@ -1,447 +0,0 @@ -# Troubleshooting Guide - -This guide helps you resolve common issues with asdf-ghjk. - -## Table of Contents - -- [Installation Issues](#installation-issues) -- [Download Failures](#download-failures) -- [GitHub API Issues](#github-api-issues) -- [Platform Issues](#platform-issues) -- [Runtime Issues](#runtime-issues) -- [Version Management](#version-management) -- [Debug Mode](#debug-mode) - -## Installation Issues - -### Error: "curl: command not found" - -**Cause:** curl is not installed on your system. - -**Solution:** - -```bash -# Ubuntu/Debian -sudo apt-get install curl - -# macOS -brew install curl - -# Fedora/RHEL -sudo dnf install curl -``` - -### Error: "tar: command not found" - -**Cause:** tar is not installed on your system. - -**Solution:** - -```bash -# Ubuntu/Debian -sudo apt-get install tar - -# macOS (should be pre-installed) -brew install gnu-tar - -# Fedora/RHEL -sudo dnf install tar -``` - -### Error: "Archive not found" - -**Cause:** The download step failed or was skipped. - -**Solution:** - -```bash -# Download explicitly first -asdf download ghjk - -# Then install -asdf install ghjk -``` - -### Error: "ghjk binary not found after extraction" - -**Cause:** The archive structure changed or extraction failed. - -**Solution:** - -```bash -# Enable debug mode -export ASDF_DEBUG=1 - -# Try installing again -asdf install ghjk - -# Check the extracted contents -ls -la ~/.asdf/installs/ghjk// -``` - -## Download Failures - -### Error: "Failed to download after 3 attempts" - -**Cause:** Network issues or GitHub is down. - -**Solution:** - -1. Check your internet connection: - -```bash -ping github.com -``` - -2. Check GitHub status: https://www.githubstatus.com/ - -3. Try with a different network - -4. Wait a few minutes and try again - -### Error: "Checksum verification failed" - -**Cause:** Downloaded file is corrupted. - -**Solution:** - -```bash -# Remove the corrupted download -rm -rf ~/.asdf/downloads/ghjk/ - -# Try downloading again -asdf install ghjk -``` - -## GitHub API Issues - -### Error: "GitHub API rate limit exceeded" - -**Cause:** GitHub limits unauthenticated API requests to 60 per hour. - -**Solution:** - -Create a GitHub personal access token and set it: - -```bash -# 1. Create token at https://github.com/settings/tokens -# 2. No special permissions needed for public repos -# 3. Add to your shell profile (~/.bashrc, ~/.zshrc, etc.): -export GITHUB_API_TOKEN="ghp_your_token_here" - -# 4. Reload your shell -source ~/.bashrc # or ~/.zshrc -``` - -### Error: "GitHub API request failed with status code: 403" - -**Cause:** Rate limit or authentication issue. - -**Solution:** - -Check your rate limit: - -```bash -curl -H "Authorization: token $GITHUB_API_TOKEN" \ - https://api.github.com/rate_limit -``` - -If using a token, verify it's valid: -- Go to https://github.com/settings/tokens -- Check if your token is still active -- Generate a new one if needed - -## Platform Issues - -### Error: "Unsupported operating system" - -**Cause:** Your OS is not supported by ghjk. - -**Supported Platforms:** -- Linux (x86_64, aarch64) -- macOS (x86_64, arm64) - -**Check your platform:** - -```bash -uname -s # Should be: Linux or Darwin -uname -m # Should be: x86_64, aarch64, or arm64 -``` - -### Error: "Unsupported architecture" - -**Cause:** Your CPU architecture is not supported. - -**Solution:** - -ghjk currently only supports: -- x86_64 (Intel/AMD 64-bit) -- aarch64/arm64 (ARM 64-bit) - -32-bit systems and other architectures are not supported. - -## Runtime Issues - -### Error: "ghjk: command not found" - -**Cause:** asdf shims not in PATH or ghjk not installed. - -**Solution:** - -1. Verify ghjk is installed: - -```bash -asdf list ghjk -``` - -2. Check that asdf is properly set up: - -```bash -# Should show ghjk version -asdf current ghjk - -# If not, add asdf to your PATH -# See: https://asdf-vm.com/guide/getting-started.html -``` - -3. Reshim if necessary: - -```bash -asdf reshim ghjk -``` - -### Warning: "Missing recommended runtime dependencies" - -**Cause:** ghjk needs additional tools to function properly. - -**Required Dependencies:** -- git -- curl -- tar -- unzip -- zstd - -**Solution:** - -```bash -# Ubuntu/Debian -sudo apt-get install git curl tar unzip zstd - -# macOS -brew install git curl tar unzip zstd - -# Fedora/RHEL -sudo dnf install git curl tar unzip zstd -``` - -### Error: "ghjk init ts fails" - -**Cause:** Missing Deno or other ghjk dependencies. - -**Solution:** - -1. Verify ghjk is working: - -```bash -ghjk --version -``` - -2. Check ghjk documentation for additional requirements: - -```bash -ghjk --help -``` - -3. Try installing Deno (ghjk's runtime): - -```bash -# ghjk should handle this, but you can install manually -curl -fsSL https://deno.land/install.sh | sh -``` - -## Version Management - -### Error: "Version not found: latest" - -**Cause:** `latest` keyword resolution failed. - -**Solution:** - -Use a specific version instead: - -```bash -# List all versions -asdf list all ghjk - -# Install a specific version -asdf install ghjk 0.3.2 -``` - -### Error: "No such version: X.Y.Z" - -**Cause:** The version doesn't exist or hasn't been released yet. - -**Solution:** - -Check available versions: - -```bash -asdf list all ghjk -``` - -### Multiple versions installed but wrong one is active - -**Cause:** Version precedence issues. - -**asdf Version Precedence (highest to lowest):** -1. `ASDF_GHJK_VERSION` environment variable -2. `.tool-versions` in current directory -3. `.tool-versions` in parent directories -4. `~/.tool-versions` (global) - -**Solution:** - -```bash -# Check which version is active and why -asdf current ghjk - -# Set local version -asdf local ghjk 0.3.2 - -# Set global version -asdf global ghjk 0.3.2 - -# Use specific version for one command -ASDF_GHJK_VERSION=0.3.1 ghjk --version -``` - -## Debug Mode - -### Enable Verbose Output - -For detailed debugging information: - -```bash -# Enable asdf debug mode -export ASDF_DEBUG=1 - -# Run your command -asdf install ghjk latest - -# Check asdf logs -cat ~/.asdf/tmp/*/install-ghjk-*.log -``` - -### Manual Script Testing - -Test plugin scripts directly: - -```bash -# Test list-all -./bin/list-all - -# Test download -export ASDF_INSTALL_VERSION="0.3.2" -export ASDF_DOWNLOAD_PATH="/tmp/test-download" -export ASDF_INSTALL_PATH="/tmp/test-install" -mkdir -p "$ASDF_DOWNLOAD_PATH" "$ASDF_INSTALL_PATH" - -./bin/download -./bin/install - -# Check result -ls -la /tmp/test-install/ -/tmp/test-install/bin/ghjk --version - -# Clean up -rm -rf /tmp/test-* -``` - -## Getting More Help - -### Check Logs - -asdf creates logs for installations: - -```bash -# Find recent logs -ls -lt ~/.asdf/tmp/ - -# View a specific log -cat ~/.asdf/tmp//install-ghjk-.log -``` - -### Verify Plugin Installation - -```bash -# List installed plugins -asdf plugin list - -# Check plugin repository -asdf plugin list --urls - -# Re-add plugin if needed -asdf plugin remove ghjk -asdf plugin add ghjk https://github.com/Hyperpolymath/asdf-ghjk.git -``` - -### Common Solutions - -1. **Update asdf:** - -```bash -asdf update -``` - -2. **Update the plugin:** - -```bash -asdf plugin update ghjk -``` - -3. **Reshim:** - -```bash -asdf reshim ghjk -``` - -4. **Clean cache:** - -```bash -rm -rf ~/.asdf/downloads/ghjk -rm -rf ~/.asdf/tmp/* -``` - -### Report an Issue - -If none of these solutions work: - -1. Gather information: - -```bash -# System info -uname -a -bash --version -asdf --version - -# Plugin version -cd ~/.asdf/plugins/ghjk && git log -1 --oneline - -# Error output with debug enabled -ASDF_DEBUG=1 asdf install ghjk 2>&1 | tee error.log -``` - -2. Open an issue: https://github.com/Hyperpolymath/asdf-ghjk/issues/new - -Include: -- System information -- Error messages -- Steps to reproduce -- What you've already tried - -## Additional Resources - -- **asdf Documentation:** https://asdf-vm.com -- **ghjk Documentation:** https://github.com/metatypedev/ghjk -- **Plugin README:** https://github.com/Hyperpolymath/asdf-ghjk -- **GitHub Issues:** https://github.com/Hyperpolymath/asdf-ghjk/issues diff --git a/asdf-git-crypt-plugin/CODE_OF_CONDUCT.adoc b/asdf-git-crypt-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-git-crypt-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-git-crypt-plugin/CODE_OF_CONDUCT.md b/asdf-git-crypt-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-git-crypt-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-git-crypt-plugin/CONTRIBUTING.adoc b/asdf-git-crypt-plugin/CONTRIBUTING.adoc index d18532b5..9a66b532 100644 --- a/asdf-git-crypt-plugin/CONTRIBUTING.adoc +++ b/asdf-git-crypt-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-git-crypt-plugin.git cd +asdf-git-crypt-plugin -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-git-crypt-plugin-dev toolbox enter +asdf-git-crypt-plugin-dev # Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-git-crypt-plugin/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-git-crypt-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-git-crypt-plugin/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-git-crypt-plugin/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-git-crypt-plugin/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-git-crypt-plugin/CONTRIBUTING.md b/asdf-git-crypt-plugin/CONTRIBUTING.md deleted file mode 100644 index 0e6907aa..00000000 --- a/asdf-git-crypt-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-git-crypt-plugin.git -cd asdf-git-crypt-plugin - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-git-crypt-plugin-dev -toolbox enter asdf-git-crypt-plugin-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-git-crypt-plugin/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-git-crypt-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-git-crypt-plugin/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-git-crypt-plugin/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-git-crypt-plugin/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-git-crypt-plugin/README.adoc b/asdf-git-crypt-plugin/README.adoc new file mode 100644 index 00000000..8d477498 --- /dev/null +++ b/asdf-git-crypt-plugin/README.adoc @@ -0,0 +1,83 @@ +== asdf-git-crypt + +https://github.com/hyperpolymath/asdf-git-crypt-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-git-crypt-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-git-crypt-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-git-crypt-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] + +https://asdf-vm.com[asdf] plugin for +https://www.agwa.name/projects/git-crypt[git-crypt]. + +Transparent git encryption. + +=== Contents + +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] + +=== Dependencies + +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] + +=== Install + +Plugin: + +[source,bash] +---- +asdf plugin add git-crypt https://github.com/hyperpolymath/asdf-git-crypt-plugin.git +---- + +git-crypt: + +[source,bash] +---- +# Show all installable versions +asdf list-all git-crypt + +# Install specific version +asdf install git-crypt latest + +# Set a version globally (in your ~/.tool-versions file) +asdf global git-crypt latest + +# Now git-crypt commands are available +git-crypt --version +---- + +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. + +=== Usage + +[source,bash] +---- +# List installed versions +asdf list git-crypt + +# Set local version for current directory +asdf local git-crypt + +# Uninstall a version +asdf uninstall git-crypt +---- + +=== Contributing + +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License + +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. + +''''' + +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-git-crypt-plugin/README.md b/asdf-git-crypt-plugin/README.md deleted file mode 100644 index 1ee1fac7..00000000 --- a/asdf-git-crypt-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-git-crypt - -[![Build](https://github.com/hyperpolymath/asdf-git-crypt-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-git-crypt-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-git-crypt-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-git-crypt-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [git-crypt](https://www.agwa.name/projects/git-crypt). - -Transparent git encryption. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add git-crypt https://github.com/hyperpolymath/asdf-git-crypt-plugin.git -``` - -git-crypt: - -```bash -# Show all installable versions -asdf list-all git-crypt - -# Install specific version -asdf install git-crypt latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global git-crypt latest - -# Now git-crypt commands are available -git-crypt --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list git-crypt - -# Set local version for current directory -asdf local git-crypt - -# Uninstall a version -asdf uninstall git-crypt -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-git-crypt-plugin/SECURITY.adoc b/asdf-git-crypt-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-git-crypt-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-git-crypt-plugin/SECURITY.md b/asdf-git-crypt-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-git-crypt-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-gitleaks-plugin/CODE_OF_CONDUCT.adoc b/asdf-gitleaks-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-gitleaks-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-gitleaks-plugin/CODE_OF_CONDUCT.md b/asdf-gitleaks-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-gitleaks-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-gitleaks-plugin/CONTRIBUTING.adoc b/asdf-gitleaks-plugin/CONTRIBUTING.adoc index d18532b5..9b949070 100644 --- a/asdf-gitleaks-plugin/CONTRIBUTING.adoc +++ b/asdf-gitleaks-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-gitleaks-plugin.git cd +asdf-gitleaks-plugin -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-gitleaks-plugin-dev toolbox enter +asdf-gitleaks-plugin-dev # Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-gitleaks-plugin/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-gitleaks-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-gitleaks-plugin/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-gitleaks-plugin/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-gitleaks-plugin/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-gitleaks-plugin/CONTRIBUTING.md b/asdf-gitleaks-plugin/CONTRIBUTING.md deleted file mode 100644 index 8f0b9ebf..00000000 --- a/asdf-gitleaks-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-gitleaks-plugin.git -cd asdf-gitleaks-plugin - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-gitleaks-plugin-dev -toolbox enter asdf-gitleaks-plugin-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-gitleaks-plugin/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-gitleaks-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-gitleaks-plugin/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-gitleaks-plugin/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-gitleaks-plugin/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-gitleaks-plugin/README.adoc b/asdf-gitleaks-plugin/README.adoc new file mode 100644 index 00000000..7ec85981 --- /dev/null +++ b/asdf-gitleaks-plugin/README.adoc @@ -0,0 +1,82 @@ +== asdf-gitleaks + +https://github.com/hyperpolymath/asdf-gitleaks-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-gitleaks-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-gitleaks-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-gitleaks-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] + +https://asdf-vm.com[asdf] plugin for https://gitleaks.io[Gitleaks]. + +Git secret scanner. + +=== Contents + +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] + +=== Dependencies + +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] + +=== Install + +Plugin: + +[source,bash] +---- +asdf plugin add gitleaks https://github.com/hyperpolymath/asdf-gitleaks-plugin.git +---- + +gitleaks: + +[source,bash] +---- +# Show all installable versions +asdf list-all gitleaks + +# Install specific version +asdf install gitleaks latest + +# Set a version globally (in your ~/.tool-versions file) +asdf global gitleaks latest + +# Now gitleaks commands are available +gitleaks --version +---- + +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. + +=== Usage + +[source,bash] +---- +# List installed versions +asdf list gitleaks + +# Set local version for current directory +asdf local gitleaks + +# Uninstall a version +asdf uninstall gitleaks +---- + +=== Contributing + +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License + +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. + +''''' + +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-gitleaks-plugin/README.md b/asdf-gitleaks-plugin/README.md deleted file mode 100644 index 946db3a6..00000000 --- a/asdf-gitleaks-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-gitleaks - -[![Build](https://github.com/hyperpolymath/asdf-gitleaks-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-gitleaks-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-gitleaks-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-gitleaks-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Gitleaks](https://gitleaks.io). - -Git secret scanner. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add gitleaks https://github.com/hyperpolymath/asdf-gitleaks-plugin.git -``` - -gitleaks: - -```bash -# Show all installable versions -asdf list-all gitleaks - -# Install specific version -asdf install gitleaks latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global gitleaks latest - -# Now gitleaks commands are available -gitleaks --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list gitleaks - -# Set local version for current directory -asdf local gitleaks - -# Uninstall a version -asdf uninstall gitleaks -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-gitleaks-plugin/SECURITY.adoc b/asdf-gitleaks-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-gitleaks-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-gitleaks-plugin/SECURITY.md b/asdf-gitleaks-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-gitleaks-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-grype-plugin/CODE_OF_CONDUCT.adoc b/asdf-grype-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-grype-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-grype-plugin/CODE_OF_CONDUCT.md b/asdf-grype-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-grype-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-grype-plugin/CONTRIBUTING.adoc b/asdf-grype-plugin/CONTRIBUTING.adoc index d18532b5..a4cb53c3 100644 --- a/asdf-grype-plugin/CONTRIBUTING.adoc +++ b/asdf-grype-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-grype-plugin.git cd +asdf-grype-plugin -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-grype-plugin-dev toolbox enter asdf-grype-plugin-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-grype-plugin/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-grype-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-grype-plugin/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-grype-plugin/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-grype-plugin/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-grype-plugin/CONTRIBUTING.md b/asdf-grype-plugin/CONTRIBUTING.md deleted file mode 100644 index f0263d08..00000000 --- a/asdf-grype-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-grype-plugin.git -cd asdf-grype-plugin - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-grype-plugin-dev -toolbox enter asdf-grype-plugin-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-grype-plugin/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-grype-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-grype-plugin/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-grype-plugin/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-grype-plugin/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-grype-plugin/README.adoc b/asdf-grype-plugin/README.adoc new file mode 100644 index 00000000..3db2f688 --- /dev/null +++ b/asdf-grype-plugin/README.adoc @@ -0,0 +1,82 @@ +== asdf-grype + +https://github.com/hyperpolymath/asdf-grype-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-grype-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-grype-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-grype-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] + +https://asdf-vm.com[asdf] plugin for https://anchore.com/grype[Grype]. + +Container vulnerability scanner. + +=== Contents + +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] + +=== Dependencies + +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] + +=== Install + +Plugin: + +[source,bash] +---- +asdf plugin add grype https://github.com/hyperpolymath/asdf-grype-plugin.git +---- + +grype: + +[source,bash] +---- +# Show all installable versions +asdf list-all grype + +# Install specific version +asdf install grype latest + +# Set a version globally (in your ~/.tool-versions file) +asdf global grype latest + +# Now grype commands are available +grype --version +---- + +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. + +=== Usage + +[source,bash] +---- +# List installed versions +asdf list grype + +# Set local version for current directory +asdf local grype + +# Uninstall a version +asdf uninstall grype +---- + +=== Contributing + +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License + +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. + +''''' + +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-grype-plugin/README.md b/asdf-grype-plugin/README.md deleted file mode 100644 index 087a519a..00000000 --- a/asdf-grype-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-grype - -[![Build](https://github.com/hyperpolymath/asdf-grype-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-grype-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-grype-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-grype-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Grype](https://anchore.com/grype). - -Container vulnerability scanner. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add grype https://github.com/hyperpolymath/asdf-grype-plugin.git -``` - -grype: - -```bash -# Show all installable versions -asdf list-all grype - -# Install specific version -asdf install grype latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global grype latest - -# Now grype commands are available -grype --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list grype - -# Set local version for current directory -asdf local grype - -# Uninstall a version -asdf uninstall grype -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-grype-plugin/SECURITY.adoc b/asdf-grype-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-grype-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-grype-plugin/SECURITY.md b/asdf-grype-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-grype-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-haproxy-plugin/CODE_OF_CONDUCT.adoc b/asdf-haproxy-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-haproxy-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-haproxy-plugin/CODE_OF_CONDUCT.md b/asdf-haproxy-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-haproxy-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-haproxy-plugin/CONTRIBUTING.adoc b/asdf-haproxy-plugin/CONTRIBUTING.adoc index d18532b5..cac873a9 100644 --- a/asdf-haproxy-plugin/CONTRIBUTING.adoc +++ b/asdf-haproxy-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-haproxy-plugin.git cd +asdf-haproxy-plugin -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-haproxy-plugin-dev toolbox enter +asdf-haproxy-plugin-dev # Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-haproxy-plugin/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-haproxy-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-haproxy-plugin/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-haproxy-plugin/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-haproxy-plugin/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-haproxy-plugin/CONTRIBUTING.md b/asdf-haproxy-plugin/CONTRIBUTING.md deleted file mode 100644 index 42989f74..00000000 --- a/asdf-haproxy-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-haproxy-plugin.git -cd asdf-haproxy-plugin - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-haproxy-plugin-dev -toolbox enter asdf-haproxy-plugin-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-haproxy-plugin/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-haproxy-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-haproxy-plugin/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-haproxy-plugin/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-haproxy-plugin/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-haproxy-plugin/README.adoc b/asdf-haproxy-plugin/README.adoc new file mode 100644 index 00000000..7d6612ef --- /dev/null +++ b/asdf-haproxy-plugin/README.adoc @@ -0,0 +1,82 @@ +== asdf-haproxy + +https://github.com/hyperpolymath/asdf-haproxy-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-haproxy-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-haproxy-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-haproxy-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] + +https://asdf-vm.com[asdf] plugin for https://www.haproxy.org[HAProxy]. + +High-availability load balancer. + +=== Contents + +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] + +=== Dependencies + +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] + +=== Install + +Plugin: + +[source,bash] +---- +asdf plugin add haproxy https://github.com/hyperpolymath/asdf-haproxy-plugin.git +---- + +haproxy: + +[source,bash] +---- +# Show all installable versions +asdf list-all haproxy + +# Install specific version +asdf install haproxy latest + +# Set a version globally (in your ~/.tool-versions file) +asdf global haproxy latest + +# Now haproxy commands are available +haproxy --version +---- + +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. + +=== Usage + +[source,bash] +---- +# List installed versions +asdf list haproxy + +# Set local version for current directory +asdf local haproxy + +# Uninstall a version +asdf uninstall haproxy +---- + +=== Contributing + +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License + +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. + +''''' + +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-haproxy-plugin/README.md b/asdf-haproxy-plugin/README.md deleted file mode 100644 index 3f311310..00000000 --- a/asdf-haproxy-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-haproxy - -[![Build](https://github.com/hyperpolymath/asdf-haproxy-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-haproxy-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-haproxy-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-haproxy-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [HAProxy](https://www.haproxy.org). - -High-availability load balancer. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add haproxy https://github.com/hyperpolymath/asdf-haproxy-plugin.git -``` - -haproxy: - -```bash -# Show all installable versions -asdf list-all haproxy - -# Install specific version -asdf install haproxy latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global haproxy latest - -# Now haproxy commands are available -haproxy --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list haproxy - -# Set local version for current directory -asdf local haproxy - -# Uninstall a version -asdf uninstall haproxy -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-haproxy-plugin/SECURITY.adoc b/asdf-haproxy-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-haproxy-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-haproxy-plugin/SECURITY.md b/asdf-haproxy-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-haproxy-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-hashicorp-plugin/ABI-FFI-README.adoc b/asdf-hashicorp-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..31ce416d --- /dev/null +++ b/asdf-hashicorp-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== HASHICORP ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/hashicorp.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libhashicorp.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +hashicorp/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── hashicorp.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── hashicorp.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/hashicorp.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "hashicorp.h" + +int main() { + void* handle = hashicorp_init(); + if (!handle) return 1; + + int result = hashicorp_process(handle, 42); + if (result != 0) { + const char* err = hashicorp_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + hashicorp_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lhashicorp -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import HASHICORP.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "hashicorp")] +extern "C" { + fn hashicorp_init() -> *mut std::ffi::c_void; + fn hashicorp_free(handle: *mut std::ffi::c_void); + fn hashicorp_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = hashicorp_init(); + assert!(!handle.is_null()); + + let result = hashicorp_process(handle, 42); + assert_eq!(result, 0); + + hashicorp_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libhashicorp = "libhashicorp" + +function init() + handle = ccall((:hashicorp_init, libhashicorp), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:hashicorp_process, libhashicorp), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:hashicorp_free, libhashicorp), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/hashicorp.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-hashicorp-plugin/ABI-FFI-README.md b/asdf-hashicorp-plugin/ABI-FFI-README.md deleted file mode 100644 index 34629ce4..00000000 --- a/asdf-hashicorp-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# HASHICORP ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/hashicorp.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libhashicorp.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -hashicorp/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── hashicorp.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── hashicorp.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/hashicorp.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "hashicorp.h" - -int main() { - void* handle = hashicorp_init(); - if (!handle) return 1; - - int result = hashicorp_process(handle, 42); - if (result != 0) { - const char* err = hashicorp_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - hashicorp_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lhashicorp -L./zig-out/lib -``` - -### From Idris2 - -```idris -import HASHICORP.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "hashicorp")] -extern "C" { - fn hashicorp_init() -> *mut std::ffi::c_void; - fn hashicorp_free(handle: *mut std::ffi::c_void); - fn hashicorp_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = hashicorp_init(); - assert!(!handle.is_null()); - - let result = hashicorp_process(handle, 42); - assert_eq!(result, 0); - - hashicorp_free(handle); - } -} -``` - -### From Julia - -```julia -const libhashicorp = "libhashicorp" - -function init() - handle = ccall((:hashicorp_init, libhashicorp), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:hashicorp_process, libhashicorp), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:hashicorp_free, libhashicorp), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/hashicorp.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-hashicorp-plugin/CODE_OF_CONDUCT.adoc b/asdf-hashicorp-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-hashicorp-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-hashicorp-plugin/CODE_OF_CONDUCT.md b/asdf-hashicorp-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-hashicorp-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-hashicorp-plugin/CONTRIBUTING.adoc b/asdf-hashicorp-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-hashicorp-plugin/CONTRIBUTING.adoc +++ b/asdf-hashicorp-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-hashicorp-plugin/CONTRIBUTING.md b/asdf-hashicorp-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-hashicorp-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-hashicorp-plugin/README.adoc b/asdf-hashicorp-plugin/README.adoc index 47cca4cd..2b2871c6 100644 --- a/asdf-hashicorp-plugin/README.adoc +++ b/asdf-hashicorp-plugin/README.adoc @@ -1,60 +1,83 @@ -= asdf-hashicorp +== asdf-hashicorp -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] -:author: hyperpolymath -:url-asdf: https://asdf-vm.com -:url-repo: https://github.com/hyperpolymath/asdf-hashicorp-plugin +https://github.com/hyperpolymath/asdf-hashicorp-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-hashicorp-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-hashicorp-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-hashicorp-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -image:https://img.shields.io/github/license/hyperpolymath/asdf-hashicorp-plugin?style=flat-square[License,link=LICENSE] -image:https://img.shields.io/github/actions/workflow/status/hyperpolymath/asdf-hashicorp-plugin/ci.yml?branch=main&style=flat-square[Build Status,link={url-repo}/actions] +https://asdf-vm.com[asdf] plugin for https://www.hashicorp.com[HashiCorp +Tools]. -An {url-asdf}[asdf] plugin to manage all HashiCorp tools. +Terraform, Vault, Consul. -== Supported Tools +=== Contents -* **vault** - Secrets management -* **terraform** - Infrastructure as Code -* **consul** - Service mesh -* **nomad** - Workload orchestration -* **packer** - Image builder -* **vagrant** - Development environments -* **boundary** - Secure remote access -* **waypoint** - Application deployment -* **sentinel** - Policy as Code -* **consul-template** - Template rendering -* **envconsul** - Environment variables from Consul +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -== Installation +=== Dependencies -Add the plugin for each tool you need: +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] + +=== Install + +Plugin: [source,bash] ---- -# Add individual tools -asdf plugin add vault https://github.com/hyperpolymath/asdf-hashicorp-plugin.git -asdf plugin add terraform https://github.com/hyperpolymath/asdf-hashicorp-plugin.git -asdf plugin add consul https://github.com/hyperpolymath/asdf-hashicorp-plugin.git -asdf plugin add nomad https://github.com/hyperpolymath/asdf-hashicorp-plugin.git -asdf plugin add packer https://github.com/hyperpolymath/asdf-hashicorp-plugin.git +asdf plugin add hashicorp https://github.com/hyperpolymath/asdf-hashicorp-plugin.git ---- -== Usage +hashicorp: [source,bash] ---- -# List all available versions -asdf list all vault +# Show all installable versions +asdf list-all hashicorp + +# Install specific version +asdf install hashicorp latest + +# Set a version globally (in your ~/.tool-versions file) +asdf global hashicorp latest + +# Now hashicorp commands are available +hashicorp --version +---- + +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -# Install a specific version -asdf install vault 1.15.0 +=== Usage -# Install latest -asdf install terraform latest +[source,bash] +---- +# List installed versions +asdf list hashicorp -# Set global default -asdf global vault 1.15.0 +# Set local version for current directory +asdf local hashicorp + +# Uninstall a version +asdf uninstall hashicorp ---- -== License +=== Contributing + +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License + +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. + +''''' -SPDX-License-Identifier: CC-BY-SA-4.0 +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-hashicorp-plugin/README.md b/asdf-hashicorp-plugin/README.md deleted file mode 100644 index 74f93203..00000000 --- a/asdf-hashicorp-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-hashicorp - -[![Build](https://github.com/hyperpolymath/asdf-hashicorp-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-hashicorp-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-hashicorp-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-hashicorp-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [HashiCorp Tools](https://www.hashicorp.com). - -Terraform, Vault, Consul. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add hashicorp https://github.com/hyperpolymath/asdf-hashicorp-plugin.git -``` - -hashicorp: - -```bash -# Show all installable versions -asdf list-all hashicorp - -# Install specific version -asdf install hashicorp latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global hashicorp latest - -# Now hashicorp commands are available -hashicorp --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list hashicorp - -# Set local version for current directory -asdf local hashicorp - -# Uninstall a version -asdf uninstall hashicorp -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-hashicorp-plugin/SECURITY.adoc b/asdf-hashicorp-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-hashicorp-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-hashicorp-plugin/SECURITY.md b/asdf-hashicorp-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-hashicorp-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-httpd-plugin/ABI-FFI-README.adoc b/asdf-httpd-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..ed324584 --- /dev/null +++ b/asdf-httpd-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== HTTPD ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/httpd.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libhttpd.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +httpd/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── httpd.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── httpd.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/httpd.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "httpd.h" + +int main() { + void* handle = httpd_init(); + if (!handle) return 1; + + int result = httpd_process(handle, 42); + if (result != 0) { + const char* err = httpd_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + httpd_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lhttpd -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import HTTPD.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "httpd")] +extern "C" { + fn httpd_init() -> *mut std::ffi::c_void; + fn httpd_free(handle: *mut std::ffi::c_void); + fn httpd_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = httpd_init(); + assert!(!handle.is_null()); + + let result = httpd_process(handle, 42); + assert_eq!(result, 0); + + httpd_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libhttpd = "libhttpd" + +function init() + handle = ccall((:httpd_init, libhttpd), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:httpd_process, libhttpd), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:httpd_free, libhttpd), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/httpd.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-httpd-plugin/ABI-FFI-README.md b/asdf-httpd-plugin/ABI-FFI-README.md deleted file mode 100644 index 1201c275..00000000 --- a/asdf-httpd-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# HTTPD ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/httpd.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libhttpd.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -httpd/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── httpd.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── httpd.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/httpd.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "httpd.h" - -int main() { - void* handle = httpd_init(); - if (!handle) return 1; - - int result = httpd_process(handle, 42); - if (result != 0) { - const char* err = httpd_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - httpd_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lhttpd -L./zig-out/lib -``` - -### From Idris2 - -```idris -import HTTPD.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "httpd")] -extern "C" { - fn httpd_init() -> *mut std::ffi::c_void; - fn httpd_free(handle: *mut std::ffi::c_void); - fn httpd_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = httpd_init(); - assert!(!handle.is_null()); - - let result = httpd_process(handle, 42); - assert_eq!(result, 0); - - httpd_free(handle); - } -} -``` - -### From Julia - -```julia -const libhttpd = "libhttpd" - -function init() - handle = ccall((:httpd_init, libhttpd), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:httpd_process, libhttpd), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:httpd_free, libhttpd), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/httpd.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-httpd-plugin/CODE_OF_CONDUCT.adoc b/asdf-httpd-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-httpd-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-httpd-plugin/CODE_OF_CONDUCT.md b/asdf-httpd-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-httpd-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-httpd-plugin/CONTRIBUTING.adoc b/asdf-httpd-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-httpd-plugin/CONTRIBUTING.adoc +++ b/asdf-httpd-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-httpd-plugin/CONTRIBUTING.md b/asdf-httpd-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-httpd-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-httpd-plugin/README.adoc b/asdf-httpd-plugin/README.adoc index d08e1dd2..be6ffebb 100644 --- a/asdf-httpd-plugin/README.adoc +++ b/asdf-httpd-plugin/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-httpd -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-httpd-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-httpd-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-httpd-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-httpd-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://httpd.apache.org[Apache +HTTP Server]. -**All repos with foreign function interfaces MUST follow this standard:** +Web server. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add httpd https://github.com/hyperpolymath/asdf-httpd-plugin.git +---- -=== Web Projects +httpd: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all httpd -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install httpd latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global httpd latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now httpd commands are available +httpd --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list httpd -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local httpd -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall httpd ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-httpd-plugin/README.md b/asdf-httpd-plugin/README.md deleted file mode 100644 index 4fb07dda..00000000 --- a/asdf-httpd-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-httpd - -[![Build](https://github.com/hyperpolymath/asdf-httpd-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-httpd-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-httpd-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-httpd-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Apache HTTP Server](https://httpd.apache.org). - -Web server. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add httpd https://github.com/hyperpolymath/asdf-httpd-plugin.git -``` - -httpd: - -```bash -# Show all installable versions -asdf list-all httpd - -# Install specific version -asdf install httpd latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global httpd latest - -# Now httpd commands are available -httpd --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list httpd - -# Set local version for current directory -asdf local httpd - -# Uninstall a version -asdf uninstall httpd -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-httpd-plugin/SECURITY.adoc b/asdf-httpd-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-httpd-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-httpd-plugin/SECURITY.md b/asdf-httpd-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-httpd-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-influxdb-plugin/ABI-FFI-README.adoc b/asdf-influxdb-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..80f95c5c --- /dev/null +++ b/asdf-influxdb-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== INFLUXDB ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/influxdb.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libinfluxdb.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +influxdb/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── influxdb.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── influxdb.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/influxdb.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "influxdb.h" + +int main() { + void* handle = influxdb_init(); + if (!handle) return 1; + + int result = influxdb_process(handle, 42); + if (result != 0) { + const char* err = influxdb_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + influxdb_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -linfluxdb -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import INFLUXDB.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "influxdb")] +extern "C" { + fn influxdb_init() -> *mut std::ffi::c_void; + fn influxdb_free(handle: *mut std::ffi::c_void); + fn influxdb_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = influxdb_init(); + assert!(!handle.is_null()); + + let result = influxdb_process(handle, 42); + assert_eq!(result, 0); + + influxdb_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libinfluxdb = "libinfluxdb" + +function init() + handle = ccall((:influxdb_init, libinfluxdb), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:influxdb_process, libinfluxdb), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:influxdb_free, libinfluxdb), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/influxdb.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-influxdb-plugin/ABI-FFI-README.md b/asdf-influxdb-plugin/ABI-FFI-README.md deleted file mode 100644 index 776a116f..00000000 --- a/asdf-influxdb-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# INFLUXDB ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/influxdb.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libinfluxdb.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -influxdb/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── influxdb.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── influxdb.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/influxdb.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "influxdb.h" - -int main() { - void* handle = influxdb_init(); - if (!handle) return 1; - - int result = influxdb_process(handle, 42); - if (result != 0) { - const char* err = influxdb_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - influxdb_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -linfluxdb -L./zig-out/lib -``` - -### From Idris2 - -```idris -import INFLUXDB.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "influxdb")] -extern "C" { - fn influxdb_init() -> *mut std::ffi::c_void; - fn influxdb_free(handle: *mut std::ffi::c_void); - fn influxdb_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = influxdb_init(); - assert!(!handle.is_null()); - - let result = influxdb_process(handle, 42); - assert_eq!(result, 0); - - influxdb_free(handle); - } -} -``` - -### From Julia - -```julia -const libinfluxdb = "libinfluxdb" - -function init() - handle = ccall((:influxdb_init, libinfluxdb), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:influxdb_process, libinfluxdb), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:influxdb_free, libinfluxdb), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/influxdb.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-influxdb-plugin/CODE_OF_CONDUCT.adoc b/asdf-influxdb-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-influxdb-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-influxdb-plugin/CODE_OF_CONDUCT.md b/asdf-influxdb-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-influxdb-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-influxdb-plugin/CONTRIBUTING.adoc b/asdf-influxdb-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-influxdb-plugin/CONTRIBUTING.adoc +++ b/asdf-influxdb-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-influxdb-plugin/CONTRIBUTING.md b/asdf-influxdb-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-influxdb-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-influxdb-plugin/README.adoc b/asdf-influxdb-plugin/README.adoc index d08e1dd2..cb85c8e4 100644 --- a/asdf-influxdb-plugin/README.adoc +++ b/asdf-influxdb-plugin/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-influxdb -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-influxdb-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-influxdb-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-influxdb-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-influxdb-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://www.influxdata.com[InfluxDB]. -**All repos with foreign function interfaces MUST follow this standard:** +Time series database. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add influxdb https://github.com/hyperpolymath/asdf-influxdb-plugin.git +---- -=== Web Projects +influxdb: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all influxdb -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install influxdb latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global influxdb latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now influxdb commands are available +influxdb --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list influxdb -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local influxdb -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall influxdb ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-influxdb-plugin/README.md b/asdf-influxdb-plugin/README.md deleted file mode 100644 index e85372e0..00000000 --- a/asdf-influxdb-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-influxdb - -[![Build](https://github.com/hyperpolymath/asdf-influxdb-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-influxdb-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-influxdb-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-influxdb-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [InfluxDB](https://www.influxdata.com). - -Time series database. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add influxdb https://github.com/hyperpolymath/asdf-influxdb-plugin.git -``` - -influxdb: - -```bash -# Show all installable versions -asdf list-all influxdb - -# Install specific version -asdf install influxdb latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global influxdb latest - -# Now influxdb commands are available -influxdb --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list influxdb - -# Set local version for current directory -asdf local influxdb - -# Uninstall a version -asdf uninstall influxdb -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-influxdb-plugin/SECURITY.adoc b/asdf-influxdb-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-influxdb-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-influxdb-plugin/SECURITY.md b/asdf-influxdb-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-influxdb-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-kdl-fmt-plugin/ABI-FFI-README.adoc b/asdf-kdl-fmt-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..0ddb18a7 --- /dev/null +++ b/asdf-kdl-fmt-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== KDL_FMT ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/kdl-fmt.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libkdl-fmt.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +kdl-fmt/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── kdl-fmt.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── kdl-fmt.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/kdl-fmt.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "kdl-fmt.h" + +int main() { + void* handle = kdl-fmt_init(); + if (!handle) return 1; + + int result = kdl-fmt_process(handle, 42); + if (result != 0) { + const char* err = kdl-fmt_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + kdl-fmt_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lkdl-fmt -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import KDL_FMT.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "kdl-fmt")] +extern "C" { + fn kdl-fmt_init() -> *mut std::ffi::c_void; + fn kdl-fmt_free(handle: *mut std::ffi::c_void); + fn kdl-fmt_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = kdl-fmt_init(); + assert!(!handle.is_null()); + + let result = kdl-fmt_process(handle, 42); + assert_eq!(result, 0); + + kdl-fmt_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libkdl-fmt = "libkdl-fmt" + +function init() + handle = ccall((:kdl-fmt_init, libkdl-fmt), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:kdl-fmt_process, libkdl-fmt), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:kdl-fmt_free, libkdl-fmt), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/kdl-fmt.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-kdl-fmt-plugin/ABI-FFI-README.md b/asdf-kdl-fmt-plugin/ABI-FFI-README.md deleted file mode 100644 index ddfecda6..00000000 --- a/asdf-kdl-fmt-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# KDL_FMT ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/kdl-fmt.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libkdl-fmt.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -kdl-fmt/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── kdl-fmt.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── kdl-fmt.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/kdl-fmt.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "kdl-fmt.h" - -int main() { - void* handle = kdl-fmt_init(); - if (!handle) return 1; - - int result = kdl-fmt_process(handle, 42); - if (result != 0) { - const char* err = kdl-fmt_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - kdl-fmt_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lkdl-fmt -L./zig-out/lib -``` - -### From Idris2 - -```idris -import KDL_FMT.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "kdl-fmt")] -extern "C" { - fn kdl-fmt_init() -> *mut std::ffi::c_void; - fn kdl-fmt_free(handle: *mut std::ffi::c_void); - fn kdl-fmt_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = kdl-fmt_init(); - assert!(!handle.is_null()); - - let result = kdl-fmt_process(handle, 42); - assert_eq!(result, 0); - - kdl-fmt_free(handle); - } -} -``` - -### From Julia - -```julia -const libkdl-fmt = "libkdl-fmt" - -function init() - handle = ccall((:kdl-fmt_init, libkdl-fmt), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:kdl-fmt_process, libkdl-fmt), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:kdl-fmt_free, libkdl-fmt), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/kdl-fmt.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-kdl-fmt-plugin/CODE_OF_CONDUCT.adoc b/asdf-kdl-fmt-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-kdl-fmt-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-kdl-fmt-plugin/CODE_OF_CONDUCT.md b/asdf-kdl-fmt-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-kdl-fmt-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-kdl-fmt-plugin/CONTRIBUTING.adoc b/asdf-kdl-fmt-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-kdl-fmt-plugin/CONTRIBUTING.adoc +++ b/asdf-kdl-fmt-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-kdl-fmt-plugin/CONTRIBUTING.md b/asdf-kdl-fmt-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-kdl-fmt-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-kdl-fmt-plugin/README.adoc b/asdf-kdl-fmt-plugin/README.adoc index d08e1dd2..1bf9cbc8 100644 --- a/asdf-kdl-fmt-plugin/README.adoc +++ b/asdf-kdl-fmt-plugin/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-kdl-fmt -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-kdl-fmt-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-kdl-fmt-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-kdl-fmt-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-kdl-fmt-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://kdl.dev[kdl-fmt]. -**All repos with foreign function interfaces MUST follow this standard:** +KDL document formatter. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add kdl-fmt https://github.com/hyperpolymath/asdf-kdl-fmt-plugin.git +---- -=== Web Projects +kdl-fmt: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all kdl-fmt -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install kdl-fmt latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global kdl-fmt latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now kdl-fmt commands are available +kdl-fmt --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list kdl-fmt -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local kdl-fmt -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall kdl-fmt ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-kdl-fmt-plugin/README.md b/asdf-kdl-fmt-plugin/README.md deleted file mode 100644 index 2e1285d5..00000000 --- a/asdf-kdl-fmt-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-kdl-fmt - -[![Build](https://github.com/hyperpolymath/asdf-kdl-fmt-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-kdl-fmt-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-kdl-fmt-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-kdl-fmt-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [kdl-fmt](https://kdl.dev). - -KDL document formatter. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add kdl-fmt https://github.com/hyperpolymath/asdf-kdl-fmt-plugin.git -``` - -kdl-fmt: - -```bash -# Show all installable versions -asdf list-all kdl-fmt - -# Install specific version -asdf install kdl-fmt latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global kdl-fmt latest - -# Now kdl-fmt commands are available -kdl-fmt --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list kdl-fmt - -# Set local version for current directory -asdf local kdl-fmt - -# Uninstall a version -asdf uninstall kdl-fmt -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-kdl-fmt-plugin/SECURITY.adoc b/asdf-kdl-fmt-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-kdl-fmt-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-kdl-fmt-plugin/SECURITY.md b/asdf-kdl-fmt-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-kdl-fmt-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-lego-plugin/ABI-FFI-README.adoc b/asdf-lego-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..112425b2 --- /dev/null +++ b/asdf-lego-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== LEGO ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/lego.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to liblego.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +lego/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── lego.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── lego.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/lego.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "lego.h" + +int main() { + void* handle = lego_init(); + if (!handle) return 1; + + int result = lego_process(handle, 42); + if (result != 0) { + const char* err = lego_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + lego_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -llego -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import LEGO.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "lego")] +extern "C" { + fn lego_init() -> *mut std::ffi::c_void; + fn lego_free(handle: *mut std::ffi::c_void); + fn lego_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = lego_init(); + assert!(!handle.is_null()); + + let result = lego_process(handle, 42); + assert_eq!(result, 0); + + lego_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const liblego = "liblego" + +function init() + handle = ccall((:lego_init, liblego), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:lego_process, liblego), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:lego_free, liblego), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/lego.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-lego-plugin/ABI-FFI-README.md b/asdf-lego-plugin/ABI-FFI-README.md deleted file mode 100644 index 376d5f24..00000000 --- a/asdf-lego-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# LEGO ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/lego.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to liblego.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -lego/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── lego.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── lego.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/lego.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "lego.h" - -int main() { - void* handle = lego_init(); - if (!handle) return 1; - - int result = lego_process(handle, 42); - if (result != 0) { - const char* err = lego_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - lego_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -llego -L./zig-out/lib -``` - -### From Idris2 - -```idris -import LEGO.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "lego")] -extern "C" { - fn lego_init() -> *mut std::ffi::c_void; - fn lego_free(handle: *mut std::ffi::c_void); - fn lego_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = lego_init(); - assert!(!handle.is_null()); - - let result = lego_process(handle, 42); - assert_eq!(result, 0); - - lego_free(handle); - } -} -``` - -### From Julia - -```julia -const liblego = "liblego" - -function init() - handle = ccall((:lego_init, liblego), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:lego_process, liblego), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:lego_free, liblego), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/lego.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-lego-plugin/CODE_OF_CONDUCT.adoc b/asdf-lego-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-lego-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-lego-plugin/CODE_OF_CONDUCT.md b/asdf-lego-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-lego-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-lego-plugin/CONTRIBUTING.adoc b/asdf-lego-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-lego-plugin/CONTRIBUTING.adoc +++ b/asdf-lego-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-lego-plugin/CONTRIBUTING.md b/asdf-lego-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-lego-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-lego-plugin/README.adoc b/asdf-lego-plugin/README.adoc index d08e1dd2..d8e272b2 100644 --- a/asdf-lego-plugin/README.adoc +++ b/asdf-lego-plugin/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-lego -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-lego-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-lego-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-lego-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-lego-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://go-acme.github.io/lego[LEGO]. -**All repos with foreign function interfaces MUST follow this standard:** +ACME client. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add lego https://github.com/hyperpolymath/asdf-lego-plugin.git +---- -=== Web Projects +lego: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all lego -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install lego latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global lego latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now lego commands are available +lego --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list lego -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local lego -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall lego ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-lego-plugin/README.md b/asdf-lego-plugin/README.md deleted file mode 100644 index d7ce2aac..00000000 --- a/asdf-lego-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-lego - -[![Build](https://github.com/hyperpolymath/asdf-lego-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-lego-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-lego-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-lego-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [LEGO](https://go-acme.github.io/lego). - -ACME client. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add lego https://github.com/hyperpolymath/asdf-lego-plugin.git -``` - -lego: - -```bash -# Show all installable versions -asdf list-all lego - -# Install specific version -asdf install lego latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global lego latest - -# Now lego commands are available -lego --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list lego - -# Set local version for current directory -asdf local lego - -# Uninstall a version -asdf uninstall lego -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-lego-plugin/SECURITY.adoc b/asdf-lego-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-lego-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-lego-plugin/SECURITY.md b/asdf-lego-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-lego-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-linkerd-plugin/ABI-FFI-README.adoc b/asdf-linkerd-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..d504aefc --- /dev/null +++ b/asdf-linkerd-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== LINKERD ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/linkerd.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to liblinkerd.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +linkerd/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── linkerd.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── linkerd.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/linkerd.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "linkerd.h" + +int main() { + void* handle = linkerd_init(); + if (!handle) return 1; + + int result = linkerd_process(handle, 42); + if (result != 0) { + const char* err = linkerd_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + linkerd_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -llinkerd -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import LINKERD.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "linkerd")] +extern "C" { + fn linkerd_init() -> *mut std::ffi::c_void; + fn linkerd_free(handle: *mut std::ffi::c_void); + fn linkerd_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = linkerd_init(); + assert!(!handle.is_null()); + + let result = linkerd_process(handle, 42); + assert_eq!(result, 0); + + linkerd_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const liblinkerd = "liblinkerd" + +function init() + handle = ccall((:linkerd_init, liblinkerd), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:linkerd_process, liblinkerd), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:linkerd_free, liblinkerd), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/linkerd.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-linkerd-plugin/ABI-FFI-README.md b/asdf-linkerd-plugin/ABI-FFI-README.md deleted file mode 100644 index 5e32aabe..00000000 --- a/asdf-linkerd-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# LINKERD ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/linkerd.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to liblinkerd.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -linkerd/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── linkerd.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── linkerd.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/linkerd.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "linkerd.h" - -int main() { - void* handle = linkerd_init(); - if (!handle) return 1; - - int result = linkerd_process(handle, 42); - if (result != 0) { - const char* err = linkerd_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - linkerd_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -llinkerd -L./zig-out/lib -``` - -### From Idris2 - -```idris -import LINKERD.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "linkerd")] -extern "C" { - fn linkerd_init() -> *mut std::ffi::c_void; - fn linkerd_free(handle: *mut std::ffi::c_void); - fn linkerd_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = linkerd_init(); - assert!(!handle.is_null()); - - let result = linkerd_process(handle, 42); - assert_eq!(result, 0); - - linkerd_free(handle); - } -} -``` - -### From Julia - -```julia -const liblinkerd = "liblinkerd" - -function init() - handle = ccall((:linkerd_init, liblinkerd), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:linkerd_process, liblinkerd), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:linkerd_free, liblinkerd), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/linkerd.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-linkerd-plugin/CODE_OF_CONDUCT.adoc b/asdf-linkerd-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-linkerd-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-linkerd-plugin/CODE_OF_CONDUCT.md b/asdf-linkerd-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-linkerd-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-linkerd-plugin/CONTRIBUTING.adoc b/asdf-linkerd-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-linkerd-plugin/CONTRIBUTING.adoc +++ b/asdf-linkerd-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-linkerd-plugin/CONTRIBUTING.md b/asdf-linkerd-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-linkerd-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-linkerd-plugin/README.adoc b/asdf-linkerd-plugin/README.adoc index d08e1dd2..c4ba49db 100644 --- a/asdf-linkerd-plugin/README.adoc +++ b/asdf-linkerd-plugin/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-linkerd -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-linkerd-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-linkerd-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-linkerd-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-linkerd-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://linkerd.io[Linkerd CLI]. -**All repos with foreign function interfaces MUST follow this standard:** +Service mesh CLI. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add linkerd https://github.com/hyperpolymath/asdf-linkerd-plugin.git +---- -=== Web Projects +linkerd: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all linkerd -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install linkerd latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global linkerd latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now linkerd commands are available +linkerd --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list linkerd -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local linkerd -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall linkerd ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-linkerd-plugin/README.md b/asdf-linkerd-plugin/README.md deleted file mode 100644 index d715ecc8..00000000 --- a/asdf-linkerd-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-linkerd - -[![Build](https://github.com/hyperpolymath/asdf-linkerd-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-linkerd-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-linkerd-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-linkerd-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Linkerd CLI](https://linkerd.io). - -Service mesh CLI. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add linkerd https://github.com/hyperpolymath/asdf-linkerd-plugin.git -``` - -linkerd: - -```bash -# Show all installable versions -asdf list-all linkerd - -# Install specific version -asdf install linkerd latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global linkerd latest - -# Now linkerd commands are available -linkerd --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list linkerd - -# Set local version for current directory -asdf local linkerd - -# Uninstall a version -asdf uninstall linkerd -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-linkerd-plugin/SECURITY.adoc b/asdf-linkerd-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-linkerd-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-linkerd-plugin/SECURITY.md b/asdf-linkerd-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-linkerd-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-mariadb-plugin/ABI-FFI-README.adoc b/asdf-mariadb-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..9247cd3c --- /dev/null +++ b/asdf-mariadb-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== MARIADB ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/mariadb.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libmariadb.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +mariadb/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── mariadb.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── mariadb.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/mariadb.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "mariadb.h" + +int main() { + void* handle = mariadb_init(); + if (!handle) return 1; + + int result = mariadb_process(handle, 42); + if (result != 0) { + const char* err = mariadb_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + mariadb_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lmariadb -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import MARIADB.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "mariadb")] +extern "C" { + fn mariadb_init() -> *mut std::ffi::c_void; + fn mariadb_free(handle: *mut std::ffi::c_void); + fn mariadb_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = mariadb_init(); + assert!(!handle.is_null()); + + let result = mariadb_process(handle, 42); + assert_eq!(result, 0); + + mariadb_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libmariadb = "libmariadb" + +function init() + handle = ccall((:mariadb_init, libmariadb), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:mariadb_process, libmariadb), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:mariadb_free, libmariadb), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/mariadb.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-mariadb-plugin/ABI-FFI-README.md b/asdf-mariadb-plugin/ABI-FFI-README.md deleted file mode 100644 index 449dd815..00000000 --- a/asdf-mariadb-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# MARIADB ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/mariadb.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libmariadb.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -mariadb/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── mariadb.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── mariadb.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/mariadb.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "mariadb.h" - -int main() { - void* handle = mariadb_init(); - if (!handle) return 1; - - int result = mariadb_process(handle, 42); - if (result != 0) { - const char* err = mariadb_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - mariadb_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lmariadb -L./zig-out/lib -``` - -### From Idris2 - -```idris -import MARIADB.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "mariadb")] -extern "C" { - fn mariadb_init() -> *mut std::ffi::c_void; - fn mariadb_free(handle: *mut std::ffi::c_void); - fn mariadb_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = mariadb_init(); - assert!(!handle.is_null()); - - let result = mariadb_process(handle, 42); - assert_eq!(result, 0); - - mariadb_free(handle); - } -} -``` - -### From Julia - -```julia -const libmariadb = "libmariadb" - -function init() - handle = ccall((:mariadb_init, libmariadb), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:mariadb_process, libmariadb), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:mariadb_free, libmariadb), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/mariadb.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-mariadb-plugin/CODE_OF_CONDUCT.adoc b/asdf-mariadb-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-mariadb-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-mariadb-plugin/CODE_OF_CONDUCT.md b/asdf-mariadb-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-mariadb-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-mariadb-plugin/CONTRIBUTING.adoc b/asdf-mariadb-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-mariadb-plugin/CONTRIBUTING.adoc +++ b/asdf-mariadb-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-mariadb-plugin/CONTRIBUTING.md b/asdf-mariadb-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-mariadb-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-mariadb-plugin/README.adoc b/asdf-mariadb-plugin/README.adoc index d08e1dd2..3ab37418 100644 --- a/asdf-mariadb-plugin/README.adoc +++ b/asdf-mariadb-plugin/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-mariadb -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-mariadb-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-mariadb-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-mariadb-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-mariadb-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://mariadb.org[MariaDB]. -**All repos with foreign function interfaces MUST follow this standard:** +MySQL-compatible database. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add mariadb https://github.com/hyperpolymath/asdf-mariadb-plugin.git +---- -=== Web Projects +mariadb: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all mariadb -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install mariadb latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global mariadb latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now mariadb commands are available +mariadb --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list mariadb -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local mariadb -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall mariadb ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-mariadb-plugin/README.md b/asdf-mariadb-plugin/README.md deleted file mode 100644 index 212ede30..00000000 --- a/asdf-mariadb-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-mariadb - -[![Build](https://github.com/hyperpolymath/asdf-mariadb-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-mariadb-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-mariadb-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-mariadb-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [MariaDB](https://mariadb.org). - -MySQL-compatible database. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add mariadb https://github.com/hyperpolymath/asdf-mariadb-plugin.git -``` - -mariadb: - -```bash -# Show all installable versions -asdf list-all mariadb - -# Install specific version -asdf install mariadb latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global mariadb latest - -# Now mariadb commands are available -mariadb --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list mariadb - -# Set local version for current directory -asdf local mariadb - -# Uninstall a version -asdf uninstall mariadb -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-mariadb-plugin/SECURITY.adoc b/asdf-mariadb-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-mariadb-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-mariadb-plugin/SECURITY.md b/asdf-mariadb-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-mariadb-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-mdbook-plugin/ABI-FFI-README.adoc b/asdf-mdbook-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..1cc92c39 --- /dev/null +++ b/asdf-mdbook-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== MDBOOK ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/mdbook.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libmdbook.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +mdbook/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── mdbook.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── mdbook.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/mdbook.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "mdbook.h" + +int main() { + void* handle = mdbook_init(); + if (!handle) return 1; + + int result = mdbook_process(handle, 42); + if (result != 0) { + const char* err = mdbook_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + mdbook_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lmdbook -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import MDBOOK.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "mdbook")] +extern "C" { + fn mdbook_init() -> *mut std::ffi::c_void; + fn mdbook_free(handle: *mut std::ffi::c_void); + fn mdbook_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = mdbook_init(); + assert!(!handle.is_null()); + + let result = mdbook_process(handle, 42); + assert_eq!(result, 0); + + mdbook_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libmdbook = "libmdbook" + +function init() + handle = ccall((:mdbook_init, libmdbook), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:mdbook_process, libmdbook), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:mdbook_free, libmdbook), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/mdbook.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-mdbook-plugin/ABI-FFI-README.md b/asdf-mdbook-plugin/ABI-FFI-README.md deleted file mode 100644 index 0ec85b6b..00000000 --- a/asdf-mdbook-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# MDBOOK ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/mdbook.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libmdbook.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -mdbook/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── mdbook.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── mdbook.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/mdbook.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "mdbook.h" - -int main() { - void* handle = mdbook_init(); - if (!handle) return 1; - - int result = mdbook_process(handle, 42); - if (result != 0) { - const char* err = mdbook_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - mdbook_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lmdbook -L./zig-out/lib -``` - -### From Idris2 - -```idris -import MDBOOK.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "mdbook")] -extern "C" { - fn mdbook_init() -> *mut std::ffi::c_void; - fn mdbook_free(handle: *mut std::ffi::c_void); - fn mdbook_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = mdbook_init(); - assert!(!handle.is_null()); - - let result = mdbook_process(handle, 42); - assert_eq!(result, 0); - - mdbook_free(handle); - } -} -``` - -### From Julia - -```julia -const libmdbook = "libmdbook" - -function init() - handle = ccall((:mdbook_init, libmdbook), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:mdbook_process, libmdbook), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:mdbook_free, libmdbook), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/mdbook.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-mdbook-plugin/CODE_OF_CONDUCT.adoc b/asdf-mdbook-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-mdbook-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-mdbook-plugin/CODE_OF_CONDUCT.md b/asdf-mdbook-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-mdbook-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-mdbook-plugin/CONTRIBUTING.adoc b/asdf-mdbook-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-mdbook-plugin/CONTRIBUTING.adoc +++ b/asdf-mdbook-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-mdbook-plugin/CONTRIBUTING.md b/asdf-mdbook-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-mdbook-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-mdbook-plugin/README.adoc b/asdf-mdbook-plugin/README.adoc index d08e1dd2..ea6cde3e 100644 --- a/asdf-mdbook-plugin/README.adoc +++ b/asdf-mdbook-plugin/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-mdbook -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-mdbook-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-mdbook-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-mdbook-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-mdbook-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://rust-lang.github.io/mdBook[mdBook]. -**All repos with foreign function interfaces MUST follow this standard:** +Rust documentation tool. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add mdbook https://github.com/hyperpolymath/asdf-mdbook-plugin.git +---- -=== Web Projects +mdbook: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all mdbook -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install mdbook latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global mdbook latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now mdbook commands are available +mdbook --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list mdbook -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local mdbook -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall mdbook ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-mdbook-plugin/README.md b/asdf-mdbook-plugin/README.md deleted file mode 100644 index d30c58bb..00000000 --- a/asdf-mdbook-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-mdbook - -[![Build](https://github.com/hyperpolymath/asdf-mdbook-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-mdbook-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-mdbook-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-mdbook-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [mdBook](https://rust-lang.github.io/mdBook). - -Rust documentation tool. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add mdbook https://github.com/hyperpolymath/asdf-mdbook-plugin.git -``` - -mdbook: - -```bash -# Show all installable versions -asdf list-all mdbook - -# Install specific version -asdf install mdbook latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global mdbook latest - -# Now mdbook commands are available -mdbook --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list mdbook - -# Set local version for current directory -asdf local mdbook - -# Uninstall a version -asdf uninstall mdbook -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-mdbook-plugin/SECURITY.adoc b/asdf-mdbook-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-mdbook-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-mdbook-plugin/SECURITY.md b/asdf-mdbook-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-mdbook-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-melange-plugin/ABI-FFI-README.adoc b/asdf-melange-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..6d9dd689 --- /dev/null +++ b/asdf-melange-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== MELANGE ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/melange.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libmelange.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +melange/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── melange.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── melange.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/melange.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "melange.h" + +int main() { + void* handle = melange_init(); + if (!handle) return 1; + + int result = melange_process(handle, 42); + if (result != 0) { + const char* err = melange_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + melange_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lmelange -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import MELANGE.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "melange")] +extern "C" { + fn melange_init() -> *mut std::ffi::c_void; + fn melange_free(handle: *mut std::ffi::c_void); + fn melange_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = melange_init(); + assert!(!handle.is_null()); + + let result = melange_process(handle, 42); + assert_eq!(result, 0); + + melange_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libmelange = "libmelange" + +function init() + handle = ccall((:melange_init, libmelange), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:melange_process, libmelange), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:melange_free, libmelange), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/melange.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-melange-plugin/ABI-FFI-README.md b/asdf-melange-plugin/ABI-FFI-README.md deleted file mode 100644 index 6a925a4d..00000000 --- a/asdf-melange-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# MELANGE ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/melange.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libmelange.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -melange/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── melange.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── melange.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/melange.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "melange.h" - -int main() { - void* handle = melange_init(); - if (!handle) return 1; - - int result = melange_process(handle, 42); - if (result != 0) { - const char* err = melange_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - melange_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lmelange -L./zig-out/lib -``` - -### From Idris2 - -```idris -import MELANGE.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "melange")] -extern "C" { - fn melange_init() -> *mut std::ffi::c_void; - fn melange_free(handle: *mut std::ffi::c_void); - fn melange_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = melange_init(); - assert!(!handle.is_null()); - - let result = melange_process(handle, 42); - assert_eq!(result, 0); - - melange_free(handle); - } -} -``` - -### From Julia - -```julia -const libmelange = "libmelange" - -function init() - handle = ccall((:melange_init, libmelange), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:melange_process, libmelange), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:melange_free, libmelange), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/melange.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-melange-plugin/CODE_OF_CONDUCT.adoc b/asdf-melange-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-melange-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-melange-plugin/CODE_OF_CONDUCT.md b/asdf-melange-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-melange-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-melange-plugin/CONTRIBUTING.adoc b/asdf-melange-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-melange-plugin/CONTRIBUTING.adoc +++ b/asdf-melange-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-melange-plugin/CONTRIBUTING.md b/asdf-melange-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-melange-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-melange-plugin/README.adoc b/asdf-melange-plugin/README.adoc index d08e1dd2..f68195f2 100644 --- a/asdf-melange-plugin/README.adoc +++ b/asdf-melange-plugin/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-melange -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-melange-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-melange-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-melange-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-melange-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://github.com/chainguard-dev/melange[Melange]. -**All repos with foreign function interfaces MUST follow this standard:** +APK package builder. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add melange https://github.com/hyperpolymath/asdf-melange-plugin.git +---- -=== Web Projects +melange: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all melange -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install melange latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global melange latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now melange commands are available +melange --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list melange -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local melange -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall melange ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-melange-plugin/README.md b/asdf-melange-plugin/README.md deleted file mode 100644 index 5f6cc5aa..00000000 --- a/asdf-melange-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-melange - -[![Build](https://github.com/hyperpolymath/asdf-melange-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-melange-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-melange-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-melange-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Melange](https://github.com/chainguard-dev/melange). - -APK package builder. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add melange https://github.com/hyperpolymath/asdf-melange-plugin.git -``` - -melange: - -```bash -# Show all installable versions -asdf list-all melange - -# Install specific version -asdf install melange latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global melange latest - -# Now melange commands are available -melange --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list melange - -# Set local version for current directory -asdf local melange - -# Uninstall a version -asdf uninstall melange -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-melange-plugin/SECURITY.adoc b/asdf-melange-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-melange-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-melange-plugin/SECURITY.md b/asdf-melange-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-melange-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-metaiconic-plugin/ABI-FFI-README.adoc b/asdf-metaiconic-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..f3cd4789 --- /dev/null +++ b/asdf-metaiconic-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== METAICONIC ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/metaiconic.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libmetaiconic.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +metaiconic/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── metaiconic.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── metaiconic.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/metaiconic.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "metaiconic.h" + +int main() { + void* handle = metaiconic_init(); + if (!handle) return 1; + + int result = metaiconic_process(handle, 42); + if (result != 0) { + const char* err = metaiconic_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + metaiconic_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lmetaiconic -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import METAICONIC.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "metaiconic")] +extern "C" { + fn metaiconic_init() -> *mut std::ffi::c_void; + fn metaiconic_free(handle: *mut std::ffi::c_void); + fn metaiconic_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = metaiconic_init(); + assert!(!handle.is_null()); + + let result = metaiconic_process(handle, 42); + assert_eq!(result, 0); + + metaiconic_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libmetaiconic = "libmetaiconic" + +function init() + handle = ccall((:metaiconic_init, libmetaiconic), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:metaiconic_process, libmetaiconic), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:metaiconic_free, libmetaiconic), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/metaiconic.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-metaiconic-plugin/ABI-FFI-README.md b/asdf-metaiconic-plugin/ABI-FFI-README.md deleted file mode 100644 index 55307ef9..00000000 --- a/asdf-metaiconic-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# METAICONIC ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/metaiconic.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libmetaiconic.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -metaiconic/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── metaiconic.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── metaiconic.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/metaiconic.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "metaiconic.h" - -int main() { - void* handle = metaiconic_init(); - if (!handle) return 1; - - int result = metaiconic_process(handle, 42); - if (result != 0) { - const char* err = metaiconic_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - metaiconic_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lmetaiconic -L./zig-out/lib -``` - -### From Idris2 - -```idris -import METAICONIC.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "metaiconic")] -extern "C" { - fn metaiconic_init() -> *mut std::ffi::c_void; - fn metaiconic_free(handle: *mut std::ffi::c_void); - fn metaiconic_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = metaiconic_init(); - assert!(!handle.is_null()); - - let result = metaiconic_process(handle, 42); - assert_eq!(result, 0); - - metaiconic_free(handle); - } -} -``` - -### From Julia - -```julia -const libmetaiconic = "libmetaiconic" - -function init() - handle = ccall((:metaiconic_init, libmetaiconic), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:metaiconic_process, libmetaiconic), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:metaiconic_free, libmetaiconic), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/metaiconic.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-metaiconic-plugin/CODE_OF_CONDUCT.adoc b/asdf-metaiconic-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-metaiconic-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-metaiconic-plugin/CODE_OF_CONDUCT.md b/asdf-metaiconic-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-metaiconic-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-metaiconic-plugin/CONTRIBUTING.adoc b/asdf-metaiconic-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-metaiconic-plugin/CONTRIBUTING.adoc +++ b/asdf-metaiconic-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-metaiconic-plugin/CONTRIBUTING.md b/asdf-metaiconic-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-metaiconic-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-metaiconic-plugin/README.adoc b/asdf-metaiconic-plugin/README.adoc index b5c0dc4c..6edb4187 100644 --- a/asdf-metaiconic-plugin/README.adoc +++ b/asdf-metaiconic-plugin/README.adoc @@ -1,114 +1,52 @@ -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] -image:https://img.shields.io/badge/Philosophy-Palimpsest-indigo.svg[Palimpsest,link="https://github.com/hyperpolymath/palimpsest-license"] +== asdf-metaiconic-plugin +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] +image:https://img.shields.io/badge/Philosophy-Palimpsest-indigo.svg[Palimpsest,link="`https://github.com/hyperpolymath/palimpsest-license`"] -// SPDX-License-Identifier: CC-BY-SA-4.0 -= asdf-metaiconic-plugin +Central metadata registry and discovery layer for the +https://asdf-vm.com[asdf] plugin ecosystem. -:toc: macro -:toc-title: Contents -:toclevels: 3 -:icons: font +=== Overview -Unified metadata index and discovery layer for the hyperpolymath asdf plugin ecosystem. +`+asdf-metaiconic-plugin+` serves as the unified metadata index for 65+ +hyperpolymath asdf plugins: -toc::[] +* *Plugin discovery* - Search and browse available plugins +* *Category organization* - Tag-based classification +* *Icon/branding consistency* - SVG icons for all plugins +* *Quality metrics* - CI status aggregation -== Overview +=== Plugin Categories -**asdf-metaiconic-plugin** is the central metadata registry for 68+ asdf plugins in the hyperpolymath ecosystem. It provides: - -* Standardized plugin metadata schema -* Category and tag-based organization -* Plugin discovery and search -* Icon and branding consistency -* Quality metrics aggregation - -== Status - -[cols="1,3"] +[cols=",",options="header",] |=== -| Component | Status - -| Specification -| ✓ link:SPECIFICATION.adoc[Complete] - -| Registry Schema -| ✓ link:registry/plugins.yaml[Implemented] - -| Category Definitions -| ✓ link:registry/categories.yaml[Implemented] - -| Search CLI -| ⏳ Phase 2 - -| Icons -| ⏳ Phase 2 +|Category |Plugins +|Security |trivy, grype, syft, cosign, age, gitleaks, sops +|Databases |mysql, mariadb, cassandra, couchdb, neo4j, arangodb +|Configuration |nickel, dhall, cue, taplo, kdl-fmt +|Static Sites |zola, cobalt, mdbook, franklin, serum, pollen +|Containers |apko, melange, envoy, linkerd |=== -== Quick Start - -[source,bash] ----- -# Search for security plugins -asdf metaiconic search "vulnerability" - -# List all plugins by category -asdf metaiconic list --category security +=== Related Projects -# Get plugin info -asdf metaiconic info trivy ----- - -== Registry Structure - ----- -registry/ -├── plugins.yaml # Master plugin list (68+ entries) -├── categories.yaml # Category definitions (9 categories) -└── schemas/ # Validation schemas ----- - -== Categories - -[cols="1,2"] +[width="100%",cols="40%,60%",options="header",] |=== -| Category | Plugins +|Project |Relationship +|https://github.com/hyperpolymath/asdf-ui-plugin[asdf-ui-plugin] |Visual +consumer -| security | trivy, grype, syft, cosign, gitleaks, age, opa -| database | arangodb, mariadb, neo4j, cassandra, surrealdb -| config | nickel, dhall, cue, yq, taplo, bebop -| network | coredns, envoy, pomerium, linkerd -| crypto | step-ca, cfssl, lego, rekor, fulcio -| build | apko, melange, restic, borg, hashicorp -| language | ada, fortran, affinescript, ocaml, vlang -| ssg | casket-ssg, zola, cobalt, mdbook -| webserver | httpd, varnish, openlitespeed +|https://github.com/hyperpolymath/asdf-security-plugin[asdf-security-plugin] +|Security layer |=== -== Ecosystem Integration - -This plugin is consumed by: - -* **asdf-plugin-configurator** - CLI tool uses registry for search -* **asdf-ui-plugin** - Visual interface uses icons and metadata -* **asdf-control-tower** - Dashboard aggregates plugin status - -See link:ECOSYSTEM.scm[ECOSYSTEM.scm] for full integration map. - -== Infrastructure - -* Multi-forge mirroring (GitHub → GitLab, Codeberg, Bitbucket) -* Instant sync propagation on push/release -* AI assistant configuration (`.claude/CLAUDE.md`) - -== Links +=== License -* link:SPECIFICATION.adoc[Full Specification] -* link:registry/plugins.yaml[Plugin Registry] -* https://github.com/hyperpolymath/asdf-control-tower[Control Tower] -* https://github.com/hyperpolymath/asdf-plugin-configurator[Configurator CLI] +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -== License +''''' -MPL-2.0 +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-metaiconic-plugin/README.md b/asdf-metaiconic-plugin/README.md deleted file mode 100644 index ed9cd4cd..00000000 --- a/asdf-metaiconic-plugin/README.md +++ /dev/null @@ -1,40 +0,0 @@ -# asdf-metaiconic-plugin - -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] -image:https://img.shields.io/badge/Philosophy-Palimpsest-indigo.svg[Palimpsest,link="https://github.com/hyperpolymath/palimpsest-license"] - -Central metadata registry and discovery layer for the [asdf](https://asdf-vm.com) plugin ecosystem. - -## Overview - -`asdf-metaiconic-plugin` serves as the unified metadata index for 65+ hyperpolymath asdf plugins: - -- **Plugin discovery** - Search and browse available plugins -- **Category organization** - Tag-based classification -- **Icon/branding consistency** - SVG icons for all plugins -- **Quality metrics** - CI status aggregation - -## Plugin Categories - -| Category | Plugins | -|----------|---------| -| Security | trivy, grype, syft, cosign, age, gitleaks, sops | -| Databases | mysql, mariadb, cassandra, couchdb, neo4j, arangodb | -| Configuration | nickel, dhall, cue, taplo, kdl-fmt | -| Static Sites | zola, cobalt, mdbook, franklin, serum, pollen | -| Containers | apko, melange, envoy, linkerd | - -## Related Projects - -| Project | Relationship | -|---------|--------------| -| [asdf-ui-plugin](https://github.com/hyperpolymath/asdf-ui-plugin) | Visual consumer | -| [asdf-security-plugin](https://github.com/hyperpolymath/asdf-security-plugin) | Security layer | - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-metaiconic-plugin/SECURITY.adoc b/asdf-metaiconic-plugin/SECURITY.adoc new file mode 100644 index 00000000..6833c545 --- /dev/null +++ b/asdf-metaiconic-plugin/SECURITY.adoc @@ -0,0 +1,378 @@ +Security Policy + +We take security seriously. We appreciate your efforts to responsibly +disclose vulnerabilities and will make every effort to acknowledge your +contributions. Table of Contents + +.... +Reporting a Vulnerability +What to Include +Response Timeline +Disclosure Policy +Scope +Safe Harbour +Recognition +Security Updates +Security Best Practices +.... + +Reporting a Vulnerability Preferred Method: GitHub Security Advisories + +The preferred method for reporting security vulnerabilities is through +GitHub’s Security Advisory feature: + +.... +Navigate to Report a Vulnerability +Click "Report a vulnerability" +Complete the form with as much detail as possible +Submit — we'll receive a private notification +.... + +This method ensures: + +.... +End-to-end encryption of your report +Private discussion space for collaboration +Coordinated disclosure tooling +Automatic credit when the advisory is published +.... + +Alternative: Encrypted Email + +If you cannot use GitHub Security Advisories, you may email us directly: + +Email security@hyperpolymath.org PGP Key Download Public Key Fingerprint +See GPG key + +== Import our PGP key + +curl -sSL https://hyperpolymath.org/gpg/security.asc | gpg –import + +== Verify fingerprint + +gpg –fingerprint security@hyperpolymath.org + +== Encrypt your report + +gpg –armor –encrypt –recipient security@hyperpolymath.org report.txt + +.... +⚠️ Important: Do not report security vulnerabilities through public GitHub issues, pull requests, discussions, or social media. +.... + +What to Include + +A good vulnerability report helps us understand and reproduce the issue +quickly. Required Information + +.... +Description: Clear explanation of the vulnerability +Impact: What an attacker could achieve (confidentiality, integrity, availability) +Affected versions: Which versions/commits are affected +Reproduction steps: Detailed steps to reproduce the issue +.... + +Helpful Additional Information + +.... +Proof of concept: Code, scripts, or screenshots demonstrating the vulnerability +Attack scenario: Realistic attack scenario showing exploitability +CVSS score: Your assessment of severity (use CVSS 3.1 Calculator) +CWE ID: Common Weakness Enumeration identifier if known +Suggested fix: If you have ideas for remediation +References: Links to related vulnerabilities, research, or advisories +.... + +Example Report Structure + +=== Summary + +{empty}[One-sentence description of the vulnerability] + +=== Vulnerability Type + +{empty}[e.g., SQL Injection, XSS, SSRF, Path Traversal, etc.] + +=== Affected Component + +{empty}[File path, function name, API endpoint, etc.] + +=== Affected Versions + +{empty}[Version range or specific commits] + +=== Severity Assessment + +* CVSS 3.1 Score: [X.X] +* CVSS Vector: [CVSS:3.1/AV:X/AC:X/PR:X/UI:X/S:X/C:X/I:X/A:X] + +=== Description + +{empty}[Detailed technical description] + +=== Steps to Reproduce + +[arabic] +. [First step] +. [Second step] +. […] + +=== Proof of Concept + +{empty}[Code, curl commands, screenshots, etc.] + +=== Impact + +{empty}[What can an attacker achieve?] + +=== Suggested Remediation + +{empty}[Optional: your ideas for fixing] + +=== References + +{empty}[Links to related issues, CVEs, research] + +Response Timeline + +We commit to the following response times: Stage Timeframe Description +Initial Response 48 hours We acknowledge receipt and confirm we’re +investigating Triage 7 days We assess severity, confirm the +vulnerability, and estimate timeline Status Update Every 7 days Regular +updates on remediation progress Resolution 90 days Target for fix +development and release (complex issues may take longer) Disclosure 90 +days Public disclosure after fix is available (coordinated with you) + +.... +Note: These are targets, not guarantees. Complex vulnerabilities may require more time. We'll communicate openly about any delays. +.... + +Disclosure Policy + +We follow coordinated disclosure (also known as responsible disclosure): + +.... +You report the vulnerability privately +We acknowledge and begin investigation +We develop a fix and prepare a release +We coordinate disclosure timing with you +We publish security advisory and fix simultaneously +You may publish your research after disclosure +.... + +Our Commitments + +.... +We will not take legal action against researchers who follow this policy +We will work with you to understand and resolve the issue +We will credit you in the security advisory (unless you prefer anonymity) +We will notify you before public disclosure +We will publish advisories with sufficient detail for users to assess risk +.... + +Your Commitments + +.... +Report vulnerabilities promptly after discovery +Give us reasonable time to address the issue before disclosure +Do not access, modify, or delete data beyond what's necessary to demonstrate the vulnerability +Do not degrade service availability (no DoS testing on production) +Do not share vulnerability details with others until coordinated disclosure +.... + +Disclosure Timeline + +Day 0 You report vulnerability Day 1-2 We acknowledge receipt Day 7 We +confirm vulnerability and share initial assessment Day 7-90 We develop +and test fix Day 90 Coordinated public disclosure (earlier if fix is +ready; later by mutual agreement) + +If we cannot reach agreement on disclosure timing, we default to 90 days +from your initial report. Scope In Scope ✅ + +The following are within scope for security research: + +.... +This repository (hyperpolymath/terrapin-ssg) and all its code +Official releases and packages published from this repository +Documentation that could lead to security issues +Build and deployment configurations in this repository +Dependencies (report here, we'll coordinate with upstream) +.... + +Out of Scope ❌ + +The following are not in scope: + +.... +Third-party services we integrate with (report directly to them) +Social engineering attacks against maintainers +Physical security +Denial of service attacks against production infrastructure +Spam, phishing, or other non-technical attacks +Issues already reported or publicly known +Theoretical vulnerabilities without proof of concept +.... + +Qualifying Vulnerabilities + +We’re particularly interested in: + +.... +Remote code execution +SQL injection, command injection, code injection +Authentication/authorisation bypass +Cross-site scripting (XSS) and cross-site request forgery (CSRF) +Server-side request forgery (SSRF) +Path traversal / local file inclusion +Information disclosure (credentials, PII, secrets) +Cryptographic weaknesses +Deserialisation vulnerabilities +Memory safety issues (buffer overflows, use-after-free, etc.) +Supply chain vulnerabilities (dependency confusion, etc.) +Significant logic flaws +.... + +Non-Qualifying Issues + +The following generally do not qualify as security vulnerabilities: + +.... +Missing security headers on non-sensitive pages +Clickjacking on pages without sensitive actions +Self-XSS (requires victim to paste code) +Missing rate limiting (unless it enables a specific attack) +Username/email enumeration (unless high-risk context) +Missing cookie flags on non-sensitive cookies +Software version disclosure +Verbose error messages (unless exposing secrets) +Best practice deviations without demonstrable impact +.... + +Safe Harbour + +We support security research conducted in good faith. Our Promise + +If you conduct security research in accordance with this policy: + +.... +✅ We will not initiate legal action against you +✅ We will not report your activity to law enforcement +✅ We will work with you in good faith to resolve issues +✅ We consider your research authorised under the Computer Fraud and Abuse Act (CFAA), UK Computer Misuse Act, and similar laws +✅ We waive any potential claim against you for circumvention of security controls +.... + +Good Faith Requirements + +To qualify for safe harbour, you must: + +.... +Comply with this security policy +Report vulnerabilities promptly +Avoid privacy violations (do not access others' data) +Avoid service degradation (no destructive testing) +Not exploit vulnerabilities beyond proof-of-concept +Not use vulnerabilities for profit (beyond bug bounties where offered) + +⚠️ Important: This safe harbour does not extend to third-party systems. Always check their policies before testing. +.... + +Recognition + +We believe in recognising security researchers who help us improve. Hall +of Fame + +Researchers who report valid vulnerabilities will be acknowledged in our +Security Acknowledgments (unless they prefer anonymity). + +Recognition includes: + +.... +Your name (or chosen alias) +Link to your website/profile (optional) +Brief description of the vulnerability class +Date of report +.... + +What We Offer + +.... +✅ Public credit in security advisories +✅ Acknowledgment in release notes +✅ Entry in our Hall of Fame +✅ Reference/recommendation letter upon request (for significant findings) +.... + +What We Don’t Currently Offer + +.... +❌ Monetary bug bounties +❌ Hardware or swag +❌ Paid security research contracts + +Note: We're a community project with limited resources. Your contributions help everyone who uses this software. +.... + +Security Updates Receiving Updates + +To stay informed about security updates: + +.... +Watch this repository: Click "Watch" → "Custom" → Select "Security alerts" +GitHub Security Advisories: Published at Security Advisories +Release notes: Security fixes noted in CHANGELOG +.... + +Update Policy Severity Response Critical/High Patch release as soon as +fix is ready Medium Included in next scheduled release (or earlier) Low +Included in next scheduled release Supported Versions Version Supported +Notes main branch ✅ Yes Latest development Latest release ✅ Yes +Current stable Previous minor release ✅ Yes Security fixes backported +Older versions ❌ No Please upgrade Security Best Practices + +When using terrapin-ssg, we recommend: General + +.... +Keep dependencies up to date +Use the latest stable release +Subscribe to security notifications +Review configuration against security documentation +Follow principle of least privilege +.... + +For Contributors + +.... +Never commit secrets, credentials, or API keys +Use signed commits (git config commit.gpgsign true) +Review dependencies before adding them +Run security linters locally before pushing +Report any concerns about existing code +.... + +Additional Resources + +.... +Our PGP Public Key +Security Advisories +Changelog +Contributing Guidelines +CVE Database +CVSS Calculator +.... + +Contact Purpose Contact Security issues Report via GitHub or +security@hyperpolymath.org General questions GitHub Discussions Other +enquiries See README for contact information Policy Changes + +This security policy may be updated from time to time. Significant +changes will be: + +.... +Committed to this repository with a clear commit message +Noted in the changelog +Announced via GitHub Discussions (for major changes) +.... + +Thank you for helping keep terrapin-ssg and its users safe. diff --git a/asdf-metaiconic-plugin/SECURITY.md b/asdf-metaiconic-plugin/SECURITY.md deleted file mode 100644 index 5eb5e20d..00000000 --- a/asdf-metaiconic-plugin/SECURITY.md +++ /dev/null @@ -1,328 +0,0 @@ -Security Policy - -We take security seriously. We appreciate your efforts to responsibly disclose vulnerabilities and will make every effort to acknowledge your contributions. -Table of Contents - - Reporting a Vulnerability - What to Include - Response Timeline - Disclosure Policy - Scope - Safe Harbour - Recognition - Security Updates - Security Best Practices - -Reporting a Vulnerability -Preferred Method: GitHub Security Advisories - -The preferred method for reporting security vulnerabilities is through GitHub's Security Advisory feature: - - Navigate to Report a Vulnerability - Click "Report a vulnerability" - Complete the form with as much detail as possible - Submit — we'll receive a private notification - -This method ensures: - - End-to-end encryption of your report - Private discussion space for collaboration - Coordinated disclosure tooling - Automatic credit when the advisory is published - -Alternative: Encrypted Email - -If you cannot use GitHub Security Advisories, you may email us directly: - -Email security@hyperpolymath.org -PGP Key Download Public Key -Fingerprint See GPG key - -# Import our PGP key -curl -sSL https://hyperpolymath.org/gpg/security.asc | gpg --import - -# Verify fingerprint -gpg --fingerprint security@hyperpolymath.org - -# Encrypt your report -gpg --armor --encrypt --recipient security@hyperpolymath.org report.txt - - ⚠️ Important: Do not report security vulnerabilities through public GitHub issues, pull requests, discussions, or social media. - -What to Include - -A good vulnerability report helps us understand and reproduce the issue quickly. -Required Information - - Description: Clear explanation of the vulnerability - Impact: What an attacker could achieve (confidentiality, integrity, availability) - Affected versions: Which versions/commits are affected - Reproduction steps: Detailed steps to reproduce the issue - -Helpful Additional Information - - Proof of concept: Code, scripts, or screenshots demonstrating the vulnerability - Attack scenario: Realistic attack scenario showing exploitability - CVSS score: Your assessment of severity (use CVSS 3.1 Calculator) - CWE ID: Common Weakness Enumeration identifier if known - Suggested fix: If you have ideas for remediation - References: Links to related vulnerabilities, research, or advisories - -Example Report Structure - -## Summary -[One-sentence description of the vulnerability] - -## Vulnerability Type -[e.g., SQL Injection, XSS, SSRF, Path Traversal, etc.] - -## Affected Component -[File path, function name, API endpoint, etc.] - -## Affected Versions -[Version range or specific commits] - -## Severity Assessment -- CVSS 3.1 Score: [X.X] -- CVSS Vector: [CVSS:3.1/AV:X/AC:X/PR:X/UI:X/S:X/C:X/I:X/A:X] - -## Description -[Detailed technical description] - -## Steps to Reproduce -1. [First step] -2. [Second step] -3. [...] - -## Proof of Concept -[Code, curl commands, screenshots, etc.] - -## Impact -[What can an attacker achieve?] - -## Suggested Remediation -[Optional: your ideas for fixing] - -## References -[Links to related issues, CVEs, research] - -Response Timeline - -We commit to the following response times: -Stage Timeframe Description -Initial Response 48 hours We acknowledge receipt and confirm we're investigating -Triage 7 days We assess severity, confirm the vulnerability, and estimate timeline -Status Update Every 7 days Regular updates on remediation progress -Resolution 90 days Target for fix development and release (complex issues may take longer) -Disclosure 90 days Public disclosure after fix is available (coordinated with you) - - Note: These are targets, not guarantees. Complex vulnerabilities may require more time. We'll communicate openly about any delays. - -Disclosure Policy - -We follow coordinated disclosure (also known as responsible disclosure): - - You report the vulnerability privately - We acknowledge and begin investigation - We develop a fix and prepare a release - We coordinate disclosure timing with you - We publish security advisory and fix simultaneously - You may publish your research after disclosure - -Our Commitments - - We will not take legal action against researchers who follow this policy - We will work with you to understand and resolve the issue - We will credit you in the security advisory (unless you prefer anonymity) - We will notify you before public disclosure - We will publish advisories with sufficient detail for users to assess risk - -Your Commitments - - Report vulnerabilities promptly after discovery - Give us reasonable time to address the issue before disclosure - Do not access, modify, or delete data beyond what's necessary to demonstrate the vulnerability - Do not degrade service availability (no DoS testing on production) - Do not share vulnerability details with others until coordinated disclosure - -Disclosure Timeline - -Day 0 You report vulnerability -Day 1-2 We acknowledge receipt -Day 7 We confirm vulnerability and share initial assessment -Day 7-90 We develop and test fix -Day 90 Coordinated public disclosure - (earlier if fix is ready; later by mutual agreement) - -If we cannot reach agreement on disclosure timing, we default to 90 days from your initial report. -Scope -In Scope ✅ - -The following are within scope for security research: - - This repository (hyperpolymath/terrapin-ssg) and all its code - Official releases and packages published from this repository - Documentation that could lead to security issues - Build and deployment configurations in this repository - Dependencies (report here, we'll coordinate with upstream) - -Out of Scope ❌ - -The following are not in scope: - - Third-party services we integrate with (report directly to them) - Social engineering attacks against maintainers - Physical security - Denial of service attacks against production infrastructure - Spam, phishing, or other non-technical attacks - Issues already reported or publicly known - Theoretical vulnerabilities without proof of concept - -Qualifying Vulnerabilities - -We're particularly interested in: - - Remote code execution - SQL injection, command injection, code injection - Authentication/authorisation bypass - Cross-site scripting (XSS) and cross-site request forgery (CSRF) - Server-side request forgery (SSRF) - Path traversal / local file inclusion - Information disclosure (credentials, PII, secrets) - Cryptographic weaknesses - Deserialisation vulnerabilities - Memory safety issues (buffer overflows, use-after-free, etc.) - Supply chain vulnerabilities (dependency confusion, etc.) - Significant logic flaws - -Non-Qualifying Issues - -The following generally do not qualify as security vulnerabilities: - - Missing security headers on non-sensitive pages - Clickjacking on pages without sensitive actions - Self-XSS (requires victim to paste code) - Missing rate limiting (unless it enables a specific attack) - Username/email enumeration (unless high-risk context) - Missing cookie flags on non-sensitive cookies - Software version disclosure - Verbose error messages (unless exposing secrets) - Best practice deviations without demonstrable impact - -Safe Harbour - -We support security research conducted in good faith. -Our Promise - -If you conduct security research in accordance with this policy: - - ✅ We will not initiate legal action against you - ✅ We will not report your activity to law enforcement - ✅ We will work with you in good faith to resolve issues - ✅ We consider your research authorised under the Computer Fraud and Abuse Act (CFAA), UK Computer Misuse Act, and similar laws - ✅ We waive any potential claim against you for circumvention of security controls - -Good Faith Requirements - -To qualify for safe harbour, you must: - - Comply with this security policy - Report vulnerabilities promptly - Avoid privacy violations (do not access others' data) - Avoid service degradation (no destructive testing) - Not exploit vulnerabilities beyond proof-of-concept - Not use vulnerabilities for profit (beyond bug bounties where offered) - - ⚠️ Important: This safe harbour does not extend to third-party systems. Always check their policies before testing. - -Recognition - -We believe in recognising security researchers who help us improve. -Hall of Fame - -Researchers who report valid vulnerabilities will be acknowledged in our Security Acknowledgments (unless they prefer anonymity). - -Recognition includes: - - Your name (or chosen alias) - Link to your website/profile (optional) - Brief description of the vulnerability class - Date of report - -What We Offer - - ✅ Public credit in security advisories - ✅ Acknowledgment in release notes - ✅ Entry in our Hall of Fame - ✅ Reference/recommendation letter upon request (for significant findings) - -What We Don't Currently Offer - - ❌ Monetary bug bounties - ❌ Hardware or swag - ❌ Paid security research contracts - - Note: We're a community project with limited resources. Your contributions help everyone who uses this software. - -Security Updates -Receiving Updates - -To stay informed about security updates: - - Watch this repository: Click "Watch" → "Custom" → Select "Security alerts" - GitHub Security Advisories: Published at Security Advisories - Release notes: Security fixes noted in CHANGELOG - -Update Policy -Severity Response -Critical/High Patch release as soon as fix is ready -Medium Included in next scheduled release (or earlier) -Low Included in next scheduled release -Supported Versions -Version Supported Notes -main branch ✅ Yes Latest development -Latest release ✅ Yes Current stable -Previous minor release ✅ Yes Security fixes backported -Older versions ❌ No Please upgrade -Security Best Practices - -When using terrapin-ssg, we recommend: -General - - Keep dependencies up to date - Use the latest stable release - Subscribe to security notifications - Review configuration against security documentation - Follow principle of least privilege - -For Contributors - - Never commit secrets, credentials, or API keys - Use signed commits (git config commit.gpgsign true) - Review dependencies before adding them - Run security linters locally before pushing - Report any concerns about existing code - -Additional Resources - - Our PGP Public Key - Security Advisories - Changelog - Contributing Guidelines - CVE Database - CVSS Calculator - -Contact -Purpose Contact -Security issues Report via GitHub or security@hyperpolymath.org -General questions GitHub Discussions -Other enquiries See README for contact information -Policy Changes - -This security policy may be updated from time to time. Significant changes will be: - - Committed to this repository with a clear commit message - Noted in the changelog - Announced via GitHub Discussions (for major changes) - -Thank you for helping keep terrapin-ssg and its users safe. diff --git a/asdf-mysql-plugin/ABI-FFI-README.adoc b/asdf-mysql-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..3c44c4c3 --- /dev/null +++ b/asdf-mysql-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== MYSQL ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/mysql.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libmysql.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +mysql/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── mysql.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── mysql.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/mysql.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "mysql.h" + +int main() { + void* handle = mysql_init(); + if (!handle) return 1; + + int result = mysql_process(handle, 42); + if (result != 0) { + const char* err = mysql_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + mysql_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lmysql -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import MYSQL.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "mysql")] +extern "C" { + fn mysql_init() -> *mut std::ffi::c_void; + fn mysql_free(handle: *mut std::ffi::c_void); + fn mysql_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = mysql_init(); + assert!(!handle.is_null()); + + let result = mysql_process(handle, 42); + assert_eq!(result, 0); + + mysql_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libmysql = "libmysql" + +function init() + handle = ccall((:mysql_init, libmysql), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:mysql_process, libmysql), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:mysql_free, libmysql), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/mysql.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-mysql-plugin/ABI-FFI-README.md b/asdf-mysql-plugin/ABI-FFI-README.md deleted file mode 100644 index 6b5cae94..00000000 --- a/asdf-mysql-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# MYSQL ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/mysql.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libmysql.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -mysql/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── mysql.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── mysql.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/mysql.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "mysql.h" - -int main() { - void* handle = mysql_init(); - if (!handle) return 1; - - int result = mysql_process(handle, 42); - if (result != 0) { - const char* err = mysql_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - mysql_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lmysql -L./zig-out/lib -``` - -### From Idris2 - -```idris -import MYSQL.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "mysql")] -extern "C" { - fn mysql_init() -> *mut std::ffi::c_void; - fn mysql_free(handle: *mut std::ffi::c_void); - fn mysql_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = mysql_init(); - assert!(!handle.is_null()); - - let result = mysql_process(handle, 42); - assert_eq!(result, 0); - - mysql_free(handle); - } -} -``` - -### From Julia - -```julia -const libmysql = "libmysql" - -function init() - handle = ccall((:mysql_init, libmysql), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:mysql_process, libmysql), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:mysql_free, libmysql), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/mysql.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-mysql-plugin/CODE_OF_CONDUCT.adoc b/asdf-mysql-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-mysql-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-mysql-plugin/CODE_OF_CONDUCT.md b/asdf-mysql-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-mysql-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-mysql-plugin/CONTRIBUTING.adoc b/asdf-mysql-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-mysql-plugin/CONTRIBUTING.adoc +++ b/asdf-mysql-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-mysql-plugin/CONTRIBUTING.md b/asdf-mysql-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-mysql-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-mysql-plugin/README.adoc b/asdf-mysql-plugin/README.adoc index d08e1dd2..fada33ed 100644 --- a/asdf-mysql-plugin/README.adoc +++ b/asdf-mysql-plugin/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-mysql -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-mysql-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-mysql-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-mysql-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-mysql-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://www.mysql.com[MySQL]. -**All repos with foreign function interfaces MUST follow this standard:** +Relational database. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add mysql https://github.com/hyperpolymath/asdf-mysql-plugin.git +---- -=== Web Projects +mysql: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all mysql -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install mysql latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global mysql latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now mysql commands are available +mysql --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list mysql -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local mysql -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall mysql ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-mysql-plugin/README.md b/asdf-mysql-plugin/README.md deleted file mode 100644 index b23513f5..00000000 --- a/asdf-mysql-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-mysql - -[![Build](https://github.com/hyperpolymath/asdf-mysql-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-mysql-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-mysql-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-mysql-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [MySQL](https://www.mysql.com). - -Relational database. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add mysql https://github.com/hyperpolymath/asdf-mysql-plugin.git -``` - -mysql: - -```bash -# Show all installable versions -asdf list-all mysql - -# Install specific version -asdf install mysql latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global mysql latest - -# Now mysql commands are available -mysql --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list mysql - -# Set local version for current directory -asdf local mysql - -# Uninstall a version -asdf uninstall mysql -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-mysql-plugin/SECURITY.adoc b/asdf-mysql-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-mysql-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-mysql-plugin/SECURITY.md b/asdf-mysql-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-mysql-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-neo4j-plugin/ABI-FFI-README.adoc b/asdf-neo4j-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..0767166f --- /dev/null +++ b/asdf-neo4j-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== NEO4J ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/neo4j.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libneo4j.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +neo4j/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── neo4j.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── neo4j.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/neo4j.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "neo4j.h" + +int main() { + void* handle = neo4j_init(); + if (!handle) return 1; + + int result = neo4j_process(handle, 42); + if (result != 0) { + const char* err = neo4j_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + neo4j_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lneo4j -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import NEO4J.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "neo4j")] +extern "C" { + fn neo4j_init() -> *mut std::ffi::c_void; + fn neo4j_free(handle: *mut std::ffi::c_void); + fn neo4j_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = neo4j_init(); + assert!(!handle.is_null()); + + let result = neo4j_process(handle, 42); + assert_eq!(result, 0); + + neo4j_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libneo4j = "libneo4j" + +function init() + handle = ccall((:neo4j_init, libneo4j), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:neo4j_process, libneo4j), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:neo4j_free, libneo4j), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/neo4j.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-neo4j-plugin/ABI-FFI-README.md b/asdf-neo4j-plugin/ABI-FFI-README.md deleted file mode 100644 index c5d9ed77..00000000 --- a/asdf-neo4j-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# NEO4J ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/neo4j.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libneo4j.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -neo4j/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── neo4j.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── neo4j.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/neo4j.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "neo4j.h" - -int main() { - void* handle = neo4j_init(); - if (!handle) return 1; - - int result = neo4j_process(handle, 42); - if (result != 0) { - const char* err = neo4j_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - neo4j_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lneo4j -L./zig-out/lib -``` - -### From Idris2 - -```idris -import NEO4J.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "neo4j")] -extern "C" { - fn neo4j_init() -> *mut std::ffi::c_void; - fn neo4j_free(handle: *mut std::ffi::c_void); - fn neo4j_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = neo4j_init(); - assert!(!handle.is_null()); - - let result = neo4j_process(handle, 42); - assert_eq!(result, 0); - - neo4j_free(handle); - } -} -``` - -### From Julia - -```julia -const libneo4j = "libneo4j" - -function init() - handle = ccall((:neo4j_init, libneo4j), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:neo4j_process, libneo4j), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:neo4j_free, libneo4j), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/neo4j.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-neo4j-plugin/CODE_OF_CONDUCT.adoc b/asdf-neo4j-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-neo4j-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-neo4j-plugin/CODE_OF_CONDUCT.md b/asdf-neo4j-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-neo4j-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-neo4j-plugin/CONTRIBUTING.adoc b/asdf-neo4j-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-neo4j-plugin/CONTRIBUTING.adoc +++ b/asdf-neo4j-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-neo4j-plugin/CONTRIBUTING.md b/asdf-neo4j-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-neo4j-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-neo4j-plugin/README.adoc b/asdf-neo4j-plugin/README.adoc index d08e1dd2..4963e8ab 100644 --- a/asdf-neo4j-plugin/README.adoc +++ b/asdf-neo4j-plugin/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-neo4j -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-neo4j-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-neo4j-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-neo4j-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-neo4j-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://neo4j.com[Neo4j]. -**All repos with foreign function interfaces MUST follow this standard:** +Graph database. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add neo4j https://github.com/hyperpolymath/asdf-neo4j-plugin.git +---- -=== Web Projects +neo4j: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all neo4j -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install neo4j latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global neo4j latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now neo4j commands are available +neo4j --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list neo4j -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local neo4j -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall neo4j ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-neo4j-plugin/README.md b/asdf-neo4j-plugin/README.md deleted file mode 100644 index e2d18f20..00000000 --- a/asdf-neo4j-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-neo4j - -[![Build](https://github.com/hyperpolymath/asdf-neo4j-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-neo4j-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-neo4j-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-neo4j-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Neo4j](https://neo4j.com). - -Graph database. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add neo4j https://github.com/hyperpolymath/asdf-neo4j-plugin.git -``` - -neo4j: - -```bash -# Show all installable versions -asdf list-all neo4j - -# Install specific version -asdf install neo4j latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global neo4j latest - -# Now neo4j commands are available -neo4j --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list neo4j - -# Set local version for current directory -asdf local neo4j - -# Uninstall a version -asdf uninstall neo4j -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-neo4j-plugin/SECURITY.adoc b/asdf-neo4j-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-neo4j-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-neo4j-plugin/SECURITY.md b/asdf-neo4j-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-neo4j-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-nickel-plugin/ABI-FFI-README.adoc b/asdf-nickel-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..785d64d6 --- /dev/null +++ b/asdf-nickel-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== NICKEL ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/nickel.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libnickel.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +nickel/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── nickel.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── nickel.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/nickel.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "nickel.h" + +int main() { + void* handle = nickel_init(); + if (!handle) return 1; + + int result = nickel_process(handle, 42); + if (result != 0) { + const char* err = nickel_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + nickel_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lnickel -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import NICKEL.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "nickel")] +extern "C" { + fn nickel_init() -> *mut std::ffi::c_void; + fn nickel_free(handle: *mut std::ffi::c_void); + fn nickel_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = nickel_init(); + assert!(!handle.is_null()); + + let result = nickel_process(handle, 42); + assert_eq!(result, 0); + + nickel_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libnickel = "libnickel" + +function init() + handle = ccall((:nickel_init, libnickel), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:nickel_process, libnickel), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:nickel_free, libnickel), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/nickel.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-nickel-plugin/ABI-FFI-README.md b/asdf-nickel-plugin/ABI-FFI-README.md deleted file mode 100644 index 8b3ac653..00000000 --- a/asdf-nickel-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# NICKEL ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/nickel.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libnickel.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -nickel/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── nickel.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── nickel.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/nickel.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "nickel.h" - -int main() { - void* handle = nickel_init(); - if (!handle) return 1; - - int result = nickel_process(handle, 42); - if (result != 0) { - const char* err = nickel_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - nickel_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lnickel -L./zig-out/lib -``` - -### From Idris2 - -```idris -import NICKEL.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "nickel")] -extern "C" { - fn nickel_init() -> *mut std::ffi::c_void; - fn nickel_free(handle: *mut std::ffi::c_void); - fn nickel_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = nickel_init(); - assert!(!handle.is_null()); - - let result = nickel_process(handle, 42); - assert_eq!(result, 0); - - nickel_free(handle); - } -} -``` - -### From Julia - -```julia -const libnickel = "libnickel" - -function init() - handle = ccall((:nickel_init, libnickel), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:nickel_process, libnickel), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:nickel_free, libnickel), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/nickel.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-nickel-plugin/CODE_OF_CONDUCT (1).adoc b/asdf-nickel-plugin/CODE_OF_CONDUCT (1).adoc new file mode 100644 index 00000000..6cc4271e --- /dev/null +++ b/asdf-nickel-plugin/CODE_OF_CONDUCT (1).adoc @@ -0,0 +1,339 @@ +== Code of Conduct + +=== Our Pledge + +We as members, contributors, and leaders pledge to make participation in +Asdf Tool Plugins a harassment-free experience for everyone, regardless +of age, body size, visible or invisible disability, ethnicity, sex +characteristics, gender identity and expression, level of experience, +education, socio-economic status, nationality, personal appearance, +race, caste, colour, religion, or sexual identity and orientation. + +We pledge to act and interact in ways that contribute to an open, +welcoming, diverse, inclusive, and healthy community. + +We recognise that a thriving open source community requires +*psychological safety* — an environment where people can contribute, ask +questions, make mistakes, and learn without fear of ridicule or +retaliation. + +''''' + +=== Our Standards + +==== Expected Behaviour + +The following behaviours contribute to a positive environment: + +*Communication* - Using welcoming and inclusive language - Being +respectful of differing viewpoints and experiences - Giving and +gracefully accepting constructive feedback - Assuming good intent while +addressing impact - Communicating clearly and patiently, especially with +newcomers + +*Collaboration* - Focusing on what is best for the community - Showing +empathy and kindness toward other community members - Being +collaborative rather than competitive - Mentoring and supporting less +experienced contributors - Celebrating others’ contributions and +successes + +*Professionalism* - Accepting responsibility and apologising to those +affected by our mistakes - Learning from the experience and avoiding +repetition - Respecting others’ time and attention - Staying on topic in +project spaces - Following project guidelines and conventions + +*Accessibility* - Using plain language and avoiding unnecessary jargon - +Providing alt text for images and transcripts for audio/video - Being +patient with those using assistive technologies - Accommodating +different communication styles and needs - Recognising that not everyone +communicates the same way + +==== Unacceptable Behaviour + +The following behaviours are considered harassment and are unacceptable: + +*Harassment* - The use of sexualised language or imagery, and sexual +attention or advances of any kind - Trolling, insulting or derogatory +comments, and personal or political attacks - Public or private +harassment - Deliberate intimidation, stalking, or following (online or +in-person) - Unwelcome physical contact or simulated physical contact +(e.g., emoji) - Sustained disruption of talks, events, or online +discussions + +*Discrimination* - Discriminatory jokes and language - Posting or +threatening to post others’ personally identifying information +("`doxing`") - Advocating for, or encouraging, any of the above +behaviour - Microaggressions — subtle, often unintentional, +discriminatory comments or actions + +*Professional Misconduct* - Publishing others’ private information +without explicit permission - Misrepresenting affiliation or +contributions - Plagiarism or claiming credit for others’ work - +Retaliating against anyone who reports a Code of Conduct violation - +Other conduct which could reasonably be considered inappropriate in a +professional setting + +==== Grey Areas + +Some situations require judgement. When uncertain: + +* *Intent vs Impact*: Good intentions do not excuse harmful impact. +Focus on making things right. +* *Power Dynamics*: Those with more power (maintainers, employers, +experienced contributors) must be especially mindful of their impact. +* *Cultural Differences*: What’s acceptable varies by culture. When in +doubt, err on the side of caution and ask. +* *Humour*: Jokes at others’ expense are rarely funny to everyone. Punch +up, not down. + +''''' + +=== Scope + +This Code of Conduct applies within all community spaces, including: + +*Online Spaces* - Repository discussions, issues, and pull/merge +requests - Project chat channels (Matrix, Discord, Slack, IRC) - Mailing +lists and forums - Social media when representing the project - Video +calls and virtual meetings + +*In-Person Spaces* - Conferences, meetups, and events - Workshops and +training sessions - Any gathering where you represent the project + +*Representation* This Code of Conduct also applies when an individual is +officially representing the community in public spaces. Examples +include: + +* Using an official project email address +* Posting via an official social media account +* Acting as an appointed representative at an event +* Speaking on behalf of the project + +''''' + +=== Enforcement + +==== Reporting + +If you experience or witness unacceptable behaviour, or have any other +concerns, please report it as soon as possible. + +*How to Report* + +[width="99%",cols="30%,33%,37%",options="header",] +|=== +|Method |Details |Best For +|*Email* |j.d.a.jewell@open.ac.uk |Detailed reports, sensitive matters + +|*Private Message* |Contact any maintainer directly |Quick questions, +minor issues + +|*Anonymous Form* |[Link to form if available] |When you need anonymity +|=== + +*What to Include* + +* Your contact information (unless anonymous) +* Names/usernames of those involved +* Description of what happened +* When and where it occurred +* Any witnesses +* Any supporting evidence (screenshots, links) +* How you would like us to respond (if you have a preference) + +*What Happens Next* + +[arabic] +. You will receive acknowledgment within *\{\{RESPONSE_TIME}}* +. The \{\{CONDUCT_TEAM}} will review the report +. We may ask for additional information +. We will determine appropriate action +. We will inform you of the outcome (respecting others’ privacy) + +==== Confidentiality + +All reports will be handled with discretion: + +* Reporter identity is protected by default +* Details are shared only with those who need to know +* We will ask before naming you in any communication +* Anonymous reports are accepted and investigated + +==== Conflicts of Interest + +If a \{\{CONDUCT_TEAM}} member is involved in an incident: + +* They will recuse themselves from the process +* Another maintainer or external party will handle the report +* We will disclose any potential conflicts + +''''' + +=== Enforcement Guidelines + +The \{\{CONDUCT_TEAM}} will follow these guidelines in determining +consequences: + +==== 1. Correction + +*Community Impact*: Use of inappropriate language or other behaviour +deemed unprofessional or unwelcome. + +*Consequence*: A private, written warning providing clarity around the +nature of the violation and an explanation of why the behaviour was +inappropriate. A public apology may be requested. + +*Duration*: Immediate + +==== 2. Warning + +*Community Impact*: A violation through a single incident or series of +actions. + +*Consequence*: A warning with consequences for continued behaviour. No +interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, for a specified period. This +includes avoiding interactions in community spaces as well as external +channels like social media. Violating these terms may lead to a +temporary or permanent ban. + +*Duration*: 1-4 weeks + +==== 3. Temporary Ban + +*Community Impact*: A serious violation of community standards, +including sustained inappropriate behaviour. + +*Consequence*: A temporary ban from any sort of interaction or public +communication with the community for a specified period. No public or +private interaction with the people involved, including unsolicited +interaction with those enforcing the Code of Conduct, is allowed during +this period. Violating these terms may lead to a permanent ban. + +*Duration*: 1-6 months + +==== 4. Permanent Ban + +*Community Impact*: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behaviour, harassment of an +individual, or aggression toward or disparagement of classes of +individuals. + +*Consequence*: A permanent ban from any sort of public interaction +within the community. + +*Duration*: Permanent (with appeal rights after 12 months) + +==== Enforcement Across Perimeters + +For contributors with elevated access (Perimeter 2 or 1): + +[cols=",",options="header",] +|=== +|Level |Additional Consequence +|Correction |Noted in contributor record +|Warning |Access privileges may be temporarily reduced +|Temporary Ban |Access reduced to Perimeter 3 for ban duration +|Permanent Ban |All access revoked +|=== + +''''' + +=== Appeals + +If you believe an enforcement decision was made in error: + +[arabic] +. *Wait 7 days* after the decision (cooling-off period) +. *Email* j.d.a.jewell@open.ac.uk with subject line "`Appeal: [Original +Report ID]`" +. *Explain* why you believe the decision should be reconsidered +. *Provide* any new information not previously available + +*Appeals Process* + +* Appeals are reviewed by a different \{\{CONDUCT_TEAM}} member than the +original +* You will receive a response within 14 days +* The appeals decision is final +* You may only appeal once per incident + +*Grounds for Appeal* + +* Procedural errors in the original investigation +* New evidence not previously available +* Disproportionate response to the violation +* Misunderstanding of facts + +''''' + +=== Supporting Those Who Report + +We are committed to supporting those who report violations: + +*We Will* - Believe and take all reports seriously - Respect your +privacy and confidentiality preferences - Keep you informed of progress +(if you wish) - Take steps to protect you from retaliation - Provide +resources if you need support + +*We Will Not* - Require you to confront the person directly - Dismiss +reports without investigation - Reveal your identity without consent - +Tolerate retaliation against reporters - Rush you to make decisions + +''''' + +=== Prevention + +Beyond enforcement, we actively work to prevent issues: + +*Onboarding* - All contributors are expected to read this Code of +Conduct - Perimeter 2 applicants must confirm they’ve read and +understood it - Maintainers receive additional training on enforcement + +*Culture* - We model the behaviour we expect - We intervene early when +we see potential issues - We thank people for positive contributions - +We create opportunities for diverse voices + +*Review* - This Code of Conduct is reviewed annually - Community +feedback is welcomed - Changes are communicated clearly + +''''' + +=== Acknowledgments + +This Code of Conduct is adapted from: + +* https://www.contributor-covenant.org/[Contributor Covenant], version +2.1 +* https://www.djangoproject.com/conduct/[Django Code of Conduct] +* https://www.rust-lang.org/policies/code-of-conduct[Rust Code of +Conduct] +* https://www.python.org/psf/conduct/[Python Community Code of Conduct] + +We thank these communities for their leadership in creating welcoming +spaces. + +''''' + +=== Questions? + +If you have questions about this Code of Conduct: + +* Open a +https://github.com/hyperpolymath/asdf-tool-plugins/discussions[Discussion] +(for general questions) +* Email j.d.a.jewell@open.ac.uk (for private questions) +* Contact any maintainer directly + +''''' + +=== Summary + +*Be kind. Be respectful. Be collaborative.* + +We’re all here because we care about this project. Let’s make it a place +where everyone can do their best work. + +''''' + +Last updated: 2026 · Based on Contributor Covenant 2.1 diff --git a/asdf-nickel-plugin/CODE_OF_CONDUCT (1).md b/asdf-nickel-plugin/CODE_OF_CONDUCT (1).md deleted file mode 100644 index d234420d..00000000 --- a/asdf-nickel-plugin/CODE_OF_CONDUCT (1).md +++ /dev/null @@ -1,327 +0,0 @@ -# Code of Conduct - - - -## Our Pledge - -We as members, contributors, and leaders pledge to make participation in Asdf Tool Plugins a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, colour, religion, or sexual identity and orientation. - -We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. - -We recognise that a thriving open source community requires **psychological safety** — an environment where people can contribute, ask questions, make mistakes, and learn without fear of ridicule or retaliation. - ---- - -## Our Standards - -### Expected Behaviour - -The following behaviours contribute to a positive environment: - -**Communication** -- Using welcoming and inclusive language -- Being respectful of differing viewpoints and experiences -- Giving and gracefully accepting constructive feedback -- Assuming good intent while addressing impact -- Communicating clearly and patiently, especially with newcomers - -**Collaboration** -- Focusing on what is best for the community -- Showing empathy and kindness toward other community members -- Being collaborative rather than competitive -- Mentoring and supporting less experienced contributors -- Celebrating others' contributions and successes - -**Professionalism** -- Accepting responsibility and apologising to those affected by our mistakes -- Learning from the experience and avoiding repetition -- Respecting others' time and attention -- Staying on topic in project spaces -- Following project guidelines and conventions - -**Accessibility** -- Using plain language and avoiding unnecessary jargon -- Providing alt text for images and transcripts for audio/video -- Being patient with those using assistive technologies -- Accommodating different communication styles and needs -- Recognising that not everyone communicates the same way - -### Unacceptable Behaviour - -The following behaviours are considered harassment and are unacceptable: - -**Harassment** -- The use of sexualised language or imagery, and sexual attention or advances of any kind -- Trolling, insulting or derogatory comments, and personal or political attacks -- Public or private harassment -- Deliberate intimidation, stalking, or following (online or in-person) -- Unwelcome physical contact or simulated physical contact (e.g., emoji) -- Sustained disruption of talks, events, or online discussions - -**Discrimination** -- Discriminatory jokes and language -- Posting or threatening to post others' personally identifying information ("doxing") -- Advocating for, or encouraging, any of the above behaviour -- Microaggressions — subtle, often unintentional, discriminatory comments or actions - -**Professional Misconduct** -- Publishing others' private information without explicit permission -- Misrepresenting affiliation or contributions -- Plagiarism or claiming credit for others' work -- Retaliating against anyone who reports a Code of Conduct violation -- Other conduct which could reasonably be considered inappropriate in a professional setting - -### Grey Areas - -Some situations require judgement. When uncertain: - -- **Intent vs Impact**: Good intentions do not excuse harmful impact. Focus on making things right. -- **Power Dynamics**: Those with more power (maintainers, employers, experienced contributors) must be especially mindful of their impact. -- **Cultural Differences**: What's acceptable varies by culture. When in doubt, err on the side of caution and ask. -- **Humour**: Jokes at others' expense are rarely funny to everyone. Punch up, not down. - ---- - -## Scope - -This Code of Conduct applies within all community spaces, including: - -**Online Spaces** -- Repository discussions, issues, and pull/merge requests -- Project chat channels (Matrix, Discord, Slack, IRC) -- Mailing lists and forums -- Social media when representing the project -- Video calls and virtual meetings - -**In-Person Spaces** -- Conferences, meetups, and events -- Workshops and training sessions -- Any gathering where you represent the project - -**Representation** -This Code of Conduct also applies when an individual is officially representing the community in public spaces. Examples include: - -- Using an official project email address -- Posting via an official social media account -- Acting as an appointed representative at an event -- Speaking on behalf of the project - ---- - -## Enforcement - -### Reporting - -If you experience or witness unacceptable behaviour, or have any other concerns, please report it as soon as possible. - -**How to Report** - -| Method | Details | Best For | -|--------|---------|----------| -| **Email** | j.d.a.jewell@open.ac.uk | Detailed reports, sensitive matters | -| **Private Message** | Contact any maintainer directly | Quick questions, minor issues | -| **Anonymous Form** | [Link to form if available] | When you need anonymity | - -**What to Include** - -- Your contact information (unless anonymous) -- Names/usernames of those involved -- Description of what happened -- When and where it occurred -- Any witnesses -- Any supporting evidence (screenshots, links) -- How you would like us to respond (if you have a preference) - -**What Happens Next** - -1. You will receive acknowledgment within **{{RESPONSE_TIME}}** -2. The {{CONDUCT_TEAM}} will review the report -3. We may ask for additional information -4. We will determine appropriate action -5. We will inform you of the outcome (respecting others' privacy) - -### Confidentiality - -All reports will be handled with discretion: - -- Reporter identity is protected by default -- Details are shared only with those who need to know -- We will ask before naming you in any communication -- Anonymous reports are accepted and investigated - -### Conflicts of Interest - -If a {{CONDUCT_TEAM}} member is involved in an incident: - -- They will recuse themselves from the process -- Another maintainer or external party will handle the report -- We will disclose any potential conflicts - ---- - -## Enforcement Guidelines - -The {{CONDUCT_TEAM}} will follow these guidelines in determining consequences: - -### 1. Correction - -**Community Impact**: Use of inappropriate language or other behaviour deemed unprofessional or unwelcome. - -**Consequence**: A private, written warning providing clarity around the nature of the violation and an explanation of why the behaviour was inappropriate. A public apology may be requested. - -**Duration**: Immediate - -### 2. Warning - -**Community Impact**: A violation through a single incident or series of actions. - -**Consequence**: A warning with consequences for continued behaviour. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. - -**Duration**: 1-4 weeks - -### 3. Temporary Ban - -**Community Impact**: A serious violation of community standards, including sustained inappropriate behaviour. - -**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. - -**Duration**: 1-6 months - -### 4. Permanent Ban - -**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behaviour, harassment of an individual, or aggression toward or disparagement of classes of individuals. - -**Consequence**: A permanent ban from any sort of public interaction within the community. - -**Duration**: Permanent (with appeal rights after 12 months) - -### Enforcement Across Perimeters - -For contributors with elevated access (Perimeter 2 or 1): - -| Level | Additional Consequence | -|-------|----------------------| -| Correction | Noted in contributor record | -| Warning | Access privileges may be temporarily reduced | -| Temporary Ban | Access reduced to Perimeter 3 for ban duration | -| Permanent Ban | All access revoked | - ---- - -## Appeals - -If you believe an enforcement decision was made in error: - -1. **Wait 7 days** after the decision (cooling-off period) -2. **Email** j.d.a.jewell@open.ac.uk with subject line "Appeal: [Original Report ID]" -3. **Explain** why you believe the decision should be reconsidered -4. **Provide** any new information not previously available - -**Appeals Process** - -- Appeals are reviewed by a different {{CONDUCT_TEAM}} member than the original -- You will receive a response within 14 days -- The appeals decision is final -- You may only appeal once per incident - -**Grounds for Appeal** - -- Procedural errors in the original investigation -- New evidence not previously available -- Disproportionate response to the violation -- Misunderstanding of facts - ---- - -## Supporting Those Who Report - -We are committed to supporting those who report violations: - -**We Will** -- Believe and take all reports seriously -- Respect your privacy and confidentiality preferences -- Keep you informed of progress (if you wish) -- Take steps to protect you from retaliation -- Provide resources if you need support - -**We Will Not** -- Require you to confront the person directly -- Dismiss reports without investigation -- Reveal your identity without consent -- Tolerate retaliation against reporters -- Rush you to make decisions - ---- - -## Prevention - -Beyond enforcement, we actively work to prevent issues: - -**Onboarding** -- All contributors are expected to read this Code of Conduct -- Perimeter 2 applicants must confirm they've read and understood it -- Maintainers receive additional training on enforcement - -**Culture** -- We model the behaviour we expect -- We intervene early when we see potential issues -- We thank people for positive contributions -- We create opportunities for diverse voices - -**Review** -- This Code of Conduct is reviewed annually -- Community feedback is welcomed -- Changes are communicated clearly - ---- - -## Acknowledgments - -This Code of Conduct is adapted from: - -- [Contributor Covenant](https://www.contributor-covenant.org/), version 2.1 -- [Django Code of Conduct](https://www.djangoproject.com/conduct/) -- [Rust Code of Conduct](https://www.rust-lang.org/policies/code-of-conduct) -- [Python Community Code of Conduct](https://www.python.org/psf/conduct/) - -We thank these communities for their leadership in creating welcoming spaces. - ---- - -## Questions? - -If you have questions about this Code of Conduct: - -- Open a [Discussion](https://github.com/hyperpolymath/asdf-tool-plugins/discussions) (for general questions) -- Email j.d.a.jewell@open.ac.uk (for private questions) -- Contact any maintainer directly - ---- - -## Summary - -**Be kind. Be respectful. Be collaborative.** - -We're all here because we care about this project. Let's make it a place where everyone can do their best work. - ---- - -Last updated: 2026 · Based on Contributor Covenant 2.1 diff --git a/asdf-nickel-plugin/CODE_OF_CONDUCT.adoc b/asdf-nickel-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-nickel-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-nickel-plugin/CODE_OF_CONDUCT.md b/asdf-nickel-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-nickel-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-nickel-plugin/CONTRIBUTING.adoc b/asdf-nickel-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-nickel-plugin/CONTRIBUTING.adoc +++ b/asdf-nickel-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-nickel-plugin/CONTRIBUTING.md b/asdf-nickel-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-nickel-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-nickel-plugin/README.adoc b/asdf-nickel-plugin/README.adoc index d08e1dd2..5c4ae9ec 100644 --- a/asdf-nickel-plugin/README.adoc +++ b/asdf-nickel-plugin/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-nickel -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-nickel-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-nickel-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-nickel-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-nickel-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://nickel-lang.org[Nickel]. -**All repos with foreign function interfaces MUST follow this standard:** +Configuration language. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add nickel https://github.com/hyperpolymath/asdf-nickel-plugin.git +---- -=== Web Projects +nickel: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all nickel -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install nickel latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global nickel latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now nickel commands are available +nickel --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list nickel -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local nickel -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall nickel ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-nickel-plugin/README.md b/asdf-nickel-plugin/README.md deleted file mode 100644 index e041b947..00000000 --- a/asdf-nickel-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-nickel - -[![Build](https://github.com/hyperpolymath/asdf-nickel-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-nickel-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-nickel-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-nickel-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Nickel](https://nickel-lang.org). - -Configuration language. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add nickel https://github.com/hyperpolymath/asdf-nickel-plugin.git -``` - -nickel: - -```bash -# Show all installable versions -asdf list-all nickel - -# Install specific version -asdf install nickel latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global nickel latest - -# Now nickel commands are available -nickel --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list nickel - -# Set local version for current directory -asdf local nickel - -# Uninstall a version -asdf uninstall nickel -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-nickel-plugin/SECURITY (1).adoc b/asdf-nickel-plugin/SECURITY (1).adoc new file mode 100644 index 00000000..a66ca685 --- /dev/null +++ b/asdf-nickel-plugin/SECURITY (1).adoc @@ -0,0 +1,452 @@ +== Security Policy + +We take security seriously. We appreciate your efforts to responsibly +disclose vulnerabilities and will make every effort to acknowledge your +contributions. + +=== Table of Contents + +* link:#reporting-a-vulnerability[Reporting a Vulnerability] +* link:#what-to-include[What to Include] +* link:#response-timeline[Response Timeline] +* link:#disclosure-policy[Disclosure Policy] +* link:#scope[Scope] +* link:#safe-harbour[Safe Harbour] +* link:#recognition[Recognition] +* link:#security-updates[Security Updates] +* link:#security-best-practices[Security Best Practices] + +''''' + +=== Reporting a Vulnerability + +==== Preferred Method: GitHub Security Advisories + +The preferred method for reporting security vulnerabilities is through +GitHub’s Security Advisory feature: + +[arabic] +. Navigate to +https://github.com/hyperpolymath/asdf-tool-plugins/security/advisories/new[Report +a Vulnerability] +. Click *"`Report a vulnerability`"* +. Complete the form with as much detail as possible +. Submit — we’ll receive a private notification + +This method ensures: + +* End-to-end encryption of your report +* Private discussion space for collaboration +* Coordinated disclosure tooling +* Automatic credit when the advisory is published + +==== Alternative: Encrypted Email + +If you cannot use GitHub Security Advisories, you may email us directly: + +[cols=",",] +|=== +|*Email* |6759885+hyperpolymath@users.noreply.github.com +|*PGP Key* |link:%7B%7BPGP_KEY_URL%7D%7D[Download Public Key] +|*Fingerprint* |`+{{PGP_FINGERPRINT}}+` +|=== + +[source,bash] +---- +# Import our PGP key +curl -sSL {{PGP_KEY_URL}} | gpg --import + +# Verify fingerprint +gpg --fingerprint 6759885+hyperpolymath@users.noreply.github.com + +# Encrypt your report +gpg --armor --encrypt --recipient 6759885+hyperpolymath@users.noreply.github.com report.txt +---- + +____ +*⚠️ Important:* Do not report security vulnerabilities through public +GitHub issues, pull requests, discussions, or social media. +____ + +''''' + +=== What to Include + +A good vulnerability report helps us understand and reproduce the issue +quickly. + +==== Required Information + +* *Description*: Clear explanation of the vulnerability +* *Impact*: What an attacker could achieve (confidentiality, integrity, +availability) +* *Affected versions*: Which versions/commits are affected +* *Reproduction steps*: Detailed steps to reproduce the issue + +==== Helpful Additional Information + +* *Proof of concept*: Code, scripts, or screenshots demonstrating the +vulnerability +* *Attack scenario*: Realistic attack scenario showing exploitability +* *CVSS score*: Your assessment of severity (use +https://www.first.org/cvss/calculator/3.1[CVSS 3.1 Calculator]) +* *CWE ID*: Common Weakness Enumeration identifier if known +* *Suggested fix*: If you have ideas for remediation +* *References*: Links to related vulnerabilities, research, or +advisories + +==== Example Report Structure + +[source,markdown] +---- +## Summary +[One-sentence description of the vulnerability] + +## Vulnerability Type +[e.g., SQL Injection, XSS, SSRF, Path Traversal, etc.] + +## Affected Component +[File path, function name, API endpoint, etc.] + +## Affected Versions +[Version range or specific commits] + +## Severity Assessment +- CVSS 3.1 Score: [X.X] +- CVSS Vector: [CVSS:3.1/AV:X/AC:X/PR:X/UI:X/S:X/C:X/I:X/A:X] + +## Description +[Detailed technical description] + +## Steps to Reproduce +1. [First step] +2. [Second step] +3. [...] + +## Proof of Concept +[Code, curl commands, screenshots, etc.] + +## Impact +[What can an attacker achieve?] + +## Suggested Remediation +[Optional: your ideas for fixing] + +## References +[Links to related issues, CVEs, research] +---- + +''''' + +=== Response Timeline + +We commit to the following response times: + +[width="100%",cols="24%,35%,41%",options="header",] +|=== +|Stage |Timeframe |Description +|*Initial Response* |48 hours |We acknowledge receipt and confirm we’re +investigating + +|*Triage* |7 days |We assess severity, confirm the vulnerability, and +estimate timeline + +|*Status Update* |Every 7 days |Regular updates on remediation progress + +|*Resolution* |90 days |Target for fix development and release (complex +issues may take longer) + +|*Disclosure* |90 days |Public disclosure after fix is available +(coordinated with you) +|=== + +____ +*Note:* These are targets, not guarantees. Complex vulnerabilities may +require more time. We’ll communicate openly about any delays. +____ + +''''' + +=== Disclosure Policy + +We follow *coordinated disclosure* (also known as responsible +disclosure): + +[arabic] +. *You report* the vulnerability privately +. *We acknowledge* and begin investigation +. *We develop* a fix and prepare a release +. *We coordinate* disclosure timing with you +. *We publish* security advisory and fix simultaneously +. *You may publish* your research after disclosure + +==== Our Commitments + +* We will not take legal action against researchers who follow this +policy +* We will work with you to understand and resolve the issue +* We will credit you in the security advisory (unless you prefer +anonymity) +* We will notify you before public disclosure +* We will publish advisories with sufficient detail for users to assess +risk + +==== Your Commitments + +* Report vulnerabilities promptly after discovery +* Give us reasonable time to address the issue before disclosure +* Do not access, modify, or delete data beyond what’s necessary to +demonstrate the vulnerability +* Do not degrade service availability (no DoS testing on production) +* Do not share vulnerability details with others until coordinated +disclosure + +==== Disclosure Timeline + +.... +Day 0 You report vulnerability +Day 1-2 We acknowledge receipt +Day 7 We confirm vulnerability and share initial assessment +Day 7-90 We develop and test fix +Day 90 Coordinated public disclosure + (earlier if fix is ready; later by mutual agreement) +.... + +If we cannot reach agreement on disclosure timing, we default to 90 days +from your initial report. + +''''' + +=== Scope + +==== In Scope ✅ + +The following are within scope for security research: + +* This repository (`+hyperpolymath/asdf-tool-plugins+`) and all its code +* Official releases and packages published from this repository +* Documentation that could lead to security issues +* Build and deployment configurations in this repository +* Dependencies (report here, we’ll coordinate with upstream) + +==== Out of Scope ❌ + +The following are *not* in scope: + +* Third-party services we integrate with (report directly to them) +* Social engineering attacks against maintainers +* Physical security +* Denial of service attacks against production infrastructure +* Spam, phishing, or other non-technical attacks +* Issues already reported or publicly known +* Theoretical vulnerabilities without proof of concept + +==== Qualifying Vulnerabilities + +We’re particularly interested in: + +* Remote code execution +* SQL injection, command injection, code injection +* Authentication/authorisation bypass +* Cross-site scripting (XSS) and cross-site request forgery (CSRF) +* Server-side request forgery (SSRF) +* Path traversal / local file inclusion +* Information disclosure (credentials, PII, secrets) +* Cryptographic weaknesses +* Deserialisation vulnerabilities +* Memory safety issues (buffer overflows, use-after-free, etc.) +* Supply chain vulnerabilities (dependency confusion, etc.) +* Significant logic flaws + +==== Non-Qualifying Issues + +The following generally do not qualify as security vulnerabilities: + +* Missing security headers on non-sensitive pages +* Clickjacking on pages without sensitive actions +* Self-XSS (requires victim to paste code) +* Missing rate limiting (unless it enables a specific attack) +* Username/email enumeration (unless high-risk context) +* Missing cookie flags on non-sensitive cookies +* Software version disclosure +* Verbose error messages (unless exposing secrets) +* Best practice deviations without demonstrable impact + +''''' + +=== Safe Harbour + +We support security research conducted in good faith. + +==== Our Promise + +If you conduct security research in accordance with this policy: + +* ✅ We will not initiate legal action against you +* ✅ We will not report your activity to law enforcement +* ✅ We will work with you in good faith to resolve issues +* ✅ We consider your research authorised under the Computer Fraud and +Abuse Act (CFAA), UK Computer Misuse Act, and similar laws +* ✅ We waive any potential claim against you for circumvention of +security controls + +==== Good Faith Requirements + +To qualify for safe harbour, you must: + +* Comply with this security policy +* Report vulnerabilities promptly +* Avoid privacy violations (do not access others’ data) +* Avoid service degradation (no destructive testing) +* Not exploit vulnerabilities beyond proof-of-concept +* Not use vulnerabilities for profit (beyond bug bounties where offered) + +____ +*⚠️ Important:* This safe harbour does not extend to third-party +systems. Always check their policies before testing. +____ + +''''' + +=== Recognition + +We believe in recognising security researchers who help us improve. + +==== Hall of Fame + +Researchers who report valid vulnerabilities will be acknowledged in our +link:SECURITY-ACKNOWLEDGMENTS.md[Security Acknowledgments] (unless they +prefer anonymity). + +Recognition includes: + +* Your name (or chosen alias) +* Link to your website/profile (optional) +* Brief description of the vulnerability class +* Date of report + +==== What We Offer + +* ✅ Public credit in security advisories +* ✅ Acknowledgment in release notes +* ✅ Entry in our Hall of Fame +* ✅ Reference/recommendation letter upon request (for significant +findings) + +==== What We Don’t Currently Offer + +* ❌ Monetary bug bounties +* ❌ Hardware or swag +* ❌ Paid security research contracts + +____ +*Note:* We’re a community project with limited resources. Your +contributions help everyone who uses this software. +____ + +''''' + +=== Security Updates + +==== Receiving Updates + +To stay informed about security updates: + +* *Watch this repository*: Click "`Watch`" → "`Custom`" → Select +"`Security alerts`" +* *GitHub Security Advisories*: Published at +https://github.com/hyperpolymath/asdf-tool-plugins/security/advisories[Security +Advisories] +* *Release notes*: Security fixes noted in link:CHANGELOG.md[CHANGELOG] + +==== Update Policy + +[cols=",",options="header",] +|=== +|Severity |Response +|*Critical/High* |Patch release as soon as fix is ready +|*Medium* |Included in next scheduled release (or earlier) +|*Low* |Included in next scheduled release +|=== + +==== Supported Versions + +[cols=",,",options="header",] +|=== +|Version |Supported |Notes +|`+main+` branch |✅ Yes |Latest development +|Latest release |✅ Yes |Current stable +|Previous minor release |✅ Yes |Security fixes backported +|Older versions |❌ No |Please upgrade +|=== + +''''' + +=== Security Best Practices + +When using Asdf Tool Plugins, we recommend: + +==== General + +* Keep dependencies up to date +* Use the latest stable release +* Subscribe to security notifications +* Review configuration against security documentation +* Follow principle of least privilege + +==== For Contributors + +* Never commit secrets, credentials, or API keys +* Use signed commits (`+git config commit.gpgsign true+`) +* Review dependencies before adding them +* Run security linters locally before pushing +* Report any concerns about existing code + +''''' + +=== Additional Resources + +* link:%7B%7BPGP_KEY_URL%7D%7D[Our PGP Public Key] +* https://github.com/hyperpolymath/asdf-tool-plugins/security/advisories[Security +Advisories] +* link:CHANGELOG.md[Changelog] +* link:CONTRIBUTING.md[Contributing Guidelines] +* https://cve.mitre.org/[CVE Database] +* https://www.first.org/cvss/calculator/3.1[CVSS Calculator] + +''''' + +=== Contact + +[width="100%",cols="50%,50%",options="header",] +|=== +|Purpose |Contact +|*Security issues* +|https://github.com/hyperpolymath/asdf-tool-plugins/security/advisories/new[Report +via GitHub] or 6759885+hyperpolymath@users.noreply.github.com + +|*General questions* +|https://github.com/hyperpolymath/asdf-tool-plugins/discussions[GitHub +Discussions] + +|*Other enquiries* |See link:README.md[README] for contact information +|=== + +''''' + +=== Policy Changes + +This security policy may be updated from time to time. Significant +changes will be: + +* Committed to this repository with a clear commit message +* Noted in the changelog +* Announced via GitHub Discussions (for major changes) + +''''' + +_Thank you for helping keep Asdf Tool Plugins and its users safe._ 🛡️ + +''''' + +Last updated: 2026 · Policy version: 1.0.0 diff --git a/asdf-nickel-plugin/SECURITY (1).md b/asdf-nickel-plugin/SECURITY (1).md deleted file mode 100644 index f61f4ad7..00000000 --- a/asdf-nickel-plugin/SECURITY (1).md +++ /dev/null @@ -1,406 +0,0 @@ -# Security Policy - - - -We take security seriously. We appreciate your efforts to responsibly disclose vulnerabilities and will make every effort to acknowledge your contributions. - -## Table of Contents - -- [Reporting a Vulnerability](#reporting-a-vulnerability) -- [What to Include](#what-to-include) -- [Response Timeline](#response-timeline) -- [Disclosure Policy](#disclosure-policy) -- [Scope](#scope) -- [Safe Harbour](#safe-harbour) -- [Recognition](#recognition) -- [Security Updates](#security-updates) -- [Security Best Practices](#security-best-practices) - ---- - -## Reporting a Vulnerability - -### Preferred Method: GitHub Security Advisories - -The preferred method for reporting security vulnerabilities is through GitHub's Security Advisory feature: - -1. Navigate to [Report a Vulnerability](https://github.com/hyperpolymath/asdf-tool-plugins/security/advisories/new) -2. Click **"Report a vulnerability"** -3. Complete the form with as much detail as possible -4. Submit — we'll receive a private notification - -This method ensures: - -- End-to-end encryption of your report -- Private discussion space for collaboration -- Coordinated disclosure tooling -- Automatic credit when the advisory is published - -### Alternative: Encrypted Email - -If you cannot use GitHub Security Advisories, you may email us directly: - -| | | -|---|---| -| **Email** | 6759885+hyperpolymath@users.noreply.github.com | -| **PGP Key** | [Download Public Key]({{PGP_KEY_URL}}) | -| **Fingerprint** | `{{PGP_FINGERPRINT}}` | - -```bash -# Import our PGP key -curl -sSL {{PGP_KEY_URL}} | gpg --import - -# Verify fingerprint -gpg --fingerprint 6759885+hyperpolymath@users.noreply.github.com - -# Encrypt your report -gpg --armor --encrypt --recipient 6759885+hyperpolymath@users.noreply.github.com report.txt -``` - -> **⚠️ Important:** Do not report security vulnerabilities through public GitHub issues, pull requests, discussions, or social media. - ---- - -## What to Include - -A good vulnerability report helps us understand and reproduce the issue quickly. - -### Required Information - -- **Description**: Clear explanation of the vulnerability -- **Impact**: What an attacker could achieve (confidentiality, integrity, availability) -- **Affected versions**: Which versions/commits are affected -- **Reproduction steps**: Detailed steps to reproduce the issue - -### Helpful Additional Information - -- **Proof of concept**: Code, scripts, or screenshots demonstrating the vulnerability -- **Attack scenario**: Realistic attack scenario showing exploitability -- **CVSS score**: Your assessment of severity (use [CVSS 3.1 Calculator](https://www.first.org/cvss/calculator/3.1)) -- **CWE ID**: Common Weakness Enumeration identifier if known -- **Suggested fix**: If you have ideas for remediation -- **References**: Links to related vulnerabilities, research, or advisories - -### Example Report Structure - -```markdown -## Summary -[One-sentence description of the vulnerability] - -## Vulnerability Type -[e.g., SQL Injection, XSS, SSRF, Path Traversal, etc.] - -## Affected Component -[File path, function name, API endpoint, etc.] - -## Affected Versions -[Version range or specific commits] - -## Severity Assessment -- CVSS 3.1 Score: [X.X] -- CVSS Vector: [CVSS:3.1/AV:X/AC:X/PR:X/UI:X/S:X/C:X/I:X/A:X] - -## Description -[Detailed technical description] - -## Steps to Reproduce -1. [First step] -2. [Second step] -3. [...] - -## Proof of Concept -[Code, curl commands, screenshots, etc.] - -## Impact -[What can an attacker achieve?] - -## Suggested Remediation -[Optional: your ideas for fixing] - -## References -[Links to related issues, CVEs, research] -``` - ---- - -## Response Timeline - -We commit to the following response times: - -| Stage | Timeframe | Description | -|-------|-----------|-------------| -| **Initial Response** | 48 hours | We acknowledge receipt and confirm we're investigating | -| **Triage** | 7 days | We assess severity, confirm the vulnerability, and estimate timeline | -| **Status Update** | Every 7 days | Regular updates on remediation progress | -| **Resolution** | 90 days | Target for fix development and release (complex issues may take longer) | -| **Disclosure** | 90 days | Public disclosure after fix is available (coordinated with you) | - -> **Note:** These are targets, not guarantees. Complex vulnerabilities may require more time. We'll communicate openly about any delays. - ---- - -## Disclosure Policy - -We follow **coordinated disclosure** (also known as responsible disclosure): - -1. **You report** the vulnerability privately -2. **We acknowledge** and begin investigation -3. **We develop** a fix and prepare a release -4. **We coordinate** disclosure timing with you -5. **We publish** security advisory and fix simultaneously -6. **You may publish** your research after disclosure - -### Our Commitments - -- We will not take legal action against researchers who follow this policy -- We will work with you to understand and resolve the issue -- We will credit you in the security advisory (unless you prefer anonymity) -- We will notify you before public disclosure -- We will publish advisories with sufficient detail for users to assess risk - -### Your Commitments - -- Report vulnerabilities promptly after discovery -- Give us reasonable time to address the issue before disclosure -- Do not access, modify, or delete data beyond what's necessary to demonstrate the vulnerability -- Do not degrade service availability (no DoS testing on production) -- Do not share vulnerability details with others until coordinated disclosure - -### Disclosure Timeline - -``` -Day 0 You report vulnerability -Day 1-2 We acknowledge receipt -Day 7 We confirm vulnerability and share initial assessment -Day 7-90 We develop and test fix -Day 90 Coordinated public disclosure - (earlier if fix is ready; later by mutual agreement) -``` - -If we cannot reach agreement on disclosure timing, we default to 90 days from your initial report. - ---- - -## Scope - -### In Scope ✅ - -The following are within scope for security research: - -- This repository (`hyperpolymath/asdf-tool-plugins`) and all its code -- Official releases and packages published from this repository -- Documentation that could lead to security issues -- Build and deployment configurations in this repository -- Dependencies (report here, we'll coordinate with upstream) - -### Out of Scope ❌ - -The following are **not** in scope: - -- Third-party services we integrate with (report directly to them) -- Social engineering attacks against maintainers -- Physical security -- Denial of service attacks against production infrastructure -- Spam, phishing, or other non-technical attacks -- Issues already reported or publicly known -- Theoretical vulnerabilities without proof of concept - -### Qualifying Vulnerabilities - -We're particularly interested in: - -- Remote code execution -- SQL injection, command injection, code injection -- Authentication/authorisation bypass -- Cross-site scripting (XSS) and cross-site request forgery (CSRF) -- Server-side request forgery (SSRF) -- Path traversal / local file inclusion -- Information disclosure (credentials, PII, secrets) -- Cryptographic weaknesses -- Deserialisation vulnerabilities -- Memory safety issues (buffer overflows, use-after-free, etc.) -- Supply chain vulnerabilities (dependency confusion, etc.) -- Significant logic flaws - -### Non-Qualifying Issues - -The following generally do not qualify as security vulnerabilities: - -- Missing security headers on non-sensitive pages -- Clickjacking on pages without sensitive actions -- Self-XSS (requires victim to paste code) -- Missing rate limiting (unless it enables a specific attack) -- Username/email enumeration (unless high-risk context) -- Missing cookie flags on non-sensitive cookies -- Software version disclosure -- Verbose error messages (unless exposing secrets) -- Best practice deviations without demonstrable impact - ---- - -## Safe Harbour - -We support security research conducted in good faith. - -### Our Promise - -If you conduct security research in accordance with this policy: - -- ✅ We will not initiate legal action against you -- ✅ We will not report your activity to law enforcement -- ✅ We will work with you in good faith to resolve issues -- ✅ We consider your research authorised under the Computer Fraud and Abuse Act (CFAA), UK Computer Misuse Act, and similar laws -- ✅ We waive any potential claim against you for circumvention of security controls - -### Good Faith Requirements - -To qualify for safe harbour, you must: - -- Comply with this security policy -- Report vulnerabilities promptly -- Avoid privacy violations (do not access others' data) -- Avoid service degradation (no destructive testing) -- Not exploit vulnerabilities beyond proof-of-concept -- Not use vulnerabilities for profit (beyond bug bounties where offered) - -> **⚠️ Important:** This safe harbour does not extend to third-party systems. Always check their policies before testing. - ---- - -## Recognition - -We believe in recognising security researchers who help us improve. - -### Hall of Fame - -Researchers who report valid vulnerabilities will be acknowledged in our [Security Acknowledgments](SECURITY-ACKNOWLEDGMENTS.md) (unless they prefer anonymity). - -Recognition includes: - -- Your name (or chosen alias) -- Link to your website/profile (optional) -- Brief description of the vulnerability class -- Date of report - -### What We Offer - -- ✅ Public credit in security advisories -- ✅ Acknowledgment in release notes -- ✅ Entry in our Hall of Fame -- ✅ Reference/recommendation letter upon request (for significant findings) - -### What We Don't Currently Offer - -- ❌ Monetary bug bounties -- ❌ Hardware or swag -- ❌ Paid security research contracts - -> **Note:** We're a community project with limited resources. Your contributions help everyone who uses this software. - ---- - -## Security Updates - -### Receiving Updates - -To stay informed about security updates: - -- **Watch this repository**: Click "Watch" → "Custom" → Select "Security alerts" -- **GitHub Security Advisories**: Published at [Security Advisories](https://github.com/hyperpolymath/asdf-tool-plugins/security/advisories) -- **Release notes**: Security fixes noted in [CHANGELOG](CHANGELOG.md) - -### Update Policy - -| Severity | Response | -|----------|----------| -| **Critical/High** | Patch release as soon as fix is ready | -| **Medium** | Included in next scheduled release (or earlier) | -| **Low** | Included in next scheduled release | - -### Supported Versions - - - -| Version | Supported | Notes | -|---------|-----------|-------| -| `main` branch | ✅ Yes | Latest development | -| Latest release | ✅ Yes | Current stable | -| Previous minor release | ✅ Yes | Security fixes backported | -| Older versions | ❌ No | Please upgrade | - ---- - -## Security Best Practices - -When using Asdf Tool Plugins, we recommend: - -### General - -- Keep dependencies up to date -- Use the latest stable release -- Subscribe to security notifications -- Review configuration against security documentation -- Follow principle of least privilege - -### For Contributors - -- Never commit secrets, credentials, or API keys -- Use signed commits (`git config commit.gpgsign true`) -- Review dependencies before adding them -- Run security linters locally before pushing -- Report any concerns about existing code - ---- - -## Additional Resources - -- [Our PGP Public Key]({{PGP_KEY_URL}}) -- [Security Advisories](https://github.com/hyperpolymath/asdf-tool-plugins/security/advisories) -- [Changelog](CHANGELOG.md) -- [Contributing Guidelines](CONTRIBUTING.md) -- [CVE Database](https://cve.mitre.org/) -- [CVSS Calculator](https://www.first.org/cvss/calculator/3.1) - ---- - -## Contact - -| Purpose | Contact | -|---------|---------| -| **Security issues** | [Report via GitHub](https://github.com/hyperpolymath/asdf-tool-plugins/security/advisories/new) or 6759885+hyperpolymath@users.noreply.github.com | -| **General questions** | [GitHub Discussions](https://github.com/hyperpolymath/asdf-tool-plugins/discussions) | -| **Other enquiries** | See [README](README.md) for contact information | - ---- - -## Policy Changes - -This security policy may be updated from time to time. Significant changes will be: - -- Committed to this repository with a clear commit message -- Noted in the changelog -- Announced via GitHub Discussions (for major changes) - ---- - -*Thank you for helping keep Asdf Tool Plugins and its users safe.* 🛡️ - ---- - -Last updated: 2026 · Policy version: 1.0.0 diff --git a/asdf-nickel-plugin/SECURITY.adoc b/asdf-nickel-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-nickel-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-nickel-plugin/SECURITY.md b/asdf-nickel-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-nickel-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-ocaml-plugin/ABI-FFI-README.adoc b/asdf-ocaml-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..ab805e19 --- /dev/null +++ b/asdf-ocaml-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== OCAML ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/ocaml.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libocaml.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +ocaml/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── ocaml.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── ocaml.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/ocaml.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "ocaml.h" + +int main() { + void* handle = ocaml_init(); + if (!handle) return 1; + + int result = ocaml_process(handle, 42); + if (result != 0) { + const char* err = ocaml_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + ocaml_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -locaml -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import OCAML.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "ocaml")] +extern "C" { + fn ocaml_init() -> *mut std::ffi::c_void; + fn ocaml_free(handle: *mut std::ffi::c_void); + fn ocaml_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = ocaml_init(); + assert!(!handle.is_null()); + + let result = ocaml_process(handle, 42); + assert_eq!(result, 0); + + ocaml_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libocaml = "libocaml" + +function init() + handle = ccall((:ocaml_init, libocaml), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:ocaml_process, libocaml), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:ocaml_free, libocaml), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/ocaml.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-ocaml-plugin/ABI-FFI-README.md b/asdf-ocaml-plugin/ABI-FFI-README.md deleted file mode 100644 index 50d6c260..00000000 --- a/asdf-ocaml-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# OCAML ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/ocaml.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libocaml.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -ocaml/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── ocaml.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── ocaml.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/ocaml.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "ocaml.h" - -int main() { - void* handle = ocaml_init(); - if (!handle) return 1; - - int result = ocaml_process(handle, 42); - if (result != 0) { - const char* err = ocaml_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - ocaml_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -locaml -L./zig-out/lib -``` - -### From Idris2 - -```idris -import OCAML.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "ocaml")] -extern "C" { - fn ocaml_init() -> *mut std::ffi::c_void; - fn ocaml_free(handle: *mut std::ffi::c_void); - fn ocaml_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = ocaml_init(); - assert!(!handle.is_null()); - - let result = ocaml_process(handle, 42); - assert_eq!(result, 0); - - ocaml_free(handle); - } -} -``` - -### From Julia - -```julia -const libocaml = "libocaml" - -function init() - handle = ccall((:ocaml_init, libocaml), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:ocaml_process, libocaml), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:ocaml_free, libocaml), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/ocaml.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-ocaml-plugin/CODE_OF_CONDUCT.adoc b/asdf-ocaml-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-ocaml-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-ocaml-plugin/CODE_OF_CONDUCT.md b/asdf-ocaml-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-ocaml-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-ocaml-plugin/CONTRIBUTING.adoc b/asdf-ocaml-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-ocaml-plugin/CONTRIBUTING.adoc +++ b/asdf-ocaml-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-ocaml-plugin/CONTRIBUTING.md b/asdf-ocaml-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-ocaml-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-ocaml-plugin/README.adoc b/asdf-ocaml-plugin/README.adoc index d08e1dd2..434b0833 100644 --- a/asdf-ocaml-plugin/README.adoc +++ b/asdf-ocaml-plugin/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-ocaml -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-ocaml-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-ocaml-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-ocaml-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-ocaml-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://ocaml.org[OCaml]. -**All repos with foreign function interfaces MUST follow this standard:** +Functional programming language. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add ocaml https://github.com/hyperpolymath/asdf-ocaml-plugin.git +---- -=== Web Projects +ocaml: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all ocaml -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install ocaml latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global ocaml latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now ocaml commands are available +ocaml --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list ocaml -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local ocaml -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall ocaml ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-ocaml-plugin/README.md b/asdf-ocaml-plugin/README.md deleted file mode 100644 index 5ad2c9bd..00000000 --- a/asdf-ocaml-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-ocaml - -[![Build](https://github.com/hyperpolymath/asdf-ocaml-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-ocaml-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-ocaml-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-ocaml-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [OCaml](https://ocaml.org). - -Functional programming language. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add ocaml https://github.com/hyperpolymath/asdf-ocaml-plugin.git -``` - -ocaml: - -```bash -# Show all installable versions -asdf list-all ocaml - -# Install specific version -asdf install ocaml latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global ocaml latest - -# Now ocaml commands are available -ocaml --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list ocaml - -# Set local version for current directory -asdf local ocaml - -# Uninstall a version -asdf uninstall ocaml -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-ocaml-plugin/SECURITY.adoc b/asdf-ocaml-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-ocaml-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-ocaml-plugin/SECURITY.md b/asdf-ocaml-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-ocaml-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-opa-plugin/ABI-FFI-README.adoc b/asdf-opa-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..b78e8453 --- /dev/null +++ b/asdf-opa-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== OPA ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/opa.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libopa.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +opa/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── opa.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── opa.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/opa.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "opa.h" + +int main() { + void* handle = opa_init(); + if (!handle) return 1; + + int result = opa_process(handle, 42); + if (result != 0) { + const char* err = opa_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + opa_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lopa -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import OPA.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "opa")] +extern "C" { + fn opa_init() -> *mut std::ffi::c_void; + fn opa_free(handle: *mut std::ffi::c_void); + fn opa_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = opa_init(); + assert!(!handle.is_null()); + + let result = opa_process(handle, 42); + assert_eq!(result, 0); + + opa_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libopa = "libopa" + +function init() + handle = ccall((:opa_init, libopa), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:opa_process, libopa), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:opa_free, libopa), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/opa.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-opa-plugin/ABI-FFI-README.md b/asdf-opa-plugin/ABI-FFI-README.md deleted file mode 100644 index 0bafe4a2..00000000 --- a/asdf-opa-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# OPA ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/opa.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libopa.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -opa/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── opa.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── opa.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/opa.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "opa.h" - -int main() { - void* handle = opa_init(); - if (!handle) return 1; - - int result = opa_process(handle, 42); - if (result != 0) { - const char* err = opa_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - opa_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lopa -L./zig-out/lib -``` - -### From Idris2 - -```idris -import OPA.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "opa")] -extern "C" { - fn opa_init() -> *mut std::ffi::c_void; - fn opa_free(handle: *mut std::ffi::c_void); - fn opa_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = opa_init(); - assert!(!handle.is_null()); - - let result = opa_process(handle, 42); - assert_eq!(result, 0); - - opa_free(handle); - } -} -``` - -### From Julia - -```julia -const libopa = "libopa" - -function init() - handle = ccall((:opa_init, libopa), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:opa_process, libopa), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:opa_free, libopa), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/opa.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-opa-plugin/CODE_OF_CONDUCT.adoc b/asdf-opa-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-opa-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-opa-plugin/CODE_OF_CONDUCT.md b/asdf-opa-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-opa-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-opa-plugin/CONTRIBUTING.adoc b/asdf-opa-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-opa-plugin/CONTRIBUTING.adoc +++ b/asdf-opa-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-opa-plugin/CONTRIBUTING.md b/asdf-opa-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-opa-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-opa-plugin/README.adoc b/asdf-opa-plugin/README.adoc index d08e1dd2..1c1f19b4 100644 --- a/asdf-opa-plugin/README.adoc +++ b/asdf-opa-plugin/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-opa -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-opa-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-opa-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-opa-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-opa-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://www.openpolicyagent.org[Open Policy Agent]. -**All repos with foreign function interfaces MUST follow this standard:** +Policy engine. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add opa https://github.com/hyperpolymath/asdf-opa-plugin.git +---- -=== Web Projects +opa: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all opa -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install opa latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global opa latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now opa commands are available +opa --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list opa -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local opa -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall opa ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-opa-plugin/README.md b/asdf-opa-plugin/README.md deleted file mode 100644 index de54dba8..00000000 --- a/asdf-opa-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-opa - -[![Build](https://github.com/hyperpolymath/asdf-opa-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-opa-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-opa-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-opa-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Open Policy Agent](https://www.openpolicyagent.org). - -Policy engine. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add opa https://github.com/hyperpolymath/asdf-opa-plugin.git -``` - -opa: - -```bash -# Show all installable versions -asdf list-all opa - -# Install specific version -asdf install opa latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global opa latest - -# Now opa commands are available -opa --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list opa - -# Set local version for current directory -asdf local opa - -# Uninstall a version -asdf uninstall opa -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-opa-plugin/SECURITY.adoc b/asdf-opa-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-opa-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-opa-plugin/SECURITY.md b/asdf-opa-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-opa-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-openlitespeed-plugin/ABI-FFI-README.adoc b/asdf-openlitespeed-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..43898c94 --- /dev/null +++ b/asdf-openlitespeed-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== OPENLITESPEED ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/openlitespeed.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libopenlitespeed.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +openlitespeed/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── openlitespeed.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── openlitespeed.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/openlitespeed.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "openlitespeed.h" + +int main() { + void* handle = openlitespeed_init(); + if (!handle) return 1; + + int result = openlitespeed_process(handle, 42); + if (result != 0) { + const char* err = openlitespeed_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + openlitespeed_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lopenlitespeed -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import OPENLITESPEED.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "openlitespeed")] +extern "C" { + fn openlitespeed_init() -> *mut std::ffi::c_void; + fn openlitespeed_free(handle: *mut std::ffi::c_void); + fn openlitespeed_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = openlitespeed_init(); + assert!(!handle.is_null()); + + let result = openlitespeed_process(handle, 42); + assert_eq!(result, 0); + + openlitespeed_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libopenlitespeed = "libopenlitespeed" + +function init() + handle = ccall((:openlitespeed_init, libopenlitespeed), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:openlitespeed_process, libopenlitespeed), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:openlitespeed_free, libopenlitespeed), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/openlitespeed.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-openlitespeed-plugin/ABI-FFI-README.md b/asdf-openlitespeed-plugin/ABI-FFI-README.md deleted file mode 100644 index c3f2c832..00000000 --- a/asdf-openlitespeed-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# OPENLITESPEED ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/openlitespeed.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libopenlitespeed.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -openlitespeed/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── openlitespeed.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── openlitespeed.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/openlitespeed.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "openlitespeed.h" - -int main() { - void* handle = openlitespeed_init(); - if (!handle) return 1; - - int result = openlitespeed_process(handle, 42); - if (result != 0) { - const char* err = openlitespeed_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - openlitespeed_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lopenlitespeed -L./zig-out/lib -``` - -### From Idris2 - -```idris -import OPENLITESPEED.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "openlitespeed")] -extern "C" { - fn openlitespeed_init() -> *mut std::ffi::c_void; - fn openlitespeed_free(handle: *mut std::ffi::c_void); - fn openlitespeed_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = openlitespeed_init(); - assert!(!handle.is_null()); - - let result = openlitespeed_process(handle, 42); - assert_eq!(result, 0); - - openlitespeed_free(handle); - } -} -``` - -### From Julia - -```julia -const libopenlitespeed = "libopenlitespeed" - -function init() - handle = ccall((:openlitespeed_init, libopenlitespeed), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:openlitespeed_process, libopenlitespeed), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:openlitespeed_free, libopenlitespeed), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/openlitespeed.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-openlitespeed-plugin/CODE_OF_CONDUCT.adoc b/asdf-openlitespeed-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-openlitespeed-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-openlitespeed-plugin/CODE_OF_CONDUCT.md b/asdf-openlitespeed-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-openlitespeed-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-openlitespeed-plugin/CONTRIBUTING.adoc b/asdf-openlitespeed-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-openlitespeed-plugin/CONTRIBUTING.adoc +++ b/asdf-openlitespeed-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-openlitespeed-plugin/CONTRIBUTING.md b/asdf-openlitespeed-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-openlitespeed-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-openlitespeed-plugin/README.adoc b/asdf-openlitespeed-plugin/README.adoc index d08e1dd2..4ec2b20f 100644 --- a/asdf-openlitespeed-plugin/README.adoc +++ b/asdf-openlitespeed-plugin/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-openlitespeed -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-openlitespeed-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-openlitespeed-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-openlitespeed-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-openlitespeed-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://openlitespeed.org[OpenLiteSpeed]. -**All repos with foreign function interfaces MUST follow this standard:** +High-performance web server. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add openlitespeed https://github.com/hyperpolymath/asdf-openlitespeed-plugin.git +---- -=== Web Projects +openlitespeed: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all openlitespeed -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install openlitespeed latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global openlitespeed latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now openlitespeed commands are available +openlitespeed --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list openlitespeed -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local openlitespeed -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall openlitespeed ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-openlitespeed-plugin/README.md b/asdf-openlitespeed-plugin/README.md deleted file mode 100644 index 967acbf5..00000000 --- a/asdf-openlitespeed-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-openlitespeed - -[![Build](https://github.com/hyperpolymath/asdf-openlitespeed-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-openlitespeed-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-openlitespeed-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-openlitespeed-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [OpenLiteSpeed](https://openlitespeed.org). - -High-performance web server. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add openlitespeed https://github.com/hyperpolymath/asdf-openlitespeed-plugin.git -``` - -openlitespeed: - -```bash -# Show all installable versions -asdf list-all openlitespeed - -# Install specific version -asdf install openlitespeed latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global openlitespeed latest - -# Now openlitespeed commands are available -openlitespeed --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list openlitespeed - -# Set local version for current directory -asdf local openlitespeed - -# Uninstall a version -asdf uninstall openlitespeed -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-openlitespeed-plugin/SECURITY.adoc b/asdf-openlitespeed-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-openlitespeed-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-openlitespeed-plugin/SECURITY.md b/asdf-openlitespeed-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-openlitespeed-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-openssh-plugin/ABI-FFI-README.adoc b/asdf-openssh-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..36317683 --- /dev/null +++ b/asdf-openssh-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== OPENSSH ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/openssh.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libopenssh.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +openssh/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── openssh.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── openssh.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/openssh.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "openssh.h" + +int main() { + void* handle = openssh_init(); + if (!handle) return 1; + + int result = openssh_process(handle, 42); + if (result != 0) { + const char* err = openssh_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + openssh_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lopenssh -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import OPENSSH.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "openssh")] +extern "C" { + fn openssh_init() -> *mut std::ffi::c_void; + fn openssh_free(handle: *mut std::ffi::c_void); + fn openssh_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = openssh_init(); + assert!(!handle.is_null()); + + let result = openssh_process(handle, 42); + assert_eq!(result, 0); + + openssh_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libopenssh = "libopenssh" + +function init() + handle = ccall((:openssh_init, libopenssh), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:openssh_process, libopenssh), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:openssh_free, libopenssh), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/openssh.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-openssh-plugin/ABI-FFI-README.md b/asdf-openssh-plugin/ABI-FFI-README.md deleted file mode 100644 index e6a77f77..00000000 --- a/asdf-openssh-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# OPENSSH ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/openssh.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libopenssh.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -openssh/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── openssh.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── openssh.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/openssh.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "openssh.h" - -int main() { - void* handle = openssh_init(); - if (!handle) return 1; - - int result = openssh_process(handle, 42); - if (result != 0) { - const char* err = openssh_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - openssh_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lopenssh -L./zig-out/lib -``` - -### From Idris2 - -```idris -import OPENSSH.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "openssh")] -extern "C" { - fn openssh_init() -> *mut std::ffi::c_void; - fn openssh_free(handle: *mut std::ffi::c_void); - fn openssh_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = openssh_init(); - assert!(!handle.is_null()); - - let result = openssh_process(handle, 42); - assert_eq!(result, 0); - - openssh_free(handle); - } -} -``` - -### From Julia - -```julia -const libopenssh = "libopenssh" - -function init() - handle = ccall((:openssh_init, libopenssh), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:openssh_process, libopenssh), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:openssh_free, libopenssh), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/openssh.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-openssh-plugin/CODE_OF_CONDUCT.adoc b/asdf-openssh-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-openssh-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-openssh-plugin/CODE_OF_CONDUCT.md b/asdf-openssh-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-openssh-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-openssh-plugin/CONTRIBUTING.adoc b/asdf-openssh-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-openssh-plugin/CONTRIBUTING.adoc +++ b/asdf-openssh-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-openssh-plugin/CONTRIBUTING.md b/asdf-openssh-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-openssh-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-openssh-plugin/README.adoc b/asdf-openssh-plugin/README.adoc index d08e1dd2..6b5d8461 100644 --- a/asdf-openssh-plugin/README.adoc +++ b/asdf-openssh-plugin/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-openssh -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-openssh-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-openssh-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-openssh-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-openssh-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://www.openssh.com[OpenSSH]. -**All repos with foreign function interfaces MUST follow this standard:** +SSH connectivity tools. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add openssh https://github.com/hyperpolymath/asdf-openssh-plugin.git +---- -=== Web Projects +openssh: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all openssh -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install openssh latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global openssh latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now openssh commands are available +openssh --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list openssh -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local openssh -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall openssh ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-openssh-plugin/README.md b/asdf-openssh-plugin/README.md deleted file mode 100644 index 0d151fcd..00000000 --- a/asdf-openssh-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-openssh - -[![Build](https://github.com/hyperpolymath/asdf-openssh-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-openssh-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-openssh-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-openssh-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [OpenSSH](https://www.openssh.com). - -SSH connectivity tools. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add openssh https://github.com/hyperpolymath/asdf-openssh-plugin.git -``` - -openssh: - -```bash -# Show all installable versions -asdf list-all openssh - -# Install specific version -asdf install openssh latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global openssh latest - -# Now openssh commands are available -openssh --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list openssh - -# Set local version for current directory -asdf local openssh - -# Uninstall a version -asdf uninstall openssh -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-openssh-plugin/SECURITY.adoc b/asdf-openssh-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-openssh-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-openssh-plugin/SECURITY.md b/asdf-openssh-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-openssh-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-openssl-plugin/ABI-FFI-README.adoc b/asdf-openssl-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..279d3f42 --- /dev/null +++ b/asdf-openssl-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== OPENSSL ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/openssl.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libopenssl.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +openssl/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── openssl.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── openssl.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/openssl.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "openssl.h" + +int main() { + void* handle = openssl_init(); + if (!handle) return 1; + + int result = openssl_process(handle, 42); + if (result != 0) { + const char* err = openssl_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + openssl_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lopenssl -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import OPENSSL.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "openssl")] +extern "C" { + fn openssl_init() -> *mut std::ffi::c_void; + fn openssl_free(handle: *mut std::ffi::c_void); + fn openssl_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = openssl_init(); + assert!(!handle.is_null()); + + let result = openssl_process(handle, 42); + assert_eq!(result, 0); + + openssl_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libopenssl = "libopenssl" + +function init() + handle = ccall((:openssl_init, libopenssl), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:openssl_process, libopenssl), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:openssl_free, libopenssl), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/openssl.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-openssl-plugin/ABI-FFI-README.md b/asdf-openssl-plugin/ABI-FFI-README.md deleted file mode 100644 index a541fd49..00000000 --- a/asdf-openssl-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# OPENSSL ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/openssl.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libopenssl.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -openssl/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── openssl.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── openssl.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/openssl.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "openssl.h" - -int main() { - void* handle = openssl_init(); - if (!handle) return 1; - - int result = openssl_process(handle, 42); - if (result != 0) { - const char* err = openssl_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - openssl_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lopenssl -L./zig-out/lib -``` - -### From Idris2 - -```idris -import OPENSSL.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "openssl")] -extern "C" { - fn openssl_init() -> *mut std::ffi::c_void; - fn openssl_free(handle: *mut std::ffi::c_void); - fn openssl_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = openssl_init(); - assert!(!handle.is_null()); - - let result = openssl_process(handle, 42); - assert_eq!(result, 0); - - openssl_free(handle); - } -} -``` - -### From Julia - -```julia -const libopenssl = "libopenssl" - -function init() - handle = ccall((:openssl_init, libopenssl), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:openssl_process, libopenssl), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:openssl_free, libopenssl), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/openssl.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-openssl-plugin/CODE_OF_CONDUCT.adoc b/asdf-openssl-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-openssl-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-openssl-plugin/CODE_OF_CONDUCT.md b/asdf-openssl-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-openssl-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-openssl-plugin/CONTRIBUTING.adoc b/asdf-openssl-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-openssl-plugin/CONTRIBUTING.adoc +++ b/asdf-openssl-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-openssl-plugin/CONTRIBUTING.md b/asdf-openssl-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-openssl-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-openssl-plugin/README.adoc b/asdf-openssl-plugin/README.adoc index d08e1dd2..b121263d 100644 --- a/asdf-openssl-plugin/README.adoc +++ b/asdf-openssl-plugin/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-openssl -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-openssl-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-openssl-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-openssl-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-openssl-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://www.openssl.org[OpenSSL]. -**All repos with foreign function interfaces MUST follow this standard:** +TLS/SSL cryptography. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add openssl https://github.com/hyperpolymath/asdf-openssl-plugin.git +---- -=== Web Projects +openssl: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all openssl -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install openssl latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global openssl latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now openssl commands are available +openssl --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list openssl -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local openssl -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall openssl ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-openssl-plugin/README.md b/asdf-openssl-plugin/README.md deleted file mode 100644 index add8b9f4..00000000 --- a/asdf-openssl-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-openssl - -[![Build](https://github.com/hyperpolymath/asdf-openssl-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-openssl-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-openssl-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-openssl-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [OpenSSL](https://www.openssl.org). - -TLS/SSL cryptography. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add openssl https://github.com/hyperpolymath/asdf-openssl-plugin.git -``` - -openssl: - -```bash -# Show all installable versions -asdf list-all openssl - -# Install specific version -asdf install openssl latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global openssl latest - -# Now openssl commands are available -openssl --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list openssl - -# Set local version for current directory -asdf local openssl - -# Uninstall a version -asdf uninstall openssl -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-openssl-plugin/SECURITY.adoc b/asdf-openssl-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-openssl-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-openssl-plugin/SECURITY.md b/asdf-openssl-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-openssl-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-orchid-plugin/ABI-FFI-README.adoc b/asdf-orchid-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..37457c75 --- /dev/null +++ b/asdf-orchid-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== ORCHID ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/orchid.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to liborchid.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +orchid/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── orchid.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── orchid.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/orchid.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "orchid.h" + +int main() { + void* handle = orchid_init(); + if (!handle) return 1; + + int result = orchid_process(handle, 42); + if (result != 0) { + const char* err = orchid_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + orchid_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lorchid -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import ORCHID.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "orchid")] +extern "C" { + fn orchid_init() -> *mut std::ffi::c_void; + fn orchid_free(handle: *mut std::ffi::c_void); + fn orchid_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = orchid_init(); + assert!(!handle.is_null()); + + let result = orchid_process(handle, 42); + assert_eq!(result, 0); + + orchid_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const liborchid = "liborchid" + +function init() + handle = ccall((:orchid_init, liborchid), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:orchid_process, liborchid), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:orchid_free, liborchid), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/orchid.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-orchid-plugin/ABI-FFI-README.md b/asdf-orchid-plugin/ABI-FFI-README.md deleted file mode 100644 index 8a8a6412..00000000 --- a/asdf-orchid-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# ORCHID ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/orchid.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to liborchid.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -orchid/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── orchid.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── orchid.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/orchid.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "orchid.h" - -int main() { - void* handle = orchid_init(); - if (!handle) return 1; - - int result = orchid_process(handle, 42); - if (result != 0) { - const char* err = orchid_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - orchid_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lorchid -L./zig-out/lib -``` - -### From Idris2 - -```idris -import ORCHID.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "orchid")] -extern "C" { - fn orchid_init() -> *mut std::ffi::c_void; - fn orchid_free(handle: *mut std::ffi::c_void); - fn orchid_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = orchid_init(); - assert!(!handle.is_null()); - - let result = orchid_process(handle, 42); - assert_eq!(result, 0); - - orchid_free(handle); - } -} -``` - -### From Julia - -```julia -const liborchid = "liborchid" - -function init() - handle = ccall((:orchid_init, liborchid), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:orchid_process, liborchid), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:orchid_free, liborchid), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/orchid.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-orchid-plugin/CODE_OF_CONDUCT.adoc b/asdf-orchid-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-orchid-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-orchid-plugin/CODE_OF_CONDUCT.md b/asdf-orchid-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-orchid-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-orchid-plugin/CONTRIBUTING.adoc b/asdf-orchid-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-orchid-plugin/CONTRIBUTING.adoc +++ b/asdf-orchid-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-orchid-plugin/CONTRIBUTING.md b/asdf-orchid-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-orchid-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-orchid-plugin/README.adoc b/asdf-orchid-plugin/README.adoc index d08e1dd2..c91f2a58 100644 --- a/asdf-orchid-plugin/README.adoc +++ b/asdf-orchid-plugin/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-orchid -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-orchid-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-orchid-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-orchid-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-orchid-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://orchid.software[Orchid]. -**All repos with foreign function interfaces MUST follow this standard:** +Static site generator. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add orchid https://github.com/hyperpolymath/asdf-orchid-plugin.git +---- -=== Web Projects +orchid: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all orchid -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install orchid latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global orchid latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now orchid commands are available +orchid --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list orchid -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local orchid -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall orchid ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-orchid-plugin/README.md b/asdf-orchid-plugin/README.md deleted file mode 100644 index 8ea1b9e8..00000000 --- a/asdf-orchid-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-orchid - -[![Build](https://github.com/hyperpolymath/asdf-orchid-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-orchid-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-orchid-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-orchid-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Orchid](https://orchid.software). - -Static site generator. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add orchid https://github.com/hyperpolymath/asdf-orchid-plugin.git -``` - -orchid: - -```bash -# Show all installable versions -asdf list-all orchid - -# Install specific version -asdf install orchid latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global orchid latest - -# Now orchid commands are available -orchid --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list orchid - -# Set local version for current directory -asdf local orchid - -# Uninstall a version -asdf uninstall orchid -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-orchid-plugin/SECURITY.adoc b/asdf-orchid-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-orchid-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-orchid-plugin/SECURITY.md b/asdf-orchid-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-orchid-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/ada/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/ada/ABI-FFI-README.adoc new file mode 100644 index 00000000..e958d332 --- /dev/null +++ b/asdf-plugin-collection/plugins/ada/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== ADA ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/ada.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libada.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +ada/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── ada.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── ada.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/ada.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "ada.h" + +int main() { + void* handle = ada_init(); + if (!handle) return 1; + + int result = ada_process(handle, 42); + if (result != 0) { + const char* err = ada_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + ada_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lada -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import ADA.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "ada")] +extern "C" { + fn ada_init() -> *mut std::ffi::c_void; + fn ada_free(handle: *mut std::ffi::c_void); + fn ada_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = ada_init(); + assert!(!handle.is_null()); + + let result = ada_process(handle, 42); + assert_eq!(result, 0); + + ada_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libada = "libada" + +function init() + handle = ccall((:ada_init, libada), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:ada_process, libada), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:ada_free, libada), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/ada.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/ada/ABI-FFI-README.md b/asdf-plugin-collection/plugins/ada/ABI-FFI-README.md deleted file mode 100644 index c9cb98b9..00000000 --- a/asdf-plugin-collection/plugins/ada/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# ADA ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/ada.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libada.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -ada/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── ada.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── ada.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/ada.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "ada.h" - -int main() { - void* handle = ada_init(); - if (!handle) return 1; - - int result = ada_process(handle, 42); - if (result != 0) { - const char* err = ada_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - ada_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lada -L./zig-out/lib -``` - -### From Idris2 - -```idris -import ADA.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "ada")] -extern "C" { - fn ada_init() -> *mut std::ffi::c_void; - fn ada_free(handle: *mut std::ffi::c_void); - fn ada_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = ada_init(); - assert!(!handle.is_null()); - - let result = ada_process(handle, 42); - assert_eq!(result, 0); - - ada_free(handle); - } -} -``` - -### From Julia - -```julia -const libada = "libada" - -function init() - handle = ccall((:ada_init, libada), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:ada_process, libada), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:ada_free, libada), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/ada.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/ada/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/ada/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/ada/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/ada/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/ada/CODE_OF_CONDUCT.md deleted file mode 100644 index caeda1c6..00000000 --- a/asdf-plugin-collection/plugins/ada/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,27 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. - diff --git a/asdf-plugin-collection/plugins/ada/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/ada/CONTRIBUTING.adoc index eb045d61..084ee525 100644 --- a/asdf-plugin-collection/plugins/ada/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/ada/CONTRIBUTING.adoc @@ -1,20 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/ada/CONTRIBUTING.md b/asdf-plugin-collection/plugins/ada/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/ada/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/ada/README.adoc b/asdf-plugin-collection/plugins/ada/README.adoc index 99d06e54..339286c8 100644 --- a/asdf-plugin-collection/plugins/ada/README.adoc +++ b/asdf-plugin-collection/plugins/ada/README.adoc @@ -1,632 +1,83 @@ -= asdf-ada +== asdf-ada -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] -image:https://img.shields.io/badge/Philosophy-Palimpsest-indigo.svg[Palimpsest,link="https://github.com/hyperpolymath/palimpsest-license"] +https://github.com/hyperpolymath/asdf-ada-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-ada-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-ada-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-ada-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] +https://asdf-vm.com[asdf] plugin for +https://www.adacore.com/community[GNAT Ada Compiler]. -:author: hyperpolymath -:revnumber: 0.1.0 -:toc: macro -:toclevels: 3 -:icons: font -:source-highlighter: rouge -:experimental: -:url-asdf: https://asdf-vm.com -:url-gnat: https://www.adacore.com/download -:url-alire: https://alire.ada.dev -:url-ada-lang: https://ada-lang.io -:url-repo: https://github.com/hyperpolymath/asdf-ada-plugin +Ada compiler from AdaCore. -image:https://img.shields.io/github/license/hyperpolymath/asdf-ada-plugin?style=flat-square[License,link=LICENSE] -image:https://img.shields.io/github/v/release/hyperpolymath/asdf-ada-plugin?style=flat-square[Release,link={url-repo}/releases] -image:https://img.shields.io/github/actions/workflow/status/hyperpolymath/asdf-ada-plugin/ci.yml?branch=main&style=flat-square[Build Status,link={url-repo}/actions] -image:https://img.shields.io/badge/asdf-plugin-blue?style=flat-square[asdf Plugin,link={url-asdf}] +=== Contents -[.lead] -An {url-asdf}[asdf] plugin to manage https://ada-lang.io[Ada/GNAT] compiler versions seamlessly across projects. - -toc::[] - -== Overview - -=== What is Ada? - -https://ada-lang.io[Ada] is a structured, statically typed, imperative, and object-oriented high-level programming language designed for safety-critical and mission-critical systems. Originally developed in the 1980s for the U.S. Department of Defense, Ada is renowned for: - -* **Strong typing** — Catches errors at compile time rather than runtime -* **Built-in concurrency** — Native tasking support for parallel programming -* **Contract-based programming** — Pre/post conditions and type invariants -* **Real-time systems support** — Deterministic behavior for embedded systems -* **Long-term maintainability** — Designed for systems with 30+ year lifecycles - -Ada is used in aerospace (Boeing, Airbus), defense systems, rail transportation, medical devices, and financial systems where reliability is paramount. - -=== What is asdf? - -{url-asdf}[asdf] is a universal version manager that allows you to manage multiple runtime versions with a single CLI tool. Instead of juggling separate version managers for each language, asdf provides one interface to rule them all. - -=== Why asdf-ada? - -Managing Ada/GNAT compiler versions traditionally requires manual downloads, environment variable configuration, and careful PATH management. `asdf-ada` simplifies this by providing: - -[cols="1,3"] -|=== -|Feature |Benefit - -|**Version Switching** -|Switch between GNAT versions instantly per project - -|**Project Isolation** -|Each project can specify its required Ada version via `.tool-versions` - -|**Reproducible Builds** -|Team members and CI/CD pipelines use identical compiler versions - -|**Multiple Distributions** -|Support for FSF GNAT, GNAT Community, and Alire-managed toolchains - -|**Cross-Platform** -|Works on Linux, macOS, and Windows (via WSL) -|=== - -== Prerequisites - -=== System Requirements - -[cols="1,2,3"] -|=== -|Platform |Minimum Version |Notes - -|**Linux** -|Ubuntu 20.04+ / Fedora 35+ / Debian 11+ -|x86_64 and aarch64 supported - -|**macOS** -|macOS 11 (Big Sur)+ -|Intel and Apple Silicon (M1/M2/M3) - -|**Windows** -|Windows 10+ with WSL2 -|Native support planned for future releases -|=== +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] === Dependencies -Before installing the plugin, ensure you have the following: - -[source,bash] ----- -# Debian/Ubuntu -sudo apt-get update -sudo apt-get install -y curl git build-essential libc6-dev - -# Fedora/RHEL -sudo dnf install -y curl git gcc glibc-devel - -# macOS (via Homebrew) -brew install curl git -xcode-select --install # For build tools - -# Arch Linux -sudo pacman -S curl git base-devel ----- - -=== asdf Installation - -If you haven't installed asdf yet: - -[source,bash] ----- -# Clone asdf -git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.0 - -# Add to your shell (bash) -echo '. "$HOME/.asdf/asdf.sh"' >> ~/.bashrc -echo '. "$HOME/.asdf/completions/asdf.bash"' >> ~/.bashrc - -# Add to your shell (zsh) -echo '. "$HOME/.asdf/asdf.sh"' >> ~/.zshrc +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -# Add to your shell (fish) -echo 'source ~/.asdf/asdf.fish' >> ~/.config/fish/config.fish +=== Install -# Reload your shell -exec $SHELL ----- - -== Installation - -=== Adding the Plugin +Plugin: [source,bash] ---- -# Add the asdf-ada plugin asdf plugin add ada https://github.com/hyperpolymath/asdf-ada-plugin.git - -# Verify installation -asdf plugin list ---- -=== Installing Ada/GNAT Versions +ada: [source,bash] ---- -# List all available versions -asdf list all ada - -# Install a specific version -asdf install ada 14.1.0 # FSF GNAT 14.1.0 -asdf install ada community-2021 # GNAT Community 2021 -asdf install ada alire-latest # Latest via Alire +# Show all installable versions +asdf list-all ada -# Install the latest stable version +# Install specific version asdf install ada latest ----- - -=== Setting the Version - -[source,bash] ----- -# Set global default (used when no local version is specified) -asdf global ada 14.1.0 - -# Set local version for current project (creates .tool-versions) -asdf local ada 14.1.0 - -# Set version for current shell session only -asdf shell ada 14.1.0 -# Verify the active version -asdf current ada -gnatmake --version ----- - -== Usage - -=== Project Configuration +# Set a version globally (in your ~/.tool-versions file) +asdf global ada latest -Create a `.tool-versions` file in your project root: - -[source] ----- -ada 14.1.0 +# Now ada commands are available +ada --version ---- -When you `cd` into the project directory, asdf automatically activates the specified version. +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -=== Available Commands +=== Usage [source,bash] ---- # List installed versions asdf list ada -# Show current version -asdf current ada +# Set local version for current directory +asdf local ada # Uninstall a version -asdf uninstall ada 13.2.0 - -# Reshim after installing Ada tools (e.g., via Alire) -asdf reshim ada - -# Show installation path -asdf where ada 14.1.0 ----- - -=== Environment Variables - -The plugin respects and sets the following environment variables: - -[cols="2,3,2"] -|=== -|Variable |Description |Default - -|`ASDF_ADA_DISTRIBUTION` -|Preferred distribution (`fsf`, `community`, `alire`) -|`fsf` - -|`ASDF_ADA_MIRROR` -|Custom mirror URL for downloads -|Official sources - -|`ASDF_ADA_SKIP_VERIFY` -|Skip checksum verification (`true`/`false`) -|`false` - -|`ASDF_ADA_INSTALL_GPRBUILD` -|Auto-install GPRbuild (`true`/`false`) -|`true` -|=== - -=== Integration with Build Tools - -==== GPRbuild - -[source,bash] ----- -# GPRbuild is included with most GNAT installations -gprbuild --version - -# Build an Ada project -gprbuild -P my_project.gpr ----- - -==== Alire - -{url-alire}[Alire] is Ada's package manager. You can use it alongside asdf: - -[source,bash] ----- -# Install Alire separately or use asdf-managed version -asdf install ada alire-latest - -# Initialize an Alire project -alr init my_project -cd my_project -alr build ----- - -==== SPARK Formal Verification - -For SPARK Pro users: - -[source,bash] ----- -# SPARK is included in GNAT Community editions -gnatprove --version - -# Run formal verification -gnatprove -P my_project.gpr ----- - -== Supported Versions - -=== FSF GNAT (GNU Ada) - -Official GNU Compiler Collection Ada frontend: - -[source] ----- -14.1.0, 14.0.0, 13.3.0, 13.2.0, 13.1.0 -12.4.0, 12.3.0, 12.2.0, 12.1.0 -11.5.0, 11.4.0, 11.3.0, 11.2.0, 11.1.0 -10.5.0, 10.4.0, 10.3.0 ----- - -=== GNAT Community Edition - -AdaCore's free community releases (discontinued after 2021): - -[source] +asdf uninstall ada ---- -community-2021 -community-2020 -community-2019 ----- - -=== Alire Toolchains - -Managed via the Alire package manager: -[source] ----- -alire-latest # Latest available via Alire -alire-native # Native toolchain via Alire ----- - -== Configuration - -=== Plugin Configuration File - -Create `~/.config/asdf-ada/config` for persistent settings: - -[source,ini] ----- -# Default distribution preference -distribution = fsf - -# Download mirror (leave empty for official sources) -mirror = - -# Verify checksums (recommended) -verify_checksums = true - -# Install GPRbuild automatically -install_gprbuild = true - -# Concurrent downloads -parallel_downloads = 4 ----- - -=== Platform-Specific Notes - -==== macOS Apple Silicon - -Native ARM64 builds are available for GNAT 13.1.0+. For older versions, Rosetta 2 emulation is used automatically. - -==== Linux ARM64 - -ARM64 builds are provided for: -- Raspberry Pi 4/5 (64-bit OS) -- AWS Graviton instances -- Other aarch64 systems - -==== Windows (WSL2) - -[source,bash] ----- -# Install WSL2 with Ubuntu -wsl --install -d Ubuntu - -# Inside WSL, install asdf and the plugin as normal -# See the Linux installation instructions above ----- - -== Troubleshooting - -=== Common Issues - -[qanda] -Version not found when running `gnatmake`:: -Run `asdf reshim ada` after installation and ensure your shell is properly configured. - -Download fails with SSL errors:: -Ensure `ca-certificates` is installed: `sudo apt-get install ca-certificates` - -"Permission denied" during installation:: -Check write permissions for `~/.asdf/installs/ada/` - -Slow downloads:: -Set `ASDF_ADA_MIRROR` to a geographically closer mirror. - -=== Getting Help - -1. Check the link:{url-repo}/issues[GitHub Issues] for known problems -2. Join the https://gitter.im/ada-lang/Lobby[Ada community chat] -3. Open a https://github.com/hyperpolymath/asdf-ada-plugin/issues/new[new issue] with: - - Your OS and version - - asdf version (`asdf --version`) - - Plugin version - - Full error output - -== Contributing - -We welcome contributions! Please see our link:CONTRIBUTING.adoc[Contributing Guide] for details. - -=== Quick Start for Contributors - -[source,bash] ----- -# Fork and clone -git clone https://github.com/YOUR_USERNAME/asdf-ada-plugin.git -cd asdf-ada-plugin - -# Create a feature branch -git checkout -b feature/your-feature-name - -# Make changes and test -./scripts/test.sh - -# Submit a pull request ----- - -=== Code of Conduct - -This project adheres to the https://www.contributor-covenant.org/[Contributor Covenant]. Please read our link:CODE_OF_CONDUCT.adoc[Code of Conduct] before participating. - -== Roadmap - -This roadmap outlines the planned development phases for `asdf-ada`. - -=== Phase 1: Foundation (v0.1.0) icon:wrench[] - -*Status:* 🚧 In Progress - -[%interactive] -* [ ] Core plugin structure following asdf plugin template -* [ ] `bin/list-all` — Fetch available GNAT versions from upstream -* [ ] `bin/download` — Download GNAT releases -* [ ] `bin/install` — Install and configure GNAT toolchain -* [ ] `bin/latest-stable` — Resolve latest stable version -* [ ] Basic FSF GNAT support (Linux x86_64) -* [ ] README and initial documentation -* [ ] GitHub Actions CI/CD pipeline -* [ ] Basic test suite using Bats - -=== Phase 2: Multi-Platform Support (v0.2.0) icon:desktop[] - -*Status:* 📋 Planned - -[%interactive] -* [ ] macOS x86_64 support -* [ ] macOS ARM64 (Apple Silicon) support -* [ ] Linux ARM64 support -* [ ] Windows WSL2 documentation and testing -* [ ] Checksum verification for all downloads -* [ ] Progress indicators during download/install -* [ ] Improved error messages and logging - -=== Phase 3: Extended Distribution Support (v0.3.0) icon:cubes[] - -*Status:* 📋 Planned - -[%interactive] -* [ ] GNAT Community Edition support (2019-2021) -* [ ] Alire toolchain integration -* [ ] AdaCore GNAT Pro stub support (license required) -* [ ] Custom mirror configuration -* [ ] Version aliases (`lts`, `stable`, `latest`) -* [ ] `bin/help` plugin subcommands - -=== Phase 4: Developer Experience (v0.4.0) icon:star[] - -*Status:* 📋 Planned - -[%interactive] -* [ ] Automatic GPRbuild installation -* [ ] GNATcov integration -* [ ] SPARK tools inclusion -* [ ] Shell completions (bash, zsh, fish) -* [ ] Version constraint solving (semver support) -* [ ] `asdf-ada doctor` command for diagnostics - -=== Phase 5: Ecosystem Integration (v0.5.0) icon:plug[] - -*Status:* 📋 Planned - -[%interactive] -* [ ] Alire crate template generation -* [ ] VS Code Ada extension compatibility documentation -* [ ] GNAT Studio integration notes -* [ ] Docker/container image publishing -* [ ] CI/CD examples (GitHub Actions, GitLab CI, Jenkins) -* [ ] Guix flake support - -=== Phase 6: Enterprise & Polish (v1.0.0) icon:building[] - -*Status:* 🔮 Future - -[%interactive] -* [ ] Stable API with semantic versioning -* [ ] Comprehensive test coverage (90%+) -* [ ] Full documentation with tutorials -* [ ] Offline installation support -* [ ] Corporate proxy support -* [ ] Signed releases -* [ ] Official asdf plugin registry listing -* [ ] Community governance model - -=== Future Ideas icon:lightbulb[] - -These features are under consideration for post-1.0 releases: - -* **Cross-compilation toolchains** — ARM bare-metal, RISC-V targets -* **GNAT-LLVM support** — LLVM-based Ada compiler backend -* **Version diffing** — Show changelog between versions -* **Performance profiling integration** — GNATbench-like features -* **IDE project generation** — Templates for various editors -* **Dependency caching** — Speed up clean installs -* **Native Windows support** — Without WSL requirement - -== Mirrors - -This repository is mirrored to: - -* https://gitlab.com/hyperpolymath/asdf-ada-plugin[GitLab] -* https://codeberg.org/hyperpolymath/asdf-ada-plugin[Codeberg] -* https://bitbucket.org/hyperpolymath/asdf-ada-plugin[Bitbucket] - -== Related Projects - -* {url-asdf}[asdf] — The universal version manager -* {url-gnat}[GNAT Downloads] — Official AdaCore downloads -* {url-alire}[Alire] — Ada/SPARK package manager -* {url-ada-lang}[Ada Programming Language] — Official Ada resources -* https://learn.adacore.com[learn.adacore.com] — Free Ada/SPARK tutorials -* https://github.com/ohenley/awesome-ada[Awesome Ada] — Curated Ada resources - -== Hyperpolymath asdf Ecosystem - -This plugin is part of the **Hyperpolymath asdf ecosystem**, a layered architecture for managing developer tool versions. - -=== Ecosystem Architecture - -[source] ----- - ┌──────────────────────────┐ - │ asdf-control-tower │ ← Layer 3: Presentation - │ (docs + dashboard) │ - └───────────┬──────────────┘ - │ -┌──────────────────────────┐ │ ┌──────────────────────────┐ -│ asdf-ui-plugin │────┼────│ asdf-plugin-configurator │ ← Layer 2–3 -│ (visual UX; planned) │ │ │ (Rust CLI; config/policy)│ -└──────────────────────────┘ │ └──────────────────────────┘ - │ - ┌───────────┴───────────┐ - │ asdf-metaiconic-plugin│ ← Layer 1: Registry - │ (registry + schema) │ - └───────────┬───────────┘ - │ - ┌────────────────────────────────────────────────┐ - │ Individual asdf tool plugins (Layer 5) │ - │ │ - │ ★ asdf-ada-plugin ← YOU ARE HERE │ - │ asdf-neo4j-plugin │ - │ asdf-ghjk │ - │ …(68+ installable plugins) │ - └────────────────────────────────────────────────┘ ----- - -=== Layer Descriptions - -[cols="1,2,4"] -|=== -|Layer |Component |Purpose - -|**Layer 0** -|Infrastructure Spine -|Multi-forge mirroring, instant-sync, policy constraints (`.claude/CLAUDE.md`), community docs — present across all repos - -|**Layer 1** -|https://github.com/hyperpolymath/asdf-metaiconic-plugin[asdf-metaiconic-plugin] -|Canonical metadata registry: `registry/plugins.yaml`, category definitions, quality metrics, icon/branding standards - -|**Layer 2** -|https://github.com/hyperpolymath/asdf-plugin-configurator[asdf-plugin-configurator] -|Rust CLI for declarative plugin configuration — apply policy to machines/projects, consume registry for validation - -|**Layer 3** -|https://github.com/hyperpolymath/asdf-control-tower[asdf-control-tower] + https://github.com/hyperpolymath/asdf-ui-plugin[asdf-ui-plugin] -|Human-facing dashboard, documentation hub, visual discovery UI (planned) - -|**Layer 4** -|Domain Collections -|Category "umbrella" plugins (e.g., `asdf-security-plugin` for curated security toolsets) - -|**Layer 5** -|**Tool Plugins** ★ -|**Actual installable units** — implements `bin/list-all`, `bin/download`, `bin/install`, `bin/latest-stable`. This repo (`asdf-ada-plugin`) lives here. -|=== - -=== This Plugin's Role - -`asdf-ada-plugin` is a **Layer 5 tool plugin** — the actual "workhorse" that asdf uses to install and manage Ada/GNAT compiler versions. It: - -* Implements the asdf plugin contract (`bin/list-all`, `bin/download`, `bin/install`, `bin/latest-stable`) -* Fetches releases from the https://github.com/alire-project/GNAT-FSF-builds[GNAT-FSF-builds] upstream -* Provides checksum verification, multi-platform support, and robust error handling -* Is indexed by `asdf-metaiconic-plugin` for ecosystem-wide discovery -* Can be configured via `asdf-plugin-configurator` for team/project consistency - -=== Ecosystem Links - -* https://github.com/hyperpolymath/asdf-control-tower[asdf-control-tower] — Ecosystem documentation hub -* https://github.com/hyperpolymath/asdf-metaiconic-plugin[asdf-metaiconic-plugin] — Plugin registry and metadata -* https://github.com/hyperpolymath/asdf-plugin-configurator[asdf-plugin-configurator] — Policy enforcement CLI - -== License - -This project is licensed under the Palimpsest-MPL License v3.0 or later. -See the link:LICENSE[LICENSE] file for details. - -[source] ----- -SPDX-License-Identifier: CC-BY-SA-4.0 ----- +=== Contributing -== Acknowledgments +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. -* The {url-asdf}[asdf] team for creating the plugin ecosystem -* https://www.adacore.com[AdaCore] for maintaining GNAT -* The Ada community for keeping the language thriving -* All contributors who help improve this plugin +=== License ---- +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -[.text-center] -Made with ❤️ for the Ada community +''''' -[.text-center] -link:#[⬆ Back to Top] +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/ada/README.md b/asdf-plugin-collection/plugins/ada/README.md deleted file mode 100644 index 2caccbaa..00000000 --- a/asdf-plugin-collection/plugins/ada/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-ada - -[![Build](https://github.com/hyperpolymath/asdf-ada-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-ada-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-ada-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-ada-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [GNAT Ada Compiler](https://www.adacore.com/community). - -Ada compiler from AdaCore. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add ada https://github.com/hyperpolymath/asdf-ada-plugin.git -``` - -ada: - -```bash -# Show all installable versions -asdf list-all ada - -# Install specific version -asdf install ada latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global ada latest - -# Now ada commands are available -ada --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list ada - -# Set local version for current directory -asdf local ada - -# Uninstall a version -asdf uninstall ada -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/ada/SECURITY.adoc b/asdf-plugin-collection/plugins/ada/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/ada/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/ada/SECURITY.md b/asdf-plugin-collection/plugins/ada/SECURITY.md deleted file mode 100644 index 159a0b7a..00000000 --- a/asdf-plugin-collection/plugins/ada/SECURITY.md +++ /dev/null @@ -1,25 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection - diff --git a/asdf-plugin-collection/plugins/age/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/age/ABI-FFI-README.adoc new file mode 100644 index 00000000..e8fa780b --- /dev/null +++ b/asdf-plugin-collection/plugins/age/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== AGE ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/age.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libage.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +age/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── age.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── age.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/age.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "age.h" + +int main() { + void* handle = age_init(); + if (!handle) return 1; + + int result = age_process(handle, 42); + if (result != 0) { + const char* err = age_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + age_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lage -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import AGE.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "age")] +extern "C" { + fn age_init() -> *mut std::ffi::c_void; + fn age_free(handle: *mut std::ffi::c_void); + fn age_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = age_init(); + assert!(!handle.is_null()); + + let result = age_process(handle, 42); + assert_eq!(result, 0); + + age_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libage = "libage" + +function init() + handle = ccall((:age_init, libage), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:age_process, libage), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:age_free, libage), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/age.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/age/ABI-FFI-README.md b/asdf-plugin-collection/plugins/age/ABI-FFI-README.md deleted file mode 100644 index 1bcc978a..00000000 --- a/asdf-plugin-collection/plugins/age/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# AGE ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/age.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libage.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -age/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── age.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── age.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/age.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "age.h" - -int main() { - void* handle = age_init(); - if (!handle) return 1; - - int result = age_process(handle, 42); - if (result != 0) { - const char* err = age_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - age_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lage -L./zig-out/lib -``` - -### From Idris2 - -```idris -import AGE.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "age")] -extern "C" { - fn age_init() -> *mut std::ffi::c_void; - fn age_free(handle: *mut std::ffi::c_void); - fn age_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = age_init(); - assert!(!handle.is_null()); - - let result = age_process(handle, 42); - assert_eq!(result, 0); - - age_free(handle); - } -} -``` - -### From Julia - -```julia -const libage = "libage" - -function init() - handle = ccall((:age_init, libage), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:age_process, libage), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:age_free, libage), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/age.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/age/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/age/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/age/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/age/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/age/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/age/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/age/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/age/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/age/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/age/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/age/CONTRIBUTING.md b/asdf-plugin-collection/plugins/age/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/age/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/age/README.adoc b/asdf-plugin-collection/plugins/age/README.adoc index d08e1dd2..08505a04 100644 --- a/asdf-plugin-collection/plugins/age/README.adoc +++ b/asdf-plugin-collection/plugins/age/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-age -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-age-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-age-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-age-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-age-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://age-encryption.org[age]. -**All repos with foreign function interfaces MUST follow this standard:** +Simple, modern file encryption. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add age https://github.com/hyperpolymath/asdf-age-plugin.git +---- -=== Web Projects +age: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all age -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install age latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global age latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now age commands are available +age --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list age -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local age -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall age ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/age/README.md b/asdf-plugin-collection/plugins/age/README.md deleted file mode 100644 index 4f2a10bd..00000000 --- a/asdf-plugin-collection/plugins/age/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-age - -[![Build](https://github.com/hyperpolymath/asdf-age-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-age-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-age-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-age-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [age](https://age-encryption.org). - -Simple, modern file encryption. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add age https://github.com/hyperpolymath/asdf-age-plugin.git -``` - -age: - -```bash -# Show all installable versions -asdf list-all age - -# Install specific version -asdf install age latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global age latest - -# Now age commands are available -age --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list age - -# Set local version for current directory -asdf local age - -# Uninstall a version -asdf uninstall age -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/age/SECURITY.adoc b/asdf-plugin-collection/plugins/age/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/age/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/age/SECURITY.md b/asdf-plugin-collection/plugins/age/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/age/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/apko/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/apko/ABI-FFI-README.adoc new file mode 100644 index 00000000..cb968d83 --- /dev/null +++ b/asdf-plugin-collection/plugins/apko/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== APKO ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/apko.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libapko.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +apko/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── apko.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── apko.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/apko.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "apko.h" + +int main() { + void* handle = apko_init(); + if (!handle) return 1; + + int result = apko_process(handle, 42); + if (result != 0) { + const char* err = apko_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + apko_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lapko -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import APKO.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "apko")] +extern "C" { + fn apko_init() -> *mut std::ffi::c_void; + fn apko_free(handle: *mut std::ffi::c_void); + fn apko_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = apko_init(); + assert!(!handle.is_null()); + + let result = apko_process(handle, 42); + assert_eq!(result, 0); + + apko_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libapko = "libapko" + +function init() + handle = ccall((:apko_init, libapko), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:apko_process, libapko), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:apko_free, libapko), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/apko.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/apko/ABI-FFI-README.md b/asdf-plugin-collection/plugins/apko/ABI-FFI-README.md deleted file mode 100644 index b4a76026..00000000 --- a/asdf-plugin-collection/plugins/apko/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# APKO ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/apko.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libapko.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -apko/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── apko.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── apko.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/apko.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "apko.h" - -int main() { - void* handle = apko_init(); - if (!handle) return 1; - - int result = apko_process(handle, 42); - if (result != 0) { - const char* err = apko_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - apko_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lapko -L./zig-out/lib -``` - -### From Idris2 - -```idris -import APKO.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "apko")] -extern "C" { - fn apko_init() -> *mut std::ffi::c_void; - fn apko_free(handle: *mut std::ffi::c_void); - fn apko_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = apko_init(); - assert!(!handle.is_null()); - - let result = apko_process(handle, 42); - assert_eq!(result, 0); - - apko_free(handle); - } -} -``` - -### From Julia - -```julia -const libapko = "libapko" - -function init() - handle = ccall((:apko_init, libapko), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:apko_process, libapko), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:apko_free, libapko), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/apko.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/apko/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/apko/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/apko/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/apko/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/apko/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/apko/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/apko/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/apko/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/apko/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/apko/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/apko/CONTRIBUTING.md b/asdf-plugin-collection/plugins/apko/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/apko/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/apko/README.adoc b/asdf-plugin-collection/plugins/apko/README.adoc index d08e1dd2..349259da 100644 --- a/asdf-plugin-collection/plugins/apko/README.adoc +++ b/asdf-plugin-collection/plugins/apko/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-apko -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-apko-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-apko-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-apko-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-apko-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://github.com/chainguard-dev/apko[apko]. -**All repos with foreign function interfaces MUST follow this standard:** +OCI images from APK packages. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add apko https://github.com/hyperpolymath/asdf-apko-plugin.git +---- -=== Web Projects +apko: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all apko -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install apko latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global apko latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now apko commands are available +apko --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list apko -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local apko -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall apko ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/apko/README.md b/asdf-plugin-collection/plugins/apko/README.md deleted file mode 100644 index c43254a5..00000000 --- a/asdf-plugin-collection/plugins/apko/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-apko - -[![Build](https://github.com/hyperpolymath/asdf-apko-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-apko-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-apko-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-apko-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [apko](https://github.com/chainguard-dev/apko). - -OCI images from APK packages. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add apko https://github.com/hyperpolymath/asdf-apko-plugin.git -``` - -apko: - -```bash -# Show all installable versions -asdf list-all apko - -# Install specific version -asdf install apko latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global apko latest - -# Now apko commands are available -apko --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list apko - -# Set local version for current directory -asdf local apko - -# Uninstall a version -asdf uninstall apko -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/apko/SECURITY.adoc b/asdf-plugin-collection/plugins/apko/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/apko/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/apko/SECURITY.md b/asdf-plugin-collection/plugins/apko/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/apko/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/arangodb/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/arangodb/ABI-FFI-README.adoc new file mode 100644 index 00000000..f35cc374 --- /dev/null +++ b/asdf-plugin-collection/plugins/arangodb/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== ARANGODB ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/arangodb.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libarangodb.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +arangodb/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── arangodb.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── arangodb.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/arangodb.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "arangodb.h" + +int main() { + void* handle = arangodb_init(); + if (!handle) return 1; + + int result = arangodb_process(handle, 42); + if (result != 0) { + const char* err = arangodb_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + arangodb_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -larangodb -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import ARANGODB.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "arangodb")] +extern "C" { + fn arangodb_init() -> *mut std::ffi::c_void; + fn arangodb_free(handle: *mut std::ffi::c_void); + fn arangodb_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = arangodb_init(); + assert!(!handle.is_null()); + + let result = arangodb_process(handle, 42); + assert_eq!(result, 0); + + arangodb_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libarangodb = "libarangodb" + +function init() + handle = ccall((:arangodb_init, libarangodb), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:arangodb_process, libarangodb), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:arangodb_free, libarangodb), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/arangodb.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/arangodb/ABI-FFI-README.md b/asdf-plugin-collection/plugins/arangodb/ABI-FFI-README.md deleted file mode 100644 index 46999d03..00000000 --- a/asdf-plugin-collection/plugins/arangodb/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# ARANGODB ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/arangodb.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libarangodb.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -arangodb/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── arangodb.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── arangodb.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/arangodb.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "arangodb.h" - -int main() { - void* handle = arangodb_init(); - if (!handle) return 1; - - int result = arangodb_process(handle, 42); - if (result != 0) { - const char* err = arangodb_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - arangodb_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -larangodb -L./zig-out/lib -``` - -### From Idris2 - -```idris -import ARANGODB.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "arangodb")] -extern "C" { - fn arangodb_init() -> *mut std::ffi::c_void; - fn arangodb_free(handle: *mut std::ffi::c_void); - fn arangodb_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = arangodb_init(); - assert!(!handle.is_null()); - - let result = arangodb_process(handle, 42); - assert_eq!(result, 0); - - arangodb_free(handle); - } -} -``` - -### From Julia - -```julia -const libarangodb = "libarangodb" - -function init() - handle = ccall((:arangodb_init, libarangodb), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:arangodb_process, libarangodb), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:arangodb_free, libarangodb), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/arangodb.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/arangodb/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/arangodb/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/arangodb/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/arangodb/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/arangodb/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/arangodb/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/arangodb/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/arangodb/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/arangodb/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/arangodb/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/arangodb/CONTRIBUTING.md b/asdf-plugin-collection/plugins/arangodb/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/arangodb/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/arangodb/README.adoc b/asdf-plugin-collection/plugins/arangodb/README.adoc index d08e1dd2..43a7cc7a 100644 --- a/asdf-plugin-collection/plugins/arangodb/README.adoc +++ b/asdf-plugin-collection/plugins/arangodb/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-arangodb -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-arangodb-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-arangodb-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-arangodb-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-arangodb-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://www.arangodb.com[ArangoDB]. -**All repos with foreign function interfaces MUST follow this standard:** +Multi-model NoSQL database. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add arangodb https://github.com/hyperpolymath/asdf-arangodb-plugin.git +---- -=== Web Projects +arangodb: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all arangodb -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install arangodb latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global arangodb latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now arangodb commands are available +arangodb --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list arangodb -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local arangodb -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall arangodb ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/arangodb/README.md b/asdf-plugin-collection/plugins/arangodb/README.md deleted file mode 100644 index 93bd52b9..00000000 --- a/asdf-plugin-collection/plugins/arangodb/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-arangodb - -[![Build](https://github.com/hyperpolymath/asdf-arangodb-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-arangodb-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-arangodb-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-arangodb-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [ArangoDB](https://www.arangodb.com). - -Multi-model NoSQL database. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add arangodb https://github.com/hyperpolymath/asdf-arangodb-plugin.git -``` - -arangodb: - -```bash -# Show all installable versions -asdf list-all arangodb - -# Install specific version -asdf install arangodb latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global arangodb latest - -# Now arangodb commands are available -arangodb --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list arangodb - -# Set local version for current directory -asdf local arangodb - -# Uninstall a version -asdf uninstall arangodb -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/arangodb/SECURITY.adoc b/asdf-plugin-collection/plugins/arangodb/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/arangodb/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/arangodb/SECURITY.md b/asdf-plugin-collection/plugins/arangodb/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/arangodb/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/bebop/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/bebop/ABI-FFI-README.adoc new file mode 100644 index 00000000..357b2f75 --- /dev/null +++ b/asdf-plugin-collection/plugins/bebop/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== BEBOP ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/bebop.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libbebop.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +bebop/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── bebop.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── bebop.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/bebop.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "bebop.h" + +int main() { + void* handle = bebop_init(); + if (!handle) return 1; + + int result = bebop_process(handle, 42); + if (result != 0) { + const char* err = bebop_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + bebop_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lbebop -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import BEBOP.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "bebop")] +extern "C" { + fn bebop_init() -> *mut std::ffi::c_void; + fn bebop_free(handle: *mut std::ffi::c_void); + fn bebop_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = bebop_init(); + assert!(!handle.is_null()); + + let result = bebop_process(handle, 42); + assert_eq!(result, 0); + + bebop_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libbebop = "libbebop" + +function init() + handle = ccall((:bebop_init, libbebop), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:bebop_process, libbebop), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:bebop_free, libbebop), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/bebop.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/bebop/ABI-FFI-README.md b/asdf-plugin-collection/plugins/bebop/ABI-FFI-README.md deleted file mode 100644 index a1726fec..00000000 --- a/asdf-plugin-collection/plugins/bebop/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# BEBOP ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/bebop.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libbebop.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -bebop/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── bebop.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── bebop.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/bebop.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "bebop.h" - -int main() { - void* handle = bebop_init(); - if (!handle) return 1; - - int result = bebop_process(handle, 42); - if (result != 0) { - const char* err = bebop_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - bebop_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lbebop -L./zig-out/lib -``` - -### From Idris2 - -```idris -import BEBOP.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "bebop")] -extern "C" { - fn bebop_init() -> *mut std::ffi::c_void; - fn bebop_free(handle: *mut std::ffi::c_void); - fn bebop_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = bebop_init(); - assert!(!handle.is_null()); - - let result = bebop_process(handle, 42); - assert_eq!(result, 0); - - bebop_free(handle); - } -} -``` - -### From Julia - -```julia -const libbebop = "libbebop" - -function init() - handle = ccall((:bebop_init, libbebop), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:bebop_process, libbebop), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:bebop_free, libbebop), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/bebop.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/bebop/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/bebop/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/bebop/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/bebop/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/bebop/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/bebop/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/bebop/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/bebop/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/bebop/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/bebop/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/bebop/CONTRIBUTING.md b/asdf-plugin-collection/plugins/bebop/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/bebop/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/bebop/README.adoc b/asdf-plugin-collection/plugins/bebop/README.adoc index d08e1dd2..5665674a 100644 --- a/asdf-plugin-collection/plugins/bebop/README.adoc +++ b/asdf-plugin-collection/plugins/bebop/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-bebop -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-bebop-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-bebop-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-bebop-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-bebop-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://bebop.sh[Bebop]. -**All repos with foreign function interfaces MUST follow this standard:** +Fast typed binary serialization. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add bebop https://github.com/hyperpolymath/asdf-bebop-plugin.git +---- -=== Web Projects +bebop: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all bebop -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install bebop latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global bebop latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now bebop commands are available +bebop --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list bebop -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local bebop -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall bebop ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/bebop/README.md b/asdf-plugin-collection/plugins/bebop/README.md deleted file mode 100644 index 320faa25..00000000 --- a/asdf-plugin-collection/plugins/bebop/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-bebop - -[![Build](https://github.com/hyperpolymath/asdf-bebop-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-bebop-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-bebop-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-bebop-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Bebop](https://bebop.sh). - -Fast typed binary serialization. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add bebop https://github.com/hyperpolymath/asdf-bebop-plugin.git -``` - -bebop: - -```bash -# Show all installable versions -asdf list-all bebop - -# Install specific version -asdf install bebop latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global bebop latest - -# Now bebop commands are available -bebop --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list bebop - -# Set local version for current directory -asdf local bebop - -# Uninstall a version -asdf uninstall bebop -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/bebop/SECURITY.adoc b/asdf-plugin-collection/plugins/bebop/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/bebop/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/bebop/SECURITY.md b/asdf-plugin-collection/plugins/bebop/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/bebop/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/borg/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/borg/ABI-FFI-README.adoc new file mode 100644 index 00000000..66d4578e --- /dev/null +++ b/asdf-plugin-collection/plugins/borg/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== BORG ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/borg.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libborg.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +borg/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── borg.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── borg.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/borg.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "borg.h" + +int main() { + void* handle = borg_init(); + if (!handle) return 1; + + int result = borg_process(handle, 42); + if (result != 0) { + const char* err = borg_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + borg_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lborg -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import BORG.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "borg")] +extern "C" { + fn borg_init() -> *mut std::ffi::c_void; + fn borg_free(handle: *mut std::ffi::c_void); + fn borg_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = borg_init(); + assert!(!handle.is_null()); + + let result = borg_process(handle, 42); + assert_eq!(result, 0); + + borg_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libborg = "libborg" + +function init() + handle = ccall((:borg_init, libborg), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:borg_process, libborg), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:borg_free, libborg), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/borg.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/borg/ABI-FFI-README.md b/asdf-plugin-collection/plugins/borg/ABI-FFI-README.md deleted file mode 100644 index f2b06791..00000000 --- a/asdf-plugin-collection/plugins/borg/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# BORG ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/borg.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libborg.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -borg/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── borg.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── borg.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/borg.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "borg.h" - -int main() { - void* handle = borg_init(); - if (!handle) return 1; - - int result = borg_process(handle, 42); - if (result != 0) { - const char* err = borg_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - borg_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lborg -L./zig-out/lib -``` - -### From Idris2 - -```idris -import BORG.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "borg")] -extern "C" { - fn borg_init() -> *mut std::ffi::c_void; - fn borg_free(handle: *mut std::ffi::c_void); - fn borg_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = borg_init(); - assert!(!handle.is_null()); - - let result = borg_process(handle, 42); - assert_eq!(result, 0); - - borg_free(handle); - } -} -``` - -### From Julia - -```julia -const libborg = "libborg" - -function init() - handle = ccall((:borg_init, libborg), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:borg_process, libborg), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:borg_free, libborg), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/borg.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/borg/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/borg/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/borg/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/borg/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/borg/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/borg/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/borg/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/borg/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/borg/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/borg/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/borg/CONTRIBUTING.md b/asdf-plugin-collection/plugins/borg/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/borg/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/borg/README.adoc b/asdf-plugin-collection/plugins/borg/README.adoc index d08e1dd2..a2d2855a 100644 --- a/asdf-plugin-collection/plugins/borg/README.adoc +++ b/asdf-plugin-collection/plugins/borg/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-borg -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-borg-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-borg-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-borg-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-borg-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://www.borgbackup.org[BorgBackup]. -**All repos with foreign function interfaces MUST follow this standard:** +Deduplicating backup. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add borg https://github.com/hyperpolymath/asdf-borg-plugin.git +---- -=== Web Projects +borg: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all borg -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install borg latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global borg latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now borg commands are available +borg --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list borg -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local borg -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall borg ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/borg/README.md b/asdf-plugin-collection/plugins/borg/README.md deleted file mode 100644 index e66f490b..00000000 --- a/asdf-plugin-collection/plugins/borg/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-borg - -[![Build](https://github.com/hyperpolymath/asdf-borg-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-borg-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-borg-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-borg-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [BorgBackup](https://www.borgbackup.org). - -Deduplicating backup. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add borg https://github.com/hyperpolymath/asdf-borg-plugin.git -``` - -borg: - -```bash -# Show all installable versions -asdf list-all borg - -# Install specific version -asdf install borg latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global borg latest - -# Now borg commands are available -borg --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list borg - -# Set local version for current directory -asdf local borg - -# Uninstall a version -asdf uninstall borg -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/borg/SECURITY.adoc b/asdf-plugin-collection/plugins/borg/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/borg/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/borg/SECURITY.md b/asdf-plugin-collection/plugins/borg/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/borg/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/casket-ssg/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/casket-ssg/ABI-FFI-README.adoc new file mode 100644 index 00000000..97b3d3b7 --- /dev/null +++ b/asdf-plugin-collection/plugins/casket-ssg/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== CASKET_SSG ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/casket-ssg.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libcasket-ssg.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +casket-ssg/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── casket-ssg.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── casket-ssg.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/casket-ssg.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "casket-ssg.h" + +int main() { + void* handle = casket-ssg_init(); + if (!handle) return 1; + + int result = casket-ssg_process(handle, 42); + if (result != 0) { + const char* err = casket-ssg_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + casket-ssg_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lcasket-ssg -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import CASKET_SSG.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "casket-ssg")] +extern "C" { + fn casket-ssg_init() -> *mut std::ffi::c_void; + fn casket-ssg_free(handle: *mut std::ffi::c_void); + fn casket-ssg_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = casket-ssg_init(); + assert!(!handle.is_null()); + + let result = casket-ssg_process(handle, 42); + assert_eq!(result, 0); + + casket-ssg_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libcasket-ssg = "libcasket-ssg" + +function init() + handle = ccall((:casket-ssg_init, libcasket-ssg), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:casket-ssg_process, libcasket-ssg), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:casket-ssg_free, libcasket-ssg), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/casket-ssg.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/casket-ssg/ABI-FFI-README.md b/asdf-plugin-collection/plugins/casket-ssg/ABI-FFI-README.md deleted file mode 100644 index e1ee045a..00000000 --- a/asdf-plugin-collection/plugins/casket-ssg/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# CASKET_SSG ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/casket-ssg.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libcasket-ssg.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -casket-ssg/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── casket-ssg.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── casket-ssg.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/casket-ssg.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "casket-ssg.h" - -int main() { - void* handle = casket-ssg_init(); - if (!handle) return 1; - - int result = casket-ssg_process(handle, 42); - if (result != 0) { - const char* err = casket-ssg_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - casket-ssg_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lcasket-ssg -L./zig-out/lib -``` - -### From Idris2 - -```idris -import CASKET_SSG.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "casket-ssg")] -extern "C" { - fn casket-ssg_init() -> *mut std::ffi::c_void; - fn casket-ssg_free(handle: *mut std::ffi::c_void); - fn casket-ssg_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = casket-ssg_init(); - assert!(!handle.is_null()); - - let result = casket-ssg_process(handle, 42); - assert_eq!(result, 0); - - casket-ssg_free(handle); - } -} -``` - -### From Julia - -```julia -const libcasket-ssg = "libcasket-ssg" - -function init() - handle = ccall((:casket-ssg_init, libcasket-ssg), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:casket-ssg_process, libcasket-ssg), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:casket-ssg_free, libcasket-ssg), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/casket-ssg.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/casket-ssg/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/casket-ssg/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/casket-ssg/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/casket-ssg/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/casket-ssg/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/casket-ssg/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/casket-ssg/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/casket-ssg/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/casket-ssg/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/casket-ssg/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/casket-ssg/CONTRIBUTING.md b/asdf-plugin-collection/plugins/casket-ssg/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/casket-ssg/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/casket-ssg/README.adoc b/asdf-plugin-collection/plugins/casket-ssg/README.adoc index 0caffcaf..fe3ba07d 100644 --- a/asdf-plugin-collection/plugins/casket-ssg/README.adoc +++ b/asdf-plugin-collection/plugins/casket-ssg/README.adoc @@ -1,40 +1,83 @@ -= asdf-casket-ssg +== asdf-casket-ssg -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] -:author: hyperpolymath -:url-asdf: https://asdf-vm.com -:url-repo: https://github.com/hyperpolymath/asdf-casket-ssg-plugin +https://github.com/hyperpolymath/asdf-casket-ssg-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-casket-ssg-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-casket-ssg-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-casket-ssg-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -image:https://img.shields.io/github/license/hyperpolymath/asdf-casket-ssg-plugin?style=flat-square[License,link=LICENSE] -image:https://img.shields.io/github/actions/workflow/status/hyperpolymath/asdf-casket-ssg-plugin/ci.yml?branch=main&style=flat-square[Build Status,link={url-repo}/actions] -image:https://img.shields.io/badge/asdf-plugin-blue?style=flat-square[asdf Plugin,link={url-asdf}] +https://asdf-vm.com[asdf] plugin for +https://github.com/caskethosting/casket[Casket]. -An {url-asdf}[asdf] plugin to manage https://github.com/hyperpolymath/casket-ssg[casket-ssg] versions. +Static site generator. -== Installation +=== Contents + +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] + +=== Dependencies + +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] + +=== Install + +Plugin: [source,bash] ---- asdf plugin add casket-ssg https://github.com/hyperpolymath/asdf-casket-ssg-plugin.git ---- -== Usage +casket-ssg: [source,bash] ---- -# List all available versions -asdf list all casket-ssg +# Show all installable versions +asdf list-all casket-ssg -# Install a specific version -asdf install casket-ssg 1.1.0 +# Install specific version +asdf install casket-ssg latest -# Set global default -asdf global casket-ssg 1.1.0 +# Set a version globally (in your ~/.tool-versions file) +asdf global casket-ssg latest -# Set local version for current project -asdf local casket-ssg 1.1.0 +# Now casket-ssg commands are available +casket-ssg --version ---- -== License +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. + +=== Usage + +[source,bash] +---- +# List installed versions +asdf list casket-ssg + +# Set local version for current directory +asdf local casket-ssg + +# Uninstall a version +asdf uninstall casket-ssg +---- + +=== Contributing + +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License + +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. + +''''' -SPDX-License-Identifier: CC-BY-SA-4.0 +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/casket-ssg/README.md b/asdf-plugin-collection/plugins/casket-ssg/README.md deleted file mode 100644 index 1db4962f..00000000 --- a/asdf-plugin-collection/plugins/casket-ssg/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-casket-ssg - -[![Build](https://github.com/hyperpolymath/asdf-casket-ssg-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-casket-ssg-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-casket-ssg-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-casket-ssg-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Casket](https://github.com/caskethosting/casket). - -Static site generator. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add casket-ssg https://github.com/hyperpolymath/asdf-casket-ssg-plugin.git -``` - -casket-ssg: - -```bash -# Show all installable versions -asdf list-all casket-ssg - -# Install specific version -asdf install casket-ssg latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global casket-ssg latest - -# Now casket-ssg commands are available -casket-ssg --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list casket-ssg - -# Set local version for current directory -asdf local casket-ssg - -# Uninstall a version -asdf uninstall casket-ssg -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/casket-ssg/SECURITY.adoc b/asdf-plugin-collection/plugins/casket-ssg/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/casket-ssg/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/casket-ssg/SECURITY.md b/asdf-plugin-collection/plugins/casket-ssg/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/casket-ssg/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/cassandra/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/cassandra/ABI-FFI-README.adoc new file mode 100644 index 00000000..3c630b9f --- /dev/null +++ b/asdf-plugin-collection/plugins/cassandra/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== CASSANDRA ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/cassandra.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libcassandra.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +cassandra/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── cassandra.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── cassandra.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/cassandra.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "cassandra.h" + +int main() { + void* handle = cassandra_init(); + if (!handle) return 1; + + int result = cassandra_process(handle, 42); + if (result != 0) { + const char* err = cassandra_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + cassandra_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lcassandra -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import CASSANDRA.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "cassandra")] +extern "C" { + fn cassandra_init() -> *mut std::ffi::c_void; + fn cassandra_free(handle: *mut std::ffi::c_void); + fn cassandra_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = cassandra_init(); + assert!(!handle.is_null()); + + let result = cassandra_process(handle, 42); + assert_eq!(result, 0); + + cassandra_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libcassandra = "libcassandra" + +function init() + handle = ccall((:cassandra_init, libcassandra), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:cassandra_process, libcassandra), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:cassandra_free, libcassandra), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/cassandra.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/cassandra/ABI-FFI-README.md b/asdf-plugin-collection/plugins/cassandra/ABI-FFI-README.md deleted file mode 100644 index d9fa65f6..00000000 --- a/asdf-plugin-collection/plugins/cassandra/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# CASSANDRA ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/cassandra.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libcassandra.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -cassandra/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── cassandra.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── cassandra.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/cassandra.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "cassandra.h" - -int main() { - void* handle = cassandra_init(); - if (!handle) return 1; - - int result = cassandra_process(handle, 42); - if (result != 0) { - const char* err = cassandra_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - cassandra_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lcassandra -L./zig-out/lib -``` - -### From Idris2 - -```idris -import CASSANDRA.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "cassandra")] -extern "C" { - fn cassandra_init() -> *mut std::ffi::c_void; - fn cassandra_free(handle: *mut std::ffi::c_void); - fn cassandra_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = cassandra_init(); - assert!(!handle.is_null()); - - let result = cassandra_process(handle, 42); - assert_eq!(result, 0); - - cassandra_free(handle); - } -} -``` - -### From Julia - -```julia -const libcassandra = "libcassandra" - -function init() - handle = ccall((:cassandra_init, libcassandra), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:cassandra_process, libcassandra), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:cassandra_free, libcassandra), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/cassandra.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/cassandra/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/cassandra/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/cassandra/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/cassandra/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/cassandra/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/cassandra/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/cassandra/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/cassandra/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/cassandra/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/cassandra/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/cassandra/CONTRIBUTING.md b/asdf-plugin-collection/plugins/cassandra/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/cassandra/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/cassandra/README.adoc b/asdf-plugin-collection/plugins/cassandra/README.adoc index d08e1dd2..2d88e26c 100644 --- a/asdf-plugin-collection/plugins/cassandra/README.adoc +++ b/asdf-plugin-collection/plugins/cassandra/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-cassandra -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-cassandra-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-cassandra-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-cassandra-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-cassandra-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://cassandra.apache.org[Apache +Cassandra]. -**All repos with foreign function interfaces MUST follow this standard:** +Distributed NoSQL database. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add cassandra https://github.com/hyperpolymath/asdf-cassandra-plugin.git +---- -=== Web Projects +cassandra: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all cassandra -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install cassandra latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global cassandra latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now cassandra commands are available +cassandra --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list cassandra -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local cassandra -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall cassandra ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/cassandra/README.md b/asdf-plugin-collection/plugins/cassandra/README.md deleted file mode 100644 index fbf491de..00000000 --- a/asdf-plugin-collection/plugins/cassandra/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-cassandra - -[![Build](https://github.com/hyperpolymath/asdf-cassandra-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-cassandra-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-cassandra-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-cassandra-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Apache Cassandra](https://cassandra.apache.org). - -Distributed NoSQL database. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add cassandra https://github.com/hyperpolymath/asdf-cassandra-plugin.git -``` - -cassandra: - -```bash -# Show all installable versions -asdf list-all cassandra - -# Install specific version -asdf install cassandra latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global cassandra latest - -# Now cassandra commands are available -cassandra --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list cassandra - -# Set local version for current directory -asdf local cassandra - -# Uninstall a version -asdf uninstall cassandra -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/cassandra/SECURITY.adoc b/asdf-plugin-collection/plugins/cassandra/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/cassandra/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/cassandra/SECURITY.md b/asdf-plugin-collection/plugins/cassandra/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/cassandra/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/cfssl/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/cfssl/ABI-FFI-README.adoc new file mode 100644 index 00000000..03f95040 --- /dev/null +++ b/asdf-plugin-collection/plugins/cfssl/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== CFSSL ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/cfssl.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libcfssl.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +cfssl/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── cfssl.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── cfssl.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/cfssl.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "cfssl.h" + +int main() { + void* handle = cfssl_init(); + if (!handle) return 1; + + int result = cfssl_process(handle, 42); + if (result != 0) { + const char* err = cfssl_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + cfssl_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lcfssl -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import CFSSL.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "cfssl")] +extern "C" { + fn cfssl_init() -> *mut std::ffi::c_void; + fn cfssl_free(handle: *mut std::ffi::c_void); + fn cfssl_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = cfssl_init(); + assert!(!handle.is_null()); + + let result = cfssl_process(handle, 42); + assert_eq!(result, 0); + + cfssl_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libcfssl = "libcfssl" + +function init() + handle = ccall((:cfssl_init, libcfssl), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:cfssl_process, libcfssl), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:cfssl_free, libcfssl), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/cfssl.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/cfssl/ABI-FFI-README.md b/asdf-plugin-collection/plugins/cfssl/ABI-FFI-README.md deleted file mode 100644 index 0c2780b9..00000000 --- a/asdf-plugin-collection/plugins/cfssl/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# CFSSL ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/cfssl.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libcfssl.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -cfssl/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── cfssl.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── cfssl.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/cfssl.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "cfssl.h" - -int main() { - void* handle = cfssl_init(); - if (!handle) return 1; - - int result = cfssl_process(handle, 42); - if (result != 0) { - const char* err = cfssl_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - cfssl_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lcfssl -L./zig-out/lib -``` - -### From Idris2 - -```idris -import CFSSL.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "cfssl")] -extern "C" { - fn cfssl_init() -> *mut std::ffi::c_void; - fn cfssl_free(handle: *mut std::ffi::c_void); - fn cfssl_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = cfssl_init(); - assert!(!handle.is_null()); - - let result = cfssl_process(handle, 42); - assert_eq!(result, 0); - - cfssl_free(handle); - } -} -``` - -### From Julia - -```julia -const libcfssl = "libcfssl" - -function init() - handle = ccall((:cfssl_init, libcfssl), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:cfssl_process, libcfssl), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:cfssl_free, libcfssl), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/cfssl.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/cfssl/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/cfssl/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/cfssl/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/cfssl/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/cfssl/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/cfssl/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/cfssl/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/cfssl/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/cfssl/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/cfssl/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/cfssl/CONTRIBUTING.md b/asdf-plugin-collection/plugins/cfssl/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/cfssl/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/cfssl/README.adoc b/asdf-plugin-collection/plugins/cfssl/README.adoc index d08e1dd2..29ea3ce9 100644 --- a/asdf-plugin-collection/plugins/cfssl/README.adoc +++ b/asdf-plugin-collection/plugins/cfssl/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-cfssl -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-cfssl-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-cfssl-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-cfssl-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-cfssl-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://cfssl.org[CFSSL]. -**All repos with foreign function interfaces MUST follow this standard:** +CloudFlare PKI toolkit. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add cfssl https://github.com/hyperpolymath/asdf-cfssl-plugin.git +---- -=== Web Projects +cfssl: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all cfssl -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install cfssl latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global cfssl latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now cfssl commands are available +cfssl --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list cfssl -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local cfssl -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall cfssl ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/cfssl/README.md b/asdf-plugin-collection/plugins/cfssl/README.md deleted file mode 100644 index deb102ac..00000000 --- a/asdf-plugin-collection/plugins/cfssl/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-cfssl - -[![Build](https://github.com/hyperpolymath/asdf-cfssl-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-cfssl-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-cfssl-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-cfssl-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [CFSSL](https://cfssl.org). - -CloudFlare PKI toolkit. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add cfssl https://github.com/hyperpolymath/asdf-cfssl-plugin.git -``` - -cfssl: - -```bash -# Show all installable versions -asdf list-all cfssl - -# Install specific version -asdf install cfssl latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global cfssl latest - -# Now cfssl commands are available -cfssl --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list cfssl - -# Set local version for current directory -asdf local cfssl - -# Uninstall a version -asdf uninstall cfssl -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/cfssl/SECURITY.adoc b/asdf-plugin-collection/plugins/cfssl/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/cfssl/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/cfssl/SECURITY.md b/asdf-plugin-collection/plugins/cfssl/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/cfssl/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/cobalt/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/cobalt/ABI-FFI-README.adoc new file mode 100644 index 00000000..2f47a922 --- /dev/null +++ b/asdf-plugin-collection/plugins/cobalt/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== COBALT ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/cobalt.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libcobalt.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +cobalt/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── cobalt.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── cobalt.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/cobalt.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "cobalt.h" + +int main() { + void* handle = cobalt_init(); + if (!handle) return 1; + + int result = cobalt_process(handle, 42); + if (result != 0) { + const char* err = cobalt_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + cobalt_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lcobalt -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import COBALT.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "cobalt")] +extern "C" { + fn cobalt_init() -> *mut std::ffi::c_void; + fn cobalt_free(handle: *mut std::ffi::c_void); + fn cobalt_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = cobalt_init(); + assert!(!handle.is_null()); + + let result = cobalt_process(handle, 42); + assert_eq!(result, 0); + + cobalt_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libcobalt = "libcobalt" + +function init() + handle = ccall((:cobalt_init, libcobalt), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:cobalt_process, libcobalt), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:cobalt_free, libcobalt), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/cobalt.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/cobalt/ABI-FFI-README.md b/asdf-plugin-collection/plugins/cobalt/ABI-FFI-README.md deleted file mode 100644 index b38a3a27..00000000 --- a/asdf-plugin-collection/plugins/cobalt/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# COBALT ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/cobalt.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libcobalt.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -cobalt/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── cobalt.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── cobalt.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/cobalt.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "cobalt.h" - -int main() { - void* handle = cobalt_init(); - if (!handle) return 1; - - int result = cobalt_process(handle, 42); - if (result != 0) { - const char* err = cobalt_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - cobalt_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lcobalt -L./zig-out/lib -``` - -### From Idris2 - -```idris -import COBALT.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "cobalt")] -extern "C" { - fn cobalt_init() -> *mut std::ffi::c_void; - fn cobalt_free(handle: *mut std::ffi::c_void); - fn cobalt_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = cobalt_init(); - assert!(!handle.is_null()); - - let result = cobalt_process(handle, 42); - assert_eq!(result, 0); - - cobalt_free(handle); - } -} -``` - -### From Julia - -```julia -const libcobalt = "libcobalt" - -function init() - handle = ccall((:cobalt_init, libcobalt), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:cobalt_process, libcobalt), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:cobalt_free, libcobalt), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/cobalt.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/cobalt/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/cobalt/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/cobalt/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/cobalt/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/cobalt/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/cobalt/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/cobalt/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/cobalt/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/cobalt/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/cobalt/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/cobalt/CONTRIBUTING.md b/asdf-plugin-collection/plugins/cobalt/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/cobalt/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/cobalt/README.adoc b/asdf-plugin-collection/plugins/cobalt/README.adoc index d08e1dd2..75e44c27 100644 --- a/asdf-plugin-collection/plugins/cobalt/README.adoc +++ b/asdf-plugin-collection/plugins/cobalt/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-cobalt -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-cobalt-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-cobalt-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-cobalt-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-cobalt-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://cobalt-org.github.io[Cobalt]. -**All repos with foreign function interfaces MUST follow this standard:** +Static site generator in Rust. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add cobalt https://github.com/hyperpolymath/asdf-cobalt-plugin.git +---- -=== Web Projects +cobalt: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all cobalt -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install cobalt latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global cobalt latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now cobalt commands are available +cobalt --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list cobalt -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local cobalt -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall cobalt ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/cobalt/README.md b/asdf-plugin-collection/plugins/cobalt/README.md deleted file mode 100644 index d38c0c31..00000000 --- a/asdf-plugin-collection/plugins/cobalt/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-cobalt - -[![Build](https://github.com/hyperpolymath/asdf-cobalt-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-cobalt-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-cobalt-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-cobalt-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Cobalt](https://cobalt-org.github.io). - -Static site generator in Rust. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add cobalt https://github.com/hyperpolymath/asdf-cobalt-plugin.git -``` - -cobalt: - -```bash -# Show all installable versions -asdf list-all cobalt - -# Install specific version -asdf install cobalt latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global cobalt latest - -# Now cobalt commands are available -cobalt --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list cobalt - -# Set local version for current directory -asdf local cobalt - -# Uninstall a version -asdf uninstall cobalt -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/cobalt/SECURITY.adoc b/asdf-plugin-collection/plugins/cobalt/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/cobalt/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/cobalt/SECURITY.md b/asdf-plugin-collection/plugins/cobalt/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/cobalt/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/cobol/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/cobol/ABI-FFI-README.adoc new file mode 100644 index 00000000..668697fe --- /dev/null +++ b/asdf-plugin-collection/plugins/cobol/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== COBOL ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/cobol.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libcobol.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +cobol/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── cobol.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── cobol.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/cobol.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "cobol.h" + +int main() { + void* handle = cobol_init(); + if (!handle) return 1; + + int result = cobol_process(handle, 42); + if (result != 0) { + const char* err = cobol_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + cobol_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lcobol -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import COBOL.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "cobol")] +extern "C" { + fn cobol_init() -> *mut std::ffi::c_void; + fn cobol_free(handle: *mut std::ffi::c_void); + fn cobol_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = cobol_init(); + assert!(!handle.is_null()); + + let result = cobol_process(handle, 42); + assert_eq!(result, 0); + + cobol_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libcobol = "libcobol" + +function init() + handle = ccall((:cobol_init, libcobol), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:cobol_process, libcobol), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:cobol_free, libcobol), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/cobol.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/cobol/ABI-FFI-README.md b/asdf-plugin-collection/plugins/cobol/ABI-FFI-README.md deleted file mode 100644 index b5600f7c..00000000 --- a/asdf-plugin-collection/plugins/cobol/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# COBOL ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/cobol.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libcobol.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -cobol/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── cobol.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── cobol.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/cobol.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "cobol.h" - -int main() { - void* handle = cobol_init(); - if (!handle) return 1; - - int result = cobol_process(handle, 42); - if (result != 0) { - const char* err = cobol_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - cobol_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lcobol -L./zig-out/lib -``` - -### From Idris2 - -```idris -import COBOL.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "cobol")] -extern "C" { - fn cobol_init() -> *mut std::ffi::c_void; - fn cobol_free(handle: *mut std::ffi::c_void); - fn cobol_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = cobol_init(); - assert!(!handle.is_null()); - - let result = cobol_process(handle, 42); - assert_eq!(result, 0); - - cobol_free(handle); - } -} -``` - -### From Julia - -```julia -const libcobol = "libcobol" - -function init() - handle = ccall((:cobol_init, libcobol), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:cobol_process, libcobol), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:cobol_free, libcobol), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/cobol.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/cobol/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/cobol/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/cobol/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/cobol/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/cobol/CODE_OF_CONDUCT.md deleted file mode 100644 index caeda1c6..00000000 --- a/asdf-plugin-collection/plugins/cobol/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,27 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. - diff --git a/asdf-plugin-collection/plugins/cobol/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/cobol/CONTRIBUTING.adoc index eb045d61..084ee525 100644 --- a/asdf-plugin-collection/plugins/cobol/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/cobol/CONTRIBUTING.adoc @@ -1,20 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/cobol/CONTRIBUTING.md b/asdf-plugin-collection/plugins/cobol/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/cobol/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/cobol/README.adoc b/asdf-plugin-collection/plugins/cobol/README.adoc index d220c553..57a4d994 100644 --- a/asdf-plugin-collection/plugins/cobol/README.adoc +++ b/asdf-plugin-collection/plugins/cobol/README.adoc @@ -1,107 +1,83 @@ -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] -image:https://img.shields.io/badge/Philosophy-Palimpsest-indigo.svg[Palimpsest,link="https://github.com/hyperpolymath/palimpsest-license"] +== asdf-cobol +https://github.com/hyperpolymath/asdf-cobol-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-cobol-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-cobol-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-cobol-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -// SPDX-License-Identifier: CC-BY-SA-4.0 -= asdf-cobol +https://asdf-vm.com[asdf] plugin for +https://www.gnu.org/software/gnucobol[GnuCOBOL]. -:toc: macro -:toclevels: 2 -:icons: font -:source-highlighter: rouge +Free COBOL compiler. -https://asdf-vm.com[asdf] plugin for https://www.gnu.org/software/gnucobol/[GnuCOBOL]. +=== Contents -[IMPORTANT] -==== -*Project Status: Specification Pending* +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -This repository is a placeholder. The plugin implementation will be uploaded shortly. -==== +=== Dependencies -toc::[] +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== Overview +=== Install -This plugin will enable version management of GnuCOBOL via the asdf version manager, allowing developers to: - -* Install multiple GnuCOBOL versions side-by-side -* Switch between versions per-project or globally -* Ensure reproducible COBOL development environments - -== Planned Installation - -Once implemented: +Plugin: [source,bash] ---- -asdf plugin add cobol https://gitlab.com/hyperpolymath/asdf-cobol.git -asdf list-all cobol -asdf install cobol 3.2.0 -asdf global cobol 3.2.0 +asdf plugin add cobol https://github.com/hyperpolymath/asdf-cobol-plugin.git ---- -== Current Repository Contents - -[cols="1,3"] -|=== -| Path | Description +cobol: -| `.github/workflows/mirror.yml` -| Hub-and-spoke mirror workflow (GitLab, Codeberg, Bitbucket) - -| `.github/workflows/instant-sync.yml` -| Automatic forge propagation on push/release - -| `README.md` -| Placeholder documentation - -| `README.adoc` -| This file -|=== +[source,bash] +---- +# Show all installable versions +asdf list-all cobol -== What Is Missing (Pending Implementation) +# Install specific version +asdf install cobol latest -Standard asdf plugin structure requires: +# Set a version globally (in your ~/.tool-versions file) +asdf global cobol latest -[source] +# Now cobol commands are available +cobol --version ---- -bin/ -├── download # Fetch GnuCOBOL source tarball -├── install # Compile and install GnuCOBOL -├── list-all # List available versions -├── list-bin-paths # (optional) Expose binaries -└── exec-env # (optional) Set runtime environment ----- - -== About GnuCOBOL -GnuCOBOL (formerly OpenCOBOL) is a free COBOL compiler that translates COBOL source to C, then compiles with a native C compiler. It implements substantial portions of the COBOL 85, COBOL 2002, and COBOL 2014 standards. +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -Key features: +=== Usage -* COBOL 85/2002/2014 support -* Compiles to native code via C -* Interoperability with C libraries -* Active development and community - -== Multi-Forge Distribution +[source,bash] +---- +# List installed versions +asdf list cobol -This repository is distributed across multiple forges: +# Set local version for current directory +asdf local cobol -* *Primary*: https://gitlab.com/hyperpolymath/asdf-cobol[GitLab] -* *Mirror*: GitHub (hyperpolymath/asdf-cobol-plugin) -* *Mirror*: Codeberg -* *Mirror*: Bitbucket +# Uninstall a version +asdf uninstall cobol +---- -== Contributing +=== Contributing -See `CONTRIBUTING.md` (pending). +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. -== License +=== License -MPL-2.0 +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -== Funding +''''' -If you find this useful, consider supporting via https://buymeacoffee.com[Buy Me a Coffee]. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/cobol/README.md b/asdf-plugin-collection/plugins/cobol/README.md deleted file mode 100644 index bb7e814a..00000000 --- a/asdf-plugin-collection/plugins/cobol/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-cobol - -[![Build](https://github.com/hyperpolymath/asdf-cobol-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-cobol-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-cobol-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-cobol-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [GnuCOBOL](https://www.gnu.org/software/gnucobol). - -Free COBOL compiler. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add cobol https://github.com/hyperpolymath/asdf-cobol-plugin.git -``` - -cobol: - -```bash -# Show all installable versions -asdf list-all cobol - -# Install specific version -asdf install cobol latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global cobol latest - -# Now cobol commands are available -cobol --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list cobol - -# Set local version for current directory -asdf local cobol - -# Uninstall a version -asdf uninstall cobol -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/cobol/SECURITY.adoc b/asdf-plugin-collection/plugins/cobol/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/cobol/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/cobol/SECURITY.md b/asdf-plugin-collection/plugins/cobol/SECURITY.md deleted file mode 100644 index 159a0b7a..00000000 --- a/asdf-plugin-collection/plugins/cobol/SECURITY.md +++ /dev/null @@ -1,25 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection - diff --git a/asdf-plugin-collection/plugins/coredns/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/coredns/ABI-FFI-README.adoc new file mode 100644 index 00000000..9a134242 --- /dev/null +++ b/asdf-plugin-collection/plugins/coredns/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== COREDNS ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/coredns.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libcoredns.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +coredns/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── coredns.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── coredns.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/coredns.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "coredns.h" + +int main() { + void* handle = coredns_init(); + if (!handle) return 1; + + int result = coredns_process(handle, 42); + if (result != 0) { + const char* err = coredns_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + coredns_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lcoredns -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import COREDNS.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "coredns")] +extern "C" { + fn coredns_init() -> *mut std::ffi::c_void; + fn coredns_free(handle: *mut std::ffi::c_void); + fn coredns_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = coredns_init(); + assert!(!handle.is_null()); + + let result = coredns_process(handle, 42); + assert_eq!(result, 0); + + coredns_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libcoredns = "libcoredns" + +function init() + handle = ccall((:coredns_init, libcoredns), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:coredns_process, libcoredns), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:coredns_free, libcoredns), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/coredns.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/coredns/ABI-FFI-README.md b/asdf-plugin-collection/plugins/coredns/ABI-FFI-README.md deleted file mode 100644 index be38cbfc..00000000 --- a/asdf-plugin-collection/plugins/coredns/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# COREDNS ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/coredns.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libcoredns.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -coredns/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── coredns.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── coredns.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/coredns.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "coredns.h" - -int main() { - void* handle = coredns_init(); - if (!handle) return 1; - - int result = coredns_process(handle, 42); - if (result != 0) { - const char* err = coredns_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - coredns_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lcoredns -L./zig-out/lib -``` - -### From Idris2 - -```idris -import COREDNS.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "coredns")] -extern "C" { - fn coredns_init() -> *mut std::ffi::c_void; - fn coredns_free(handle: *mut std::ffi::c_void); - fn coredns_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = coredns_init(); - assert!(!handle.is_null()); - - let result = coredns_process(handle, 42); - assert_eq!(result, 0); - - coredns_free(handle); - } -} -``` - -### From Julia - -```julia -const libcoredns = "libcoredns" - -function init() - handle = ccall((:coredns_init, libcoredns), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:coredns_process, libcoredns), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:coredns_free, libcoredns), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/coredns.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/coredns/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/coredns/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/coredns/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/coredns/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/coredns/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/coredns/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/coredns/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/coredns/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/coredns/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/coredns/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/coredns/CONTRIBUTING.md b/asdf-plugin-collection/plugins/coredns/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/coredns/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/coredns/README.adoc b/asdf-plugin-collection/plugins/coredns/README.adoc index d08e1dd2..c52bdaac 100644 --- a/asdf-plugin-collection/plugins/coredns/README.adoc +++ b/asdf-plugin-collection/plugins/coredns/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-coredns -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-coredns-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-coredns-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-coredns-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-coredns-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://coredns.io[CoreDNS]. -**All repos with foreign function interfaces MUST follow this standard:** +Flexible DNS server. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add coredns https://github.com/hyperpolymath/asdf-coredns-plugin.git +---- -=== Web Projects +coredns: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all coredns -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install coredns latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global coredns latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now coredns commands are available +coredns --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list coredns -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local coredns -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall coredns ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/coredns/README.md b/asdf-plugin-collection/plugins/coredns/README.md deleted file mode 100644 index a98918e5..00000000 --- a/asdf-plugin-collection/plugins/coredns/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-coredns - -[![Build](https://github.com/hyperpolymath/asdf-coredns-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-coredns-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-coredns-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-coredns-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [CoreDNS](https://coredns.io). - -Flexible DNS server. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add coredns https://github.com/hyperpolymath/asdf-coredns-plugin.git -``` - -coredns: - -```bash -# Show all installable versions -asdf list-all coredns - -# Install specific version -asdf install coredns latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global coredns latest - -# Now coredns commands are available -coredns --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list coredns - -# Set local version for current directory -asdf local coredns - -# Uninstall a version -asdf uninstall coredns -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/coredns/SECURITY.adoc b/asdf-plugin-collection/plugins/coredns/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/coredns/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/coredns/SECURITY.md b/asdf-plugin-collection/plugins/coredns/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/coredns/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/cosign/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/cosign/ABI-FFI-README.adoc new file mode 100644 index 00000000..2ba60102 --- /dev/null +++ b/asdf-plugin-collection/plugins/cosign/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== COSIGN ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/cosign.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libcosign.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +cosign/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── cosign.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── cosign.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/cosign.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "cosign.h" + +int main() { + void* handle = cosign_init(); + if (!handle) return 1; + + int result = cosign_process(handle, 42); + if (result != 0) { + const char* err = cosign_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + cosign_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lcosign -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import COSIGN.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "cosign")] +extern "C" { + fn cosign_init() -> *mut std::ffi::c_void; + fn cosign_free(handle: *mut std::ffi::c_void); + fn cosign_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = cosign_init(); + assert!(!handle.is_null()); + + let result = cosign_process(handle, 42); + assert_eq!(result, 0); + + cosign_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libcosign = "libcosign" + +function init() + handle = ccall((:cosign_init, libcosign), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:cosign_process, libcosign), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:cosign_free, libcosign), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/cosign.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/cosign/ABI-FFI-README.md b/asdf-plugin-collection/plugins/cosign/ABI-FFI-README.md deleted file mode 100644 index 98655399..00000000 --- a/asdf-plugin-collection/plugins/cosign/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# COSIGN ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/cosign.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libcosign.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -cosign/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── cosign.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── cosign.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/cosign.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "cosign.h" - -int main() { - void* handle = cosign_init(); - if (!handle) return 1; - - int result = cosign_process(handle, 42); - if (result != 0) { - const char* err = cosign_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - cosign_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lcosign -L./zig-out/lib -``` - -### From Idris2 - -```idris -import COSIGN.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "cosign")] -extern "C" { - fn cosign_init() -> *mut std::ffi::c_void; - fn cosign_free(handle: *mut std::ffi::c_void); - fn cosign_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = cosign_init(); - assert!(!handle.is_null()); - - let result = cosign_process(handle, 42); - assert_eq!(result, 0); - - cosign_free(handle); - } -} -``` - -### From Julia - -```julia -const libcosign = "libcosign" - -function init() - handle = ccall((:cosign_init, libcosign), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:cosign_process, libcosign), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:cosign_free, libcosign), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/cosign.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/cosign/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/cosign/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/cosign/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/cosign/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/cosign/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/cosign/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/cosign/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/cosign/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/cosign/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/cosign/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/cosign/CONTRIBUTING.md b/asdf-plugin-collection/plugins/cosign/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/cosign/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/cosign/README.adoc b/asdf-plugin-collection/plugins/cosign/README.adoc index d08e1dd2..c4df0e5e 100644 --- a/asdf-plugin-collection/plugins/cosign/README.adoc +++ b/asdf-plugin-collection/plugins/cosign/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-cosign -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-cosign-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-cosign-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-cosign-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-cosign-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://sigstore.dev[Cosign]. -**All repos with foreign function interfaces MUST follow this standard:** +Container signing from Sigstore. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add cosign https://github.com/hyperpolymath/asdf-cosign-plugin.git +---- -=== Web Projects +cosign: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all cosign -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install cosign latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global cosign latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now cosign commands are available +cosign --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list cosign -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local cosign -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall cosign ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/cosign/README.md b/asdf-plugin-collection/plugins/cosign/README.md deleted file mode 100644 index 9d8e33c6..00000000 --- a/asdf-plugin-collection/plugins/cosign/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-cosign - -[![Build](https://github.com/hyperpolymath/asdf-cosign-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-cosign-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-cosign-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-cosign-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Cosign](https://sigstore.dev). - -Container signing from Sigstore. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add cosign https://github.com/hyperpolymath/asdf-cosign-plugin.git -``` - -cosign: - -```bash -# Show all installable versions -asdf list-all cosign - -# Install specific version -asdf install cosign latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global cosign latest - -# Now cosign commands are available -cosign --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list cosign - -# Set local version for current directory -asdf local cosign - -# Uninstall a version -asdf uninstall cosign -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/cosign/SECURITY.adoc b/asdf-plugin-collection/plugins/cosign/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/cosign/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/cosign/SECURITY.md b/asdf-plugin-collection/plugins/cosign/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/cosign/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/couchdb/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/couchdb/ABI-FFI-README.adoc new file mode 100644 index 00000000..24c93349 --- /dev/null +++ b/asdf-plugin-collection/plugins/couchdb/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== COUCHDB ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/couchdb.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libcouchdb.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +couchdb/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── couchdb.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── couchdb.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/couchdb.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "couchdb.h" + +int main() { + void* handle = couchdb_init(); + if (!handle) return 1; + + int result = couchdb_process(handle, 42); + if (result != 0) { + const char* err = couchdb_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + couchdb_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lcouchdb -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import COUCHDB.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "couchdb")] +extern "C" { + fn couchdb_init() -> *mut std::ffi::c_void; + fn couchdb_free(handle: *mut std::ffi::c_void); + fn couchdb_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = couchdb_init(); + assert!(!handle.is_null()); + + let result = couchdb_process(handle, 42); + assert_eq!(result, 0); + + couchdb_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libcouchdb = "libcouchdb" + +function init() + handle = ccall((:couchdb_init, libcouchdb), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:couchdb_process, libcouchdb), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:couchdb_free, libcouchdb), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/couchdb.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/couchdb/ABI-FFI-README.md b/asdf-plugin-collection/plugins/couchdb/ABI-FFI-README.md deleted file mode 100644 index e724fafc..00000000 --- a/asdf-plugin-collection/plugins/couchdb/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# COUCHDB ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/couchdb.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libcouchdb.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -couchdb/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── couchdb.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── couchdb.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/couchdb.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "couchdb.h" - -int main() { - void* handle = couchdb_init(); - if (!handle) return 1; - - int result = couchdb_process(handle, 42); - if (result != 0) { - const char* err = couchdb_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - couchdb_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lcouchdb -L./zig-out/lib -``` - -### From Idris2 - -```idris -import COUCHDB.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "couchdb")] -extern "C" { - fn couchdb_init() -> *mut std::ffi::c_void; - fn couchdb_free(handle: *mut std::ffi::c_void); - fn couchdb_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = couchdb_init(); - assert!(!handle.is_null()); - - let result = couchdb_process(handle, 42); - assert_eq!(result, 0); - - couchdb_free(handle); - } -} -``` - -### From Julia - -```julia -const libcouchdb = "libcouchdb" - -function init() - handle = ccall((:couchdb_init, libcouchdb), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:couchdb_process, libcouchdb), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:couchdb_free, libcouchdb), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/couchdb.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/couchdb/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/couchdb/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/couchdb/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/couchdb/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/couchdb/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/couchdb/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/couchdb/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/couchdb/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/couchdb/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/couchdb/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/couchdb/CONTRIBUTING.md b/asdf-plugin-collection/plugins/couchdb/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/couchdb/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/couchdb/README.adoc b/asdf-plugin-collection/plugins/couchdb/README.adoc index d08e1dd2..cf4866d3 100644 --- a/asdf-plugin-collection/plugins/couchdb/README.adoc +++ b/asdf-plugin-collection/plugins/couchdb/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-couchdb -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-couchdb-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-couchdb-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-couchdb-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-couchdb-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://couchdb.apache.org[Apache +CouchDB]. -**All repos with foreign function interfaces MUST follow this standard:** +NoSQL document database. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add couchdb https://github.com/hyperpolymath/asdf-couchdb-plugin.git +---- -=== Web Projects +couchdb: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all couchdb -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install couchdb latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global couchdb latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now couchdb commands are available +couchdb --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list couchdb -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local couchdb -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall couchdb ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/couchdb/README.md b/asdf-plugin-collection/plugins/couchdb/README.md deleted file mode 100644 index 374c8a7e..00000000 --- a/asdf-plugin-collection/plugins/couchdb/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-couchdb - -[![Build](https://github.com/hyperpolymath/asdf-couchdb-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-couchdb-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-couchdb-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-couchdb-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Apache CouchDB](https://couchdb.apache.org). - -NoSQL document database. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add couchdb https://github.com/hyperpolymath/asdf-couchdb-plugin.git -``` - -couchdb: - -```bash -# Show all installable versions -asdf list-all couchdb - -# Install specific version -asdf install couchdb latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global couchdb latest - -# Now couchdb commands are available -couchdb --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list couchdb - -# Set local version for current directory -asdf local couchdb - -# Uninstall a version -asdf uninstall couchdb -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/couchdb/SECURITY.adoc b/asdf-plugin-collection/plugins/couchdb/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/couchdb/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/couchdb/SECURITY.md b/asdf-plugin-collection/plugins/couchdb/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/couchdb/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/cue/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/cue/ABI-FFI-README.adoc new file mode 100644 index 00000000..850cf0c3 --- /dev/null +++ b/asdf-plugin-collection/plugins/cue/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== CUE ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/cue.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libcue.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +cue/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── cue.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── cue.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/cue.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "cue.h" + +int main() { + void* handle = cue_init(); + if (!handle) return 1; + + int result = cue_process(handle, 42); + if (result != 0) { + const char* err = cue_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + cue_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lcue -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import CUE.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "cue")] +extern "C" { + fn cue_init() -> *mut std::ffi::c_void; + fn cue_free(handle: *mut std::ffi::c_void); + fn cue_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = cue_init(); + assert!(!handle.is_null()); + + let result = cue_process(handle, 42); + assert_eq!(result, 0); + + cue_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libcue = "libcue" + +function init() + handle = ccall((:cue_init, libcue), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:cue_process, libcue), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:cue_free, libcue), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/cue.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/cue/ABI-FFI-README.md b/asdf-plugin-collection/plugins/cue/ABI-FFI-README.md deleted file mode 100644 index 3bd1487e..00000000 --- a/asdf-plugin-collection/plugins/cue/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# CUE ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/cue.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libcue.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -cue/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── cue.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── cue.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/cue.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "cue.h" - -int main() { - void* handle = cue_init(); - if (!handle) return 1; - - int result = cue_process(handle, 42); - if (result != 0) { - const char* err = cue_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - cue_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lcue -L./zig-out/lib -``` - -### From Idris2 - -```idris -import CUE.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "cue")] -extern "C" { - fn cue_init() -> *mut std::ffi::c_void; - fn cue_free(handle: *mut std::ffi::c_void); - fn cue_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = cue_init(); - assert!(!handle.is_null()); - - let result = cue_process(handle, 42); - assert_eq!(result, 0); - - cue_free(handle); - } -} -``` - -### From Julia - -```julia -const libcue = "libcue" - -function init() - handle = ccall((:cue_init, libcue), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:cue_process, libcue), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:cue_free, libcue), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/cue.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/cue/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/cue/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/cue/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/cue/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/cue/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/cue/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/cue/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/cue/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/cue/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/cue/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/cue/CONTRIBUTING.md b/asdf-plugin-collection/plugins/cue/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/cue/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/cue/README.adoc b/asdf-plugin-collection/plugins/cue/README.adoc index d08e1dd2..51879d59 100644 --- a/asdf-plugin-collection/plugins/cue/README.adoc +++ b/asdf-plugin-collection/plugins/cue/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-cue -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-cue-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-cue-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-cue-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-cue-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://cuelang.org[CUE]. -**All repos with foreign function interfaces MUST follow this standard:** +Data validation language. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add cue https://github.com/hyperpolymath/asdf-cue-plugin.git +---- -=== Web Projects +cue: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all cue -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install cue latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global cue latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now cue commands are available +cue --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list cue -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local cue -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall cue ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/cue/README.md b/asdf-plugin-collection/plugins/cue/README.md deleted file mode 100644 index fbf1b418..00000000 --- a/asdf-plugin-collection/plugins/cue/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-cue - -[![Build](https://github.com/hyperpolymath/asdf-cue-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-cue-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-cue-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-cue-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [CUE](https://cuelang.org). - -Data validation language. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add cue https://github.com/hyperpolymath/asdf-cue-plugin.git -``` - -cue: - -```bash -# Show all installable versions -asdf list-all cue - -# Install specific version -asdf install cue latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global cue latest - -# Now cue commands are available -cue --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list cue - -# Set local version for current directory -asdf local cue - -# Uninstall a version -asdf uninstall cue -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/cue/SECURITY.adoc b/asdf-plugin-collection/plugins/cue/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/cue/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/cue/SECURITY.md b/asdf-plugin-collection/plugins/cue/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/cue/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/deno/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/deno/ABI-FFI-README.adoc new file mode 100644 index 00000000..ba563468 --- /dev/null +++ b/asdf-plugin-collection/plugins/deno/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== DENO ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/deno.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libdeno.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +deno/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── deno.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── deno.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/deno.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "deno.h" + +int main() { + void* handle = deno_init(); + if (!handle) return 1; + + int result = deno_process(handle, 42); + if (result != 0) { + const char* err = deno_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + deno_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -ldeno -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import DENO.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "deno")] +extern "C" { + fn deno_init() -> *mut std::ffi::c_void; + fn deno_free(handle: *mut std::ffi::c_void); + fn deno_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = deno_init(); + assert!(!handle.is_null()); + + let result = deno_process(handle, 42); + assert_eq!(result, 0); + + deno_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libdeno = "libdeno" + +function init() + handle = ccall((:deno_init, libdeno), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:deno_process, libdeno), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:deno_free, libdeno), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/deno.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/deno/ABI-FFI-README.md b/asdf-plugin-collection/plugins/deno/ABI-FFI-README.md deleted file mode 100644 index 10bd75bc..00000000 --- a/asdf-plugin-collection/plugins/deno/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# DENO ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/deno.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libdeno.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -deno/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── deno.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── deno.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/deno.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "deno.h" - -int main() { - void* handle = deno_init(); - if (!handle) return 1; - - int result = deno_process(handle, 42); - if (result != 0) { - const char* err = deno_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - deno_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -ldeno -L./zig-out/lib -``` - -### From Idris2 - -```idris -import DENO.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "deno")] -extern "C" { - fn deno_init() -> *mut std::ffi::c_void; - fn deno_free(handle: *mut std::ffi::c_void); - fn deno_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = deno_init(); - assert!(!handle.is_null()); - - let result = deno_process(handle, 42); - assert_eq!(result, 0); - - deno_free(handle); - } -} -``` - -### From Julia - -```julia -const libdeno = "libdeno" - -function init() - handle = ccall((:deno_init, libdeno), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:deno_process, libdeno), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:deno_free, libdeno), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/deno.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/deno/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/deno/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/deno/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/deno/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/deno/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/deno/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/deno/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/deno/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/deno/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/deno/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/deno/CONTRIBUTING.md b/asdf-plugin-collection/plugins/deno/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/deno/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/deno/README.adoc b/asdf-plugin-collection/plugins/deno/README.adoc index d08e1dd2..06e1239d 100644 --- a/asdf-plugin-collection/plugins/deno/README.adoc +++ b/asdf-plugin-collection/plugins/deno/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-deno -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-deno-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-deno-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-deno-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-deno-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://deno.land[Deno]. -**All repos with foreign function interfaces MUST follow this standard:** +Secure TypeScript/JavaScript runtime. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add deno https://github.com/hyperpolymath/asdf-deno-plugin.git +---- -=== Web Projects +deno: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all deno -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install deno latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global deno latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now deno commands are available +deno --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list deno -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local deno -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall deno ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/deno/README.md b/asdf-plugin-collection/plugins/deno/README.md deleted file mode 100644 index c07cf267..00000000 --- a/asdf-plugin-collection/plugins/deno/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-deno - -[![Build](https://github.com/hyperpolymath/asdf-deno-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-deno-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-deno-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-deno-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Deno](https://deno.land). - -Secure TypeScript/JavaScript runtime. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add deno https://github.com/hyperpolymath/asdf-deno-plugin.git -``` - -deno: - -```bash -# Show all installable versions -asdf list-all deno - -# Install specific version -asdf install deno latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global deno latest - -# Now deno commands are available -deno --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list deno - -# Set local version for current directory -asdf local deno - -# Uninstall a version -asdf uninstall deno -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/deno/SECURITY.adoc b/asdf-plugin-collection/plugins/deno/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/deno/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/deno/SECURITY.md b/asdf-plugin-collection/plugins/deno/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/deno/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/dhall/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/dhall/ABI-FFI-README.adoc new file mode 100644 index 00000000..14b6a8a8 --- /dev/null +++ b/asdf-plugin-collection/plugins/dhall/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== DHALL ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/dhall.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libdhall.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +dhall/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── dhall.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── dhall.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/dhall.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "dhall.h" + +int main() { + void* handle = dhall_init(); + if (!handle) return 1; + + int result = dhall_process(handle, 42); + if (result != 0) { + const char* err = dhall_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + dhall_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -ldhall -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import DHALL.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "dhall")] +extern "C" { + fn dhall_init() -> *mut std::ffi::c_void; + fn dhall_free(handle: *mut std::ffi::c_void); + fn dhall_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = dhall_init(); + assert!(!handle.is_null()); + + let result = dhall_process(handle, 42); + assert_eq!(result, 0); + + dhall_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libdhall = "libdhall" + +function init() + handle = ccall((:dhall_init, libdhall), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:dhall_process, libdhall), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:dhall_free, libdhall), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/dhall.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/dhall/ABI-FFI-README.md b/asdf-plugin-collection/plugins/dhall/ABI-FFI-README.md deleted file mode 100644 index 91fc1481..00000000 --- a/asdf-plugin-collection/plugins/dhall/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# DHALL ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/dhall.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libdhall.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -dhall/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── dhall.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── dhall.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/dhall.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "dhall.h" - -int main() { - void* handle = dhall_init(); - if (!handle) return 1; - - int result = dhall_process(handle, 42); - if (result != 0) { - const char* err = dhall_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - dhall_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -ldhall -L./zig-out/lib -``` - -### From Idris2 - -```idris -import DHALL.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "dhall")] -extern "C" { - fn dhall_init() -> *mut std::ffi::c_void; - fn dhall_free(handle: *mut std::ffi::c_void); - fn dhall_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = dhall_init(); - assert!(!handle.is_null()); - - let result = dhall_process(handle, 42); - assert_eq!(result, 0); - - dhall_free(handle); - } -} -``` - -### From Julia - -```julia -const libdhall = "libdhall" - -function init() - handle = ccall((:dhall_init, libdhall), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:dhall_process, libdhall), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:dhall_free, libdhall), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/dhall.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/dhall/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/dhall/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/dhall/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/dhall/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/dhall/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/dhall/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/dhall/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/dhall/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/dhall/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/dhall/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/dhall/CONTRIBUTING.md b/asdf-plugin-collection/plugins/dhall/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/dhall/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/dhall/README.adoc b/asdf-plugin-collection/plugins/dhall/README.adoc index d08e1dd2..ca06ba48 100644 --- a/asdf-plugin-collection/plugins/dhall/README.adoc +++ b/asdf-plugin-collection/plugins/dhall/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-dhall -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-dhall-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-dhall-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-dhall-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-dhall-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://dhall-lang.org[Dhall]. -**All repos with foreign function interfaces MUST follow this standard:** +Programmable configuration. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add dhall https://github.com/hyperpolymath/asdf-dhall-plugin.git +---- -=== Web Projects +dhall: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all dhall -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install dhall latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global dhall latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now dhall commands are available +dhall --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list dhall -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local dhall -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall dhall ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/dhall/README.md b/asdf-plugin-collection/plugins/dhall/README.md deleted file mode 100644 index 6faab96a..00000000 --- a/asdf-plugin-collection/plugins/dhall/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-dhall - -[![Build](https://github.com/hyperpolymath/asdf-dhall-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-dhall-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-dhall-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-dhall-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Dhall](https://dhall-lang.org). - -Programmable configuration. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add dhall https://github.com/hyperpolymath/asdf-dhall-plugin.git -``` - -dhall: - -```bash -# Show all installable versions -asdf list-all dhall - -# Install specific version -asdf install dhall latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global dhall latest - -# Now dhall commands are available -dhall --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list dhall - -# Set local version for current directory -asdf local dhall - -# Uninstall a version -asdf uninstall dhall -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/dhall/SECURITY.adoc b/asdf-plugin-collection/plugins/dhall/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/dhall/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/dhall/SECURITY.md b/asdf-plugin-collection/plugins/dhall/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/dhall/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/doctl/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/doctl/ABI-FFI-README.adoc new file mode 100644 index 00000000..4d5d4fab --- /dev/null +++ b/asdf-plugin-collection/plugins/doctl/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== DOCTL ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/doctl.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libdoctl.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +doctl/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── doctl.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── doctl.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/doctl.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "doctl.h" + +int main() { + void* handle = doctl_init(); + if (!handle) return 1; + + int result = doctl_process(handle, 42); + if (result != 0) { + const char* err = doctl_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + doctl_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -ldoctl -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import DOCTL.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "doctl")] +extern "C" { + fn doctl_init() -> *mut std::ffi::c_void; + fn doctl_free(handle: *mut std::ffi::c_void); + fn doctl_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = doctl_init(); + assert!(!handle.is_null()); + + let result = doctl_process(handle, 42); + assert_eq!(result, 0); + + doctl_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libdoctl = "libdoctl" + +function init() + handle = ccall((:doctl_init, libdoctl), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:doctl_process, libdoctl), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:doctl_free, libdoctl), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/doctl.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/doctl/ABI-FFI-README.md b/asdf-plugin-collection/plugins/doctl/ABI-FFI-README.md deleted file mode 100644 index 0da3bc65..00000000 --- a/asdf-plugin-collection/plugins/doctl/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# DOCTL ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/doctl.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libdoctl.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -doctl/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── doctl.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── doctl.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/doctl.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "doctl.h" - -int main() { - void* handle = doctl_init(); - if (!handle) return 1; - - int result = doctl_process(handle, 42); - if (result != 0) { - const char* err = doctl_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - doctl_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -ldoctl -L./zig-out/lib -``` - -### From Idris2 - -```idris -import DOCTL.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "doctl")] -extern "C" { - fn doctl_init() -> *mut std::ffi::c_void; - fn doctl_free(handle: *mut std::ffi::c_void); - fn doctl_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = doctl_init(); - assert!(!handle.is_null()); - - let result = doctl_process(handle, 42); - assert_eq!(result, 0); - - doctl_free(handle); - } -} -``` - -### From Julia - -```julia -const libdoctl = "libdoctl" - -function init() - handle = ccall((:doctl_init, libdoctl), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:doctl_process, libdoctl), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:doctl_free, libdoctl), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/doctl.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/doctl/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/doctl/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/doctl/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/doctl/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/doctl/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/doctl/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/doctl/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/doctl/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/doctl/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/doctl/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/doctl/CONTRIBUTING.md b/asdf-plugin-collection/plugins/doctl/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/doctl/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/doctl/README.adoc b/asdf-plugin-collection/plugins/doctl/README.adoc index d08e1dd2..ccf6797a 100644 --- a/asdf-plugin-collection/plugins/doctl/README.adoc +++ b/asdf-plugin-collection/plugins/doctl/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-doctl -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-doctl-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-doctl-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-doctl-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-doctl-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://docs.digitalocean.com/reference/doctl[DigitalOcean CLI]. -**All repos with foreign function interfaces MUST follow this standard:** +DO command-line. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add doctl https://github.com/hyperpolymath/asdf-doctl-plugin.git +---- -=== Web Projects +doctl: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all doctl -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install doctl latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global doctl latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now doctl commands are available +doctl --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list doctl -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local doctl -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall doctl ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/doctl/README.md b/asdf-plugin-collection/plugins/doctl/README.md deleted file mode 100644 index cf5eec8b..00000000 --- a/asdf-plugin-collection/plugins/doctl/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-doctl - -[![Build](https://github.com/hyperpolymath/asdf-doctl-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-doctl-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-doctl-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-doctl-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [DigitalOcean CLI](https://docs.digitalocean.com/reference/doctl). - -DO command-line. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add doctl https://github.com/hyperpolymath/asdf-doctl-plugin.git -``` - -doctl: - -```bash -# Show all installable versions -asdf list-all doctl - -# Install specific version -asdf install doctl latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global doctl latest - -# Now doctl commands are available -doctl --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list doctl - -# Set local version for current directory -asdf local doctl - -# Uninstall a version -asdf uninstall doctl -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/doctl/SECURITY.adoc b/asdf-plugin-collection/plugins/doctl/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/doctl/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/doctl/SECURITY.md b/asdf-plugin-collection/plugins/doctl/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/doctl/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/dragonfly/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/dragonfly/ABI-FFI-README.adoc new file mode 100644 index 00000000..9959a0d9 --- /dev/null +++ b/asdf-plugin-collection/plugins/dragonfly/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== DRAGONFLY ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/dragonfly.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libdragonfly.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +dragonfly/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── dragonfly.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── dragonfly.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/dragonfly.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "dragonfly.h" + +int main() { + void* handle = dragonfly_init(); + if (!handle) return 1; + + int result = dragonfly_process(handle, 42); + if (result != 0) { + const char* err = dragonfly_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + dragonfly_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -ldragonfly -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import DRAGONFLY.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "dragonfly")] +extern "C" { + fn dragonfly_init() -> *mut std::ffi::c_void; + fn dragonfly_free(handle: *mut std::ffi::c_void); + fn dragonfly_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = dragonfly_init(); + assert!(!handle.is_null()); + + let result = dragonfly_process(handle, 42); + assert_eq!(result, 0); + + dragonfly_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libdragonfly = "libdragonfly" + +function init() + handle = ccall((:dragonfly_init, libdragonfly), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:dragonfly_process, libdragonfly), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:dragonfly_free, libdragonfly), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/dragonfly.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/dragonfly/ABI-FFI-README.md b/asdf-plugin-collection/plugins/dragonfly/ABI-FFI-README.md deleted file mode 100644 index f4a92036..00000000 --- a/asdf-plugin-collection/plugins/dragonfly/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# DRAGONFLY ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/dragonfly.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libdragonfly.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -dragonfly/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── dragonfly.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── dragonfly.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/dragonfly.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "dragonfly.h" - -int main() { - void* handle = dragonfly_init(); - if (!handle) return 1; - - int result = dragonfly_process(handle, 42); - if (result != 0) { - const char* err = dragonfly_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - dragonfly_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -ldragonfly -L./zig-out/lib -``` - -### From Idris2 - -```idris -import DRAGONFLY.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "dragonfly")] -extern "C" { - fn dragonfly_init() -> *mut std::ffi::c_void; - fn dragonfly_free(handle: *mut std::ffi::c_void); - fn dragonfly_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = dragonfly_init(); - assert!(!handle.is_null()); - - let result = dragonfly_process(handle, 42); - assert_eq!(result, 0); - - dragonfly_free(handle); - } -} -``` - -### From Julia - -```julia -const libdragonfly = "libdragonfly" - -function init() - handle = ccall((:dragonfly_init, libdragonfly), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:dragonfly_process, libdragonfly), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:dragonfly_free, libdragonfly), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/dragonfly.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/dragonfly/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/dragonfly/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/dragonfly/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/dragonfly/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/dragonfly/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/dragonfly/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/dragonfly/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/dragonfly/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/dragonfly/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/dragonfly/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/dragonfly/CONTRIBUTING.md b/asdf-plugin-collection/plugins/dragonfly/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/dragonfly/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/dragonfly/README.adoc b/asdf-plugin-collection/plugins/dragonfly/README.adoc index d08e1dd2..49b3536a 100644 --- a/asdf-plugin-collection/plugins/dragonfly/README.adoc +++ b/asdf-plugin-collection/plugins/dragonfly/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-dragonfly -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-dragonfly-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-dragonfly-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-dragonfly-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-dragonfly-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://dragonflydb.io[Dragonfly]. -**All repos with foreign function interfaces MUST follow this standard:** +Redis-compatible datastore. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add dragonfly https://github.com/hyperpolymath/asdf-dragonfly-plugin.git +---- -=== Web Projects +dragonfly: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all dragonfly -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install dragonfly latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global dragonfly latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now dragonfly commands are available +dragonfly --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list dragonfly -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local dragonfly -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall dragonfly ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/dragonfly/README.md b/asdf-plugin-collection/plugins/dragonfly/README.md deleted file mode 100644 index 8ec1224b..00000000 --- a/asdf-plugin-collection/plugins/dragonfly/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-dragonfly - -[![Build](https://github.com/hyperpolymath/asdf-dragonfly-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-dragonfly-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-dragonfly-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-dragonfly-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Dragonfly](https://dragonflydb.io). - -Redis-compatible datastore. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add dragonfly https://github.com/hyperpolymath/asdf-dragonfly-plugin.git -``` - -dragonfly: - -```bash -# Show all installable versions -asdf list-all dragonfly - -# Install specific version -asdf install dragonfly latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global dragonfly latest - -# Now dragonfly commands are available -dragonfly --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list dragonfly - -# Set local version for current directory -asdf local dragonfly - -# Uninstall a version -asdf uninstall dragonfly -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/dragonfly/SECURITY.adoc b/asdf-plugin-collection/plugins/dragonfly/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/dragonfly/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/dragonfly/SECURITY.md b/asdf-plugin-collection/plugins/dragonfly/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/dragonfly/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/envoy/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/envoy/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/envoy/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/envoy/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/envoy/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/envoy/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/envoy/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/envoy/CONTRIBUTING.adoc index d18532b5..e86d3f29 100644 --- a/asdf-plugin-collection/plugins/envoy/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/envoy/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-envoy-plugin.git cd +asdf-envoy-plugin -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-envoy-plugin-dev toolbox enter asdf-envoy-plugin-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-envoy-plugin/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-envoy-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-envoy-plugin/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-envoy-plugin/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-envoy-plugin/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/envoy/CONTRIBUTING.md b/asdf-plugin-collection/plugins/envoy/CONTRIBUTING.md deleted file mode 100644 index f0947d18..00000000 --- a/asdf-plugin-collection/plugins/envoy/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-envoy-plugin.git -cd asdf-envoy-plugin - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-envoy-plugin-dev -toolbox enter asdf-envoy-plugin-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-envoy-plugin/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-envoy-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-envoy-plugin/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-envoy-plugin/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-envoy-plugin/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/envoy/README.adoc b/asdf-plugin-collection/plugins/envoy/README.adoc new file mode 100644 index 00000000..c236d9e1 --- /dev/null +++ b/asdf-plugin-collection/plugins/envoy/README.adoc @@ -0,0 +1,83 @@ +== asdf-envoy + +https://github.com/hyperpolymath/asdf-envoy-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-envoy-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-envoy-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-envoy-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] + +https://asdf-vm.com[asdf] plugin for https://www.envoyproxy.io[Envoy +Proxy]. + +Cloud-native proxy. + +=== Contents + +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] + +=== Dependencies + +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] + +=== Install + +Plugin: + +[source,bash] +---- +asdf plugin add envoy https://github.com/hyperpolymath/asdf-envoy-plugin.git +---- + +envoy: + +[source,bash] +---- +# Show all installable versions +asdf list-all envoy + +# Install specific version +asdf install envoy latest + +# Set a version globally (in your ~/.tool-versions file) +asdf global envoy latest + +# Now envoy commands are available +envoy --version +---- + +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. + +=== Usage + +[source,bash] +---- +# List installed versions +asdf list envoy + +# Set local version for current directory +asdf local envoy + +# Uninstall a version +asdf uninstall envoy +---- + +=== Contributing + +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License + +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. + +''''' + +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/envoy/README.md b/asdf-plugin-collection/plugins/envoy/README.md deleted file mode 100644 index c294b14f..00000000 --- a/asdf-plugin-collection/plugins/envoy/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-envoy - -[![Build](https://github.com/hyperpolymath/asdf-envoy-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-envoy-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-envoy-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-envoy-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Envoy Proxy](https://www.envoyproxy.io). - -Cloud-native proxy. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add envoy https://github.com/hyperpolymath/asdf-envoy-plugin.git -``` - -envoy: - -```bash -# Show all installable versions -asdf list-all envoy - -# Install specific version -asdf install envoy latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global envoy latest - -# Now envoy commands are available -envoy --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list envoy - -# Set local version for current directory -asdf local envoy - -# Uninstall a version -asdf uninstall envoy -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/envoy/SECURITY.adoc b/asdf-plugin-collection/plugins/envoy/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/envoy/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/envoy/SECURITY.md b/asdf-plugin-collection/plugins/envoy/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/envoy/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/fornax/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/fornax/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/fornax/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/fornax/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/fornax/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/fornax/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/fornax/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/fornax/CONTRIBUTING.adoc index d18532b5..16fd4e4f 100644 --- a/asdf-plugin-collection/plugins/fornax/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/fornax/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-fornax-plugin.git cd +asdf-fornax-plugin -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-fornax-plugin-dev toolbox enter +asdf-fornax-plugin-dev # Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-fornax-plugin/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-fornax-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-fornax-plugin/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-fornax-plugin/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-fornax-plugin/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/fornax/CONTRIBUTING.md b/asdf-plugin-collection/plugins/fornax/CONTRIBUTING.md deleted file mode 100644 index 3a40ee9c..00000000 --- a/asdf-plugin-collection/plugins/fornax/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-fornax-plugin.git -cd asdf-fornax-plugin - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-fornax-plugin-dev -toolbox enter asdf-fornax-plugin-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-fornax-plugin/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-fornax-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-fornax-plugin/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-fornax-plugin/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-fornax-plugin/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/fornax/README.adoc b/asdf-plugin-collection/plugins/fornax/README.adoc new file mode 100644 index 00000000..5bf382d3 --- /dev/null +++ b/asdf-plugin-collection/plugins/fornax/README.adoc @@ -0,0 +1,83 @@ +== asdf-fornax + +https://github.com/hyperpolymath/asdf-fornax-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-fornax-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-fornax-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-fornax-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] + +https://asdf-vm.com[asdf] plugin for +https://github.com/katef/fornax[Fornax]. + +Static site generator. + +=== Contents + +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] + +=== Dependencies + +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] + +=== Install + +Plugin: + +[source,bash] +---- +asdf plugin add fornax https://github.com/hyperpolymath/asdf-fornax-plugin.git +---- + +fornax: + +[source,bash] +---- +# Show all installable versions +asdf list-all fornax + +# Install specific version +asdf install fornax latest + +# Set a version globally (in your ~/.tool-versions file) +asdf global fornax latest + +# Now fornax commands are available +fornax --version +---- + +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. + +=== Usage + +[source,bash] +---- +# List installed versions +asdf list fornax + +# Set local version for current directory +asdf local fornax + +# Uninstall a version +asdf uninstall fornax +---- + +=== Contributing + +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License + +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. + +''''' + +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/fornax/README.md b/asdf-plugin-collection/plugins/fornax/README.md deleted file mode 100644 index 407fc39e..00000000 --- a/asdf-plugin-collection/plugins/fornax/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-fornax - -[![Build](https://github.com/hyperpolymath/asdf-fornax-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-fornax-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-fornax-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-fornax-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Fornax](https://github.com/katef/fornax). - -Static site generator. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add fornax https://github.com/hyperpolymath/asdf-fornax-plugin.git -``` - -fornax: - -```bash -# Show all installable versions -asdf list-all fornax - -# Install specific version -asdf install fornax latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global fornax latest - -# Now fornax commands are available -fornax --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list fornax - -# Set local version for current directory -asdf local fornax - -# Uninstall a version -asdf uninstall fornax -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/fornax/SECURITY.adoc b/asdf-plugin-collection/plugins/fornax/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/fornax/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/fornax/SECURITY.md b/asdf-plugin-collection/plugins/fornax/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/fornax/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/fortran/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/fortran/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/fortran/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/fortran/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/fortran/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/fortran/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/fortran/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/fortran/CONTRIBUTING.adoc index d18532b5..c1d537f7 100644 --- a/asdf-plugin-collection/plugins/fortran/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/fortran/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-fortran-plugin.git cd +asdf-fortran-plugin -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-fortran-plugin-dev toolbox enter +asdf-fortran-plugin-dev # Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-fortran-plugin/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-fortran-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-fortran-plugin/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-fortran-plugin/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-fortran-plugin/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/fortran/CONTRIBUTING.md b/asdf-plugin-collection/plugins/fortran/CONTRIBUTING.md deleted file mode 100644 index d6943f4a..00000000 --- a/asdf-plugin-collection/plugins/fortran/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-fortran-plugin.git -cd asdf-fortran-plugin - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-fortran-plugin-dev -toolbox enter asdf-fortran-plugin-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-fortran-plugin/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-fortran-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-fortran-plugin/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-fortran-plugin/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-fortran-plugin/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/fortran/README.adoc b/asdf-plugin-collection/plugins/fortran/README.adoc new file mode 100644 index 00000000..a297d1ad --- /dev/null +++ b/asdf-plugin-collection/plugins/fortran/README.adoc @@ -0,0 +1,83 @@ +== asdf-fortran + +https://github.com/hyperpolymath/asdf-fortran-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-fortran-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-fortran-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-fortran-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] + +https://asdf-vm.com[asdf] plugin for +https://gcc.gnu.org/fortran[GFortran]. + +GNU Fortran compiler. + +=== Contents + +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] + +=== Dependencies + +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] + +=== Install + +Plugin: + +[source,bash] +---- +asdf plugin add fortran https://github.com/hyperpolymath/asdf-fortran-plugin.git +---- + +fortran: + +[source,bash] +---- +# Show all installable versions +asdf list-all fortran + +# Install specific version +asdf install fortran latest + +# Set a version globally (in your ~/.tool-versions file) +asdf global fortran latest + +# Now fortran commands are available +fortran --version +---- + +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. + +=== Usage + +[source,bash] +---- +# List installed versions +asdf list fortran + +# Set local version for current directory +asdf local fortran + +# Uninstall a version +asdf uninstall fortran +---- + +=== Contributing + +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License + +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. + +''''' + +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/fortran/README.md b/asdf-plugin-collection/plugins/fortran/README.md deleted file mode 100644 index 78c8c1d8..00000000 --- a/asdf-plugin-collection/plugins/fortran/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-fortran - -[![Build](https://github.com/hyperpolymath/asdf-fortran-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-fortran-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-fortran-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-fortran-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [GFortran](https://gcc.gnu.org/fortran). - -GNU Fortran compiler. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add fortran https://github.com/hyperpolymath/asdf-fortran-plugin.git -``` - -fortran: - -```bash -# Show all installable versions -asdf list-all fortran - -# Install specific version -asdf install fortran latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global fortran latest - -# Now fortran commands are available -fortran --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list fortran - -# Set local version for current directory -asdf local fortran - -# Uninstall a version -asdf uninstall fortran -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/fortran/SECURITY.adoc b/asdf-plugin-collection/plugins/fortran/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/fortran/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/fortran/SECURITY.md b/asdf-plugin-collection/plugins/fortran/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/fortran/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/franklin/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/franklin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/franklin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/franklin/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/franklin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/franklin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/franklin/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/franklin/CONTRIBUTING.adoc index d18532b5..3e266b5e 100644 --- a/asdf-plugin-collection/plugins/franklin/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/franklin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-franklin-plugin.git cd +asdf-franklin-plugin -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-franklin-plugin-dev toolbox enter +asdf-franklin-plugin-dev # Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-franklin-plugin/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-franklin-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-franklin-plugin/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-franklin-plugin/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-franklin-plugin/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/franklin/CONTRIBUTING.md b/asdf-plugin-collection/plugins/franklin/CONTRIBUTING.md deleted file mode 100644 index 9c51f54a..00000000 --- a/asdf-plugin-collection/plugins/franklin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-franklin-plugin.git -cd asdf-franklin-plugin - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-franklin-plugin-dev -toolbox enter asdf-franklin-plugin-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-franklin-plugin/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-franklin-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-franklin-plugin/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-franklin-plugin/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-franklin-plugin/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/franklin/README.adoc b/asdf-plugin-collection/plugins/franklin/README.adoc new file mode 100644 index 00000000..f1f882c6 --- /dev/null +++ b/asdf-plugin-collection/plugins/franklin/README.adoc @@ -0,0 +1,83 @@ +== asdf-franklin + +https://github.com/hyperpolymath/asdf-franklin-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-franklin-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-franklin-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-franklin-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] + +https://asdf-vm.com[asdf] plugin for +https://franklinjl.org[Franklin.jl]. + +Julia static site generator. + +=== Contents + +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] + +=== Dependencies + +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] + +=== Install + +Plugin: + +[source,bash] +---- +asdf plugin add franklin https://github.com/hyperpolymath/asdf-franklin-plugin.git +---- + +franklin: + +[source,bash] +---- +# Show all installable versions +asdf list-all franklin + +# Install specific version +asdf install franklin latest + +# Set a version globally (in your ~/.tool-versions file) +asdf global franklin latest + +# Now franklin commands are available +franklin --version +---- + +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. + +=== Usage + +[source,bash] +---- +# List installed versions +asdf list franklin + +# Set local version for current directory +asdf local franklin + +# Uninstall a version +asdf uninstall franklin +---- + +=== Contributing + +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License + +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. + +''''' + +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/franklin/README.md b/asdf-plugin-collection/plugins/franklin/README.md deleted file mode 100644 index 72876015..00000000 --- a/asdf-plugin-collection/plugins/franklin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-franklin - -[![Build](https://github.com/hyperpolymath/asdf-franklin-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-franklin-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-franklin-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-franklin-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Franklin.jl](https://franklinjl.org). - -Julia static site generator. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add franklin https://github.com/hyperpolymath/asdf-franklin-plugin.git -``` - -franklin: - -```bash -# Show all installable versions -asdf list-all franklin - -# Install specific version -asdf install franklin latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global franklin latest - -# Now franklin commands are available -franklin --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list franklin - -# Set local version for current directory -asdf local franklin - -# Uninstall a version -asdf uninstall franklin -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/franklin/SECURITY.adoc b/asdf-plugin-collection/plugins/franklin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/franklin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/franklin/SECURITY.md b/asdf-plugin-collection/plugins/franklin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/franklin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/fulcio/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/fulcio/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/fulcio/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/fulcio/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/fulcio/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/fulcio/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/fulcio/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/fulcio/CONTRIBUTING.adoc index d18532b5..1d015055 100644 --- a/asdf-plugin-collection/plugins/fulcio/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/fulcio/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-fulcio-plugin.git cd +asdf-fulcio-plugin -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-fulcio-plugin-dev toolbox enter +asdf-fulcio-plugin-dev # Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-fulcio-plugin/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-fulcio-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-fulcio-plugin/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-fulcio-plugin/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-fulcio-plugin/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/fulcio/CONTRIBUTING.md b/asdf-plugin-collection/plugins/fulcio/CONTRIBUTING.md deleted file mode 100644 index c61ac639..00000000 --- a/asdf-plugin-collection/plugins/fulcio/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-fulcio-plugin.git -cd asdf-fulcio-plugin - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-fulcio-plugin-dev -toolbox enter asdf-fulcio-plugin-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-fulcio-plugin/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-fulcio-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-fulcio-plugin/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-fulcio-plugin/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-fulcio-plugin/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/fulcio/README.adoc b/asdf-plugin-collection/plugins/fulcio/README.adoc new file mode 100644 index 00000000..b81f375d --- /dev/null +++ b/asdf-plugin-collection/plugins/fulcio/README.adoc @@ -0,0 +1,82 @@ +== asdf-fulcio + +https://github.com/hyperpolymath/asdf-fulcio-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-fulcio-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-fulcio-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-fulcio-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] + +https://asdf-vm.com[asdf] plugin for https://sigstore.dev[Fulcio]. + +Sigstore certificate authority. + +=== Contents + +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] + +=== Dependencies + +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] + +=== Install + +Plugin: + +[source,bash] +---- +asdf plugin add fulcio https://github.com/hyperpolymath/asdf-fulcio-plugin.git +---- + +fulcio: + +[source,bash] +---- +# Show all installable versions +asdf list-all fulcio + +# Install specific version +asdf install fulcio latest + +# Set a version globally (in your ~/.tool-versions file) +asdf global fulcio latest + +# Now fulcio commands are available +fulcio --version +---- + +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. + +=== Usage + +[source,bash] +---- +# List installed versions +asdf list fulcio + +# Set local version for current directory +asdf local fulcio + +# Uninstall a version +asdf uninstall fulcio +---- + +=== Contributing + +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License + +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. + +''''' + +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/fulcio/README.md b/asdf-plugin-collection/plugins/fulcio/README.md deleted file mode 100644 index 7779116b..00000000 --- a/asdf-plugin-collection/plugins/fulcio/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-fulcio - -[![Build](https://github.com/hyperpolymath/asdf-fulcio-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-fulcio-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-fulcio-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-fulcio-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Fulcio](https://sigstore.dev). - -Sigstore certificate authority. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add fulcio https://github.com/hyperpolymath/asdf-fulcio-plugin.git -``` - -fulcio: - -```bash -# Show all installable versions -asdf list-all fulcio - -# Install specific version -asdf install fulcio latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global fulcio latest - -# Now fulcio commands are available -fulcio --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list fulcio - -# Set local version for current directory -asdf local fulcio - -# Uninstall a version -asdf uninstall fulcio -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/fulcio/SECURITY.adoc b/asdf-plugin-collection/plugins/fulcio/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/fulcio/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/fulcio/SECURITY.md b/asdf-plugin-collection/plugins/fulcio/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/fulcio/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/git-crypt/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/git-crypt/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/git-crypt/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/git-crypt/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/git-crypt/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/git-crypt/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/git-crypt/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/git-crypt/CONTRIBUTING.adoc index d18532b5..9a66b532 100644 --- a/asdf-plugin-collection/plugins/git-crypt/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/git-crypt/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-git-crypt-plugin.git cd +asdf-git-crypt-plugin -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-git-crypt-plugin-dev toolbox enter +asdf-git-crypt-plugin-dev # Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-git-crypt-plugin/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-git-crypt-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-git-crypt-plugin/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-git-crypt-plugin/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-git-crypt-plugin/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/git-crypt/CONTRIBUTING.md b/asdf-plugin-collection/plugins/git-crypt/CONTRIBUTING.md deleted file mode 100644 index 0e6907aa..00000000 --- a/asdf-plugin-collection/plugins/git-crypt/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-git-crypt-plugin.git -cd asdf-git-crypt-plugin - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-git-crypt-plugin-dev -toolbox enter asdf-git-crypt-plugin-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-git-crypt-plugin/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-git-crypt-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-git-crypt-plugin/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-git-crypt-plugin/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-git-crypt-plugin/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/git-crypt/README.adoc b/asdf-plugin-collection/plugins/git-crypt/README.adoc new file mode 100644 index 00000000..8d477498 --- /dev/null +++ b/asdf-plugin-collection/plugins/git-crypt/README.adoc @@ -0,0 +1,83 @@ +== asdf-git-crypt + +https://github.com/hyperpolymath/asdf-git-crypt-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-git-crypt-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-git-crypt-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-git-crypt-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] + +https://asdf-vm.com[asdf] plugin for +https://www.agwa.name/projects/git-crypt[git-crypt]. + +Transparent git encryption. + +=== Contents + +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] + +=== Dependencies + +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] + +=== Install + +Plugin: + +[source,bash] +---- +asdf plugin add git-crypt https://github.com/hyperpolymath/asdf-git-crypt-plugin.git +---- + +git-crypt: + +[source,bash] +---- +# Show all installable versions +asdf list-all git-crypt + +# Install specific version +asdf install git-crypt latest + +# Set a version globally (in your ~/.tool-versions file) +asdf global git-crypt latest + +# Now git-crypt commands are available +git-crypt --version +---- + +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. + +=== Usage + +[source,bash] +---- +# List installed versions +asdf list git-crypt + +# Set local version for current directory +asdf local git-crypt + +# Uninstall a version +asdf uninstall git-crypt +---- + +=== Contributing + +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License + +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. + +''''' + +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/git-crypt/README.md b/asdf-plugin-collection/plugins/git-crypt/README.md deleted file mode 100644 index 1ee1fac7..00000000 --- a/asdf-plugin-collection/plugins/git-crypt/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-git-crypt - -[![Build](https://github.com/hyperpolymath/asdf-git-crypt-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-git-crypt-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-git-crypt-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-git-crypt-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [git-crypt](https://www.agwa.name/projects/git-crypt). - -Transparent git encryption. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add git-crypt https://github.com/hyperpolymath/asdf-git-crypt-plugin.git -``` - -git-crypt: - -```bash -# Show all installable versions -asdf list-all git-crypt - -# Install specific version -asdf install git-crypt latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global git-crypt latest - -# Now git-crypt commands are available -git-crypt --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list git-crypt - -# Set local version for current directory -asdf local git-crypt - -# Uninstall a version -asdf uninstall git-crypt -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/git-crypt/SECURITY.adoc b/asdf-plugin-collection/plugins/git-crypt/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/git-crypt/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/git-crypt/SECURITY.md b/asdf-plugin-collection/plugins/git-crypt/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/git-crypt/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/gitleaks/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/gitleaks/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/gitleaks/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/gitleaks/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/gitleaks/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/gitleaks/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/gitleaks/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/gitleaks/CONTRIBUTING.adoc index d18532b5..9b949070 100644 --- a/asdf-plugin-collection/plugins/gitleaks/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/gitleaks/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-gitleaks-plugin.git cd +asdf-gitleaks-plugin -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-gitleaks-plugin-dev toolbox enter +asdf-gitleaks-plugin-dev # Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-gitleaks-plugin/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-gitleaks-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-gitleaks-plugin/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-gitleaks-plugin/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-gitleaks-plugin/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/gitleaks/CONTRIBUTING.md b/asdf-plugin-collection/plugins/gitleaks/CONTRIBUTING.md deleted file mode 100644 index 8f0b9ebf..00000000 --- a/asdf-plugin-collection/plugins/gitleaks/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-gitleaks-plugin.git -cd asdf-gitleaks-plugin - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-gitleaks-plugin-dev -toolbox enter asdf-gitleaks-plugin-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-gitleaks-plugin/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-gitleaks-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-gitleaks-plugin/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-gitleaks-plugin/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-gitleaks-plugin/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/gitleaks/README.adoc b/asdf-plugin-collection/plugins/gitleaks/README.adoc new file mode 100644 index 00000000..7ec85981 --- /dev/null +++ b/asdf-plugin-collection/plugins/gitleaks/README.adoc @@ -0,0 +1,82 @@ +== asdf-gitleaks + +https://github.com/hyperpolymath/asdf-gitleaks-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-gitleaks-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-gitleaks-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-gitleaks-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] + +https://asdf-vm.com[asdf] plugin for https://gitleaks.io[Gitleaks]. + +Git secret scanner. + +=== Contents + +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] + +=== Dependencies + +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] + +=== Install + +Plugin: + +[source,bash] +---- +asdf plugin add gitleaks https://github.com/hyperpolymath/asdf-gitleaks-plugin.git +---- + +gitleaks: + +[source,bash] +---- +# Show all installable versions +asdf list-all gitleaks + +# Install specific version +asdf install gitleaks latest + +# Set a version globally (in your ~/.tool-versions file) +asdf global gitleaks latest + +# Now gitleaks commands are available +gitleaks --version +---- + +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. + +=== Usage + +[source,bash] +---- +# List installed versions +asdf list gitleaks + +# Set local version for current directory +asdf local gitleaks + +# Uninstall a version +asdf uninstall gitleaks +---- + +=== Contributing + +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License + +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. + +''''' + +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/gitleaks/README.md b/asdf-plugin-collection/plugins/gitleaks/README.md deleted file mode 100644 index 946db3a6..00000000 --- a/asdf-plugin-collection/plugins/gitleaks/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-gitleaks - -[![Build](https://github.com/hyperpolymath/asdf-gitleaks-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-gitleaks-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-gitleaks-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-gitleaks-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Gitleaks](https://gitleaks.io). - -Git secret scanner. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add gitleaks https://github.com/hyperpolymath/asdf-gitleaks-plugin.git -``` - -gitleaks: - -```bash -# Show all installable versions -asdf list-all gitleaks - -# Install specific version -asdf install gitleaks latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global gitleaks latest - -# Now gitleaks commands are available -gitleaks --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list gitleaks - -# Set local version for current directory -asdf local gitleaks - -# Uninstall a version -asdf uninstall gitleaks -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/gitleaks/SECURITY.adoc b/asdf-plugin-collection/plugins/gitleaks/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/gitleaks/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/gitleaks/SECURITY.md b/asdf-plugin-collection/plugins/gitleaks/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/gitleaks/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/grype/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/grype/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/grype/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/grype/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/grype/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/grype/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/grype/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/grype/CONTRIBUTING.adoc index d18532b5..a4cb53c3 100644 --- a/asdf-plugin-collection/plugins/grype/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/grype/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-grype-plugin.git cd +asdf-grype-plugin -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-grype-plugin-dev toolbox enter asdf-grype-plugin-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-grype-plugin/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-grype-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-grype-plugin/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-grype-plugin/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-grype-plugin/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/grype/CONTRIBUTING.md b/asdf-plugin-collection/plugins/grype/CONTRIBUTING.md deleted file mode 100644 index f0263d08..00000000 --- a/asdf-plugin-collection/plugins/grype/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-grype-plugin.git -cd asdf-grype-plugin - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-grype-plugin-dev -toolbox enter asdf-grype-plugin-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-grype-plugin/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-grype-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-grype-plugin/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-grype-plugin/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-grype-plugin/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/grype/README.adoc b/asdf-plugin-collection/plugins/grype/README.adoc new file mode 100644 index 00000000..3db2f688 --- /dev/null +++ b/asdf-plugin-collection/plugins/grype/README.adoc @@ -0,0 +1,82 @@ +== asdf-grype + +https://github.com/hyperpolymath/asdf-grype-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-grype-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-grype-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-grype-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] + +https://asdf-vm.com[asdf] plugin for https://anchore.com/grype[Grype]. + +Container vulnerability scanner. + +=== Contents + +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] + +=== Dependencies + +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] + +=== Install + +Plugin: + +[source,bash] +---- +asdf plugin add grype https://github.com/hyperpolymath/asdf-grype-plugin.git +---- + +grype: + +[source,bash] +---- +# Show all installable versions +asdf list-all grype + +# Install specific version +asdf install grype latest + +# Set a version globally (in your ~/.tool-versions file) +asdf global grype latest + +# Now grype commands are available +grype --version +---- + +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. + +=== Usage + +[source,bash] +---- +# List installed versions +asdf list grype + +# Set local version for current directory +asdf local grype + +# Uninstall a version +asdf uninstall grype +---- + +=== Contributing + +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License + +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. + +''''' + +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/grype/README.md b/asdf-plugin-collection/plugins/grype/README.md deleted file mode 100644 index 087a519a..00000000 --- a/asdf-plugin-collection/plugins/grype/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-grype - -[![Build](https://github.com/hyperpolymath/asdf-grype-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-grype-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-grype-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-grype-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Grype](https://anchore.com/grype). - -Container vulnerability scanner. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add grype https://github.com/hyperpolymath/asdf-grype-plugin.git -``` - -grype: - -```bash -# Show all installable versions -asdf list-all grype - -# Install specific version -asdf install grype latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global grype latest - -# Now grype commands are available -grype --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list grype - -# Set local version for current directory -asdf local grype - -# Uninstall a version -asdf uninstall grype -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/grype/SECURITY.adoc b/asdf-plugin-collection/plugins/grype/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/grype/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/grype/SECURITY.md b/asdf-plugin-collection/plugins/grype/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/grype/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/haproxy/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/haproxy/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/haproxy/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/haproxy/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/haproxy/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/haproxy/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/haproxy/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/haproxy/CONTRIBUTING.adoc index d18532b5..cac873a9 100644 --- a/asdf-plugin-collection/plugins/haproxy/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/haproxy/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-haproxy-plugin.git cd +asdf-haproxy-plugin -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-haproxy-plugin-dev toolbox enter +asdf-haproxy-plugin-dev # Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-haproxy-plugin/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-haproxy-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-haproxy-plugin/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-haproxy-plugin/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-haproxy-plugin/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/haproxy/CONTRIBUTING.md b/asdf-plugin-collection/plugins/haproxy/CONTRIBUTING.md deleted file mode 100644 index 42989f74..00000000 --- a/asdf-plugin-collection/plugins/haproxy/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-haproxy-plugin.git -cd asdf-haproxy-plugin - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-haproxy-plugin-dev -toolbox enter asdf-haproxy-plugin-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-haproxy-plugin/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-haproxy-plugin/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-haproxy-plugin/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-haproxy-plugin/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-haproxy-plugin/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/haproxy/README.adoc b/asdf-plugin-collection/plugins/haproxy/README.adoc new file mode 100644 index 00000000..7d6612ef --- /dev/null +++ b/asdf-plugin-collection/plugins/haproxy/README.adoc @@ -0,0 +1,82 @@ +== asdf-haproxy + +https://github.com/hyperpolymath/asdf-haproxy-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-haproxy-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-haproxy-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-haproxy-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] + +https://asdf-vm.com[asdf] plugin for https://www.haproxy.org[HAProxy]. + +High-availability load balancer. + +=== Contents + +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] + +=== Dependencies + +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] + +=== Install + +Plugin: + +[source,bash] +---- +asdf plugin add haproxy https://github.com/hyperpolymath/asdf-haproxy-plugin.git +---- + +haproxy: + +[source,bash] +---- +# Show all installable versions +asdf list-all haproxy + +# Install specific version +asdf install haproxy latest + +# Set a version globally (in your ~/.tool-versions file) +asdf global haproxy latest + +# Now haproxy commands are available +haproxy --version +---- + +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. + +=== Usage + +[source,bash] +---- +# List installed versions +asdf list haproxy + +# Set local version for current directory +asdf local haproxy + +# Uninstall a version +asdf uninstall haproxy +---- + +=== Contributing + +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License + +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. + +''''' + +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/haproxy/README.md b/asdf-plugin-collection/plugins/haproxy/README.md deleted file mode 100644 index 3f311310..00000000 --- a/asdf-plugin-collection/plugins/haproxy/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-haproxy - -[![Build](https://github.com/hyperpolymath/asdf-haproxy-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-haproxy-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-haproxy-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-haproxy-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [HAProxy](https://www.haproxy.org). - -High-availability load balancer. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add haproxy https://github.com/hyperpolymath/asdf-haproxy-plugin.git -``` - -haproxy: - -```bash -# Show all installable versions -asdf list-all haproxy - -# Install specific version -asdf install haproxy latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global haproxy latest - -# Now haproxy commands are available -haproxy --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list haproxy - -# Set local version for current directory -asdf local haproxy - -# Uninstall a version -asdf uninstall haproxy -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/haproxy/SECURITY.adoc b/asdf-plugin-collection/plugins/haproxy/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/haproxy/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/haproxy/SECURITY.md b/asdf-plugin-collection/plugins/haproxy/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/haproxy/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/hashicorp/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/hashicorp/ABI-FFI-README.adoc new file mode 100644 index 00000000..31ce416d --- /dev/null +++ b/asdf-plugin-collection/plugins/hashicorp/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== HASHICORP ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/hashicorp.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libhashicorp.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +hashicorp/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── hashicorp.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── hashicorp.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/hashicorp.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "hashicorp.h" + +int main() { + void* handle = hashicorp_init(); + if (!handle) return 1; + + int result = hashicorp_process(handle, 42); + if (result != 0) { + const char* err = hashicorp_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + hashicorp_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lhashicorp -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import HASHICORP.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "hashicorp")] +extern "C" { + fn hashicorp_init() -> *mut std::ffi::c_void; + fn hashicorp_free(handle: *mut std::ffi::c_void); + fn hashicorp_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = hashicorp_init(); + assert!(!handle.is_null()); + + let result = hashicorp_process(handle, 42); + assert_eq!(result, 0); + + hashicorp_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libhashicorp = "libhashicorp" + +function init() + handle = ccall((:hashicorp_init, libhashicorp), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:hashicorp_process, libhashicorp), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:hashicorp_free, libhashicorp), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/hashicorp.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/hashicorp/ABI-FFI-README.md b/asdf-plugin-collection/plugins/hashicorp/ABI-FFI-README.md deleted file mode 100644 index 34629ce4..00000000 --- a/asdf-plugin-collection/plugins/hashicorp/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# HASHICORP ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/hashicorp.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libhashicorp.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -hashicorp/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── hashicorp.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── hashicorp.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/hashicorp.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "hashicorp.h" - -int main() { - void* handle = hashicorp_init(); - if (!handle) return 1; - - int result = hashicorp_process(handle, 42); - if (result != 0) { - const char* err = hashicorp_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - hashicorp_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lhashicorp -L./zig-out/lib -``` - -### From Idris2 - -```idris -import HASHICORP.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "hashicorp")] -extern "C" { - fn hashicorp_init() -> *mut std::ffi::c_void; - fn hashicorp_free(handle: *mut std::ffi::c_void); - fn hashicorp_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = hashicorp_init(); - assert!(!handle.is_null()); - - let result = hashicorp_process(handle, 42); - assert_eq!(result, 0); - - hashicorp_free(handle); - } -} -``` - -### From Julia - -```julia -const libhashicorp = "libhashicorp" - -function init() - handle = ccall((:hashicorp_init, libhashicorp), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:hashicorp_process, libhashicorp), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:hashicorp_free, libhashicorp), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/hashicorp.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/hashicorp/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/hashicorp/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/hashicorp/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/hashicorp/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/hashicorp/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/hashicorp/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/hashicorp/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/hashicorp/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/hashicorp/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/hashicorp/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/hashicorp/CONTRIBUTING.md b/asdf-plugin-collection/plugins/hashicorp/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/hashicorp/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/hashicorp/README.adoc b/asdf-plugin-collection/plugins/hashicorp/README.adoc index 47cca4cd..2b2871c6 100644 --- a/asdf-plugin-collection/plugins/hashicorp/README.adoc +++ b/asdf-plugin-collection/plugins/hashicorp/README.adoc @@ -1,60 +1,83 @@ -= asdf-hashicorp +== asdf-hashicorp -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] -:author: hyperpolymath -:url-asdf: https://asdf-vm.com -:url-repo: https://github.com/hyperpolymath/asdf-hashicorp-plugin +https://github.com/hyperpolymath/asdf-hashicorp-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-hashicorp-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-hashicorp-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-hashicorp-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -image:https://img.shields.io/github/license/hyperpolymath/asdf-hashicorp-plugin?style=flat-square[License,link=LICENSE] -image:https://img.shields.io/github/actions/workflow/status/hyperpolymath/asdf-hashicorp-plugin/ci.yml?branch=main&style=flat-square[Build Status,link={url-repo}/actions] +https://asdf-vm.com[asdf] plugin for https://www.hashicorp.com[HashiCorp +Tools]. -An {url-asdf}[asdf] plugin to manage all HashiCorp tools. +Terraform, Vault, Consul. -== Supported Tools +=== Contents -* **vault** - Secrets management -* **terraform** - Infrastructure as Code -* **consul** - Service mesh -* **nomad** - Workload orchestration -* **packer** - Image builder -* **vagrant** - Development environments -* **boundary** - Secure remote access -* **waypoint** - Application deployment -* **sentinel** - Policy as Code -* **consul-template** - Template rendering -* **envconsul** - Environment variables from Consul +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -== Installation +=== Dependencies -Add the plugin for each tool you need: +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] + +=== Install + +Plugin: [source,bash] ---- -# Add individual tools -asdf plugin add vault https://github.com/hyperpolymath/asdf-hashicorp-plugin.git -asdf plugin add terraform https://github.com/hyperpolymath/asdf-hashicorp-plugin.git -asdf plugin add consul https://github.com/hyperpolymath/asdf-hashicorp-plugin.git -asdf plugin add nomad https://github.com/hyperpolymath/asdf-hashicorp-plugin.git -asdf plugin add packer https://github.com/hyperpolymath/asdf-hashicorp-plugin.git +asdf plugin add hashicorp https://github.com/hyperpolymath/asdf-hashicorp-plugin.git ---- -== Usage +hashicorp: [source,bash] ---- -# List all available versions -asdf list all vault +# Show all installable versions +asdf list-all hashicorp + +# Install specific version +asdf install hashicorp latest + +# Set a version globally (in your ~/.tool-versions file) +asdf global hashicorp latest + +# Now hashicorp commands are available +hashicorp --version +---- + +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -# Install a specific version -asdf install vault 1.15.0 +=== Usage -# Install latest -asdf install terraform latest +[source,bash] +---- +# List installed versions +asdf list hashicorp -# Set global default -asdf global vault 1.15.0 +# Set local version for current directory +asdf local hashicorp + +# Uninstall a version +asdf uninstall hashicorp ---- -== License +=== Contributing + +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License + +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. + +''''' -SPDX-License-Identifier: CC-BY-SA-4.0 +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/hashicorp/README.md b/asdf-plugin-collection/plugins/hashicorp/README.md deleted file mode 100644 index 74f93203..00000000 --- a/asdf-plugin-collection/plugins/hashicorp/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-hashicorp - -[![Build](https://github.com/hyperpolymath/asdf-hashicorp-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-hashicorp-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-hashicorp-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-hashicorp-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [HashiCorp Tools](https://www.hashicorp.com). - -Terraform, Vault, Consul. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add hashicorp https://github.com/hyperpolymath/asdf-hashicorp-plugin.git -``` - -hashicorp: - -```bash -# Show all installable versions -asdf list-all hashicorp - -# Install specific version -asdf install hashicorp latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global hashicorp latest - -# Now hashicorp commands are available -hashicorp --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list hashicorp - -# Set local version for current directory -asdf local hashicorp - -# Uninstall a version -asdf uninstall hashicorp -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/hashicorp/SECURITY.adoc b/asdf-plugin-collection/plugins/hashicorp/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/hashicorp/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/hashicorp/SECURITY.md b/asdf-plugin-collection/plugins/hashicorp/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/hashicorp/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/httpd/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/httpd/ABI-FFI-README.adoc new file mode 100644 index 00000000..ed324584 --- /dev/null +++ b/asdf-plugin-collection/plugins/httpd/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== HTTPD ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/httpd.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libhttpd.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +httpd/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── httpd.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── httpd.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/httpd.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "httpd.h" + +int main() { + void* handle = httpd_init(); + if (!handle) return 1; + + int result = httpd_process(handle, 42); + if (result != 0) { + const char* err = httpd_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + httpd_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lhttpd -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import HTTPD.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "httpd")] +extern "C" { + fn httpd_init() -> *mut std::ffi::c_void; + fn httpd_free(handle: *mut std::ffi::c_void); + fn httpd_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = httpd_init(); + assert!(!handle.is_null()); + + let result = httpd_process(handle, 42); + assert_eq!(result, 0); + + httpd_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libhttpd = "libhttpd" + +function init() + handle = ccall((:httpd_init, libhttpd), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:httpd_process, libhttpd), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:httpd_free, libhttpd), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/httpd.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/httpd/ABI-FFI-README.md b/asdf-plugin-collection/plugins/httpd/ABI-FFI-README.md deleted file mode 100644 index 1201c275..00000000 --- a/asdf-plugin-collection/plugins/httpd/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# HTTPD ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/httpd.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libhttpd.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -httpd/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── httpd.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── httpd.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/httpd.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "httpd.h" - -int main() { - void* handle = httpd_init(); - if (!handle) return 1; - - int result = httpd_process(handle, 42); - if (result != 0) { - const char* err = httpd_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - httpd_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lhttpd -L./zig-out/lib -``` - -### From Idris2 - -```idris -import HTTPD.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "httpd")] -extern "C" { - fn httpd_init() -> *mut std::ffi::c_void; - fn httpd_free(handle: *mut std::ffi::c_void); - fn httpd_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = httpd_init(); - assert!(!handle.is_null()); - - let result = httpd_process(handle, 42); - assert_eq!(result, 0); - - httpd_free(handle); - } -} -``` - -### From Julia - -```julia -const libhttpd = "libhttpd" - -function init() - handle = ccall((:httpd_init, libhttpd), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:httpd_process, libhttpd), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:httpd_free, libhttpd), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/httpd.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/httpd/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/httpd/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/httpd/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/httpd/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/httpd/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/httpd/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/httpd/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/httpd/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/httpd/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/httpd/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/httpd/CONTRIBUTING.md b/asdf-plugin-collection/plugins/httpd/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/httpd/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/httpd/README.adoc b/asdf-plugin-collection/plugins/httpd/README.adoc index d08e1dd2..be6ffebb 100644 --- a/asdf-plugin-collection/plugins/httpd/README.adoc +++ b/asdf-plugin-collection/plugins/httpd/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-httpd -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-httpd-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-httpd-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-httpd-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-httpd-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://httpd.apache.org[Apache +HTTP Server]. -**All repos with foreign function interfaces MUST follow this standard:** +Web server. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add httpd https://github.com/hyperpolymath/asdf-httpd-plugin.git +---- -=== Web Projects +httpd: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all httpd -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install httpd latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global httpd latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now httpd commands are available +httpd --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list httpd -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local httpd -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall httpd ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/httpd/README.md b/asdf-plugin-collection/plugins/httpd/README.md deleted file mode 100644 index 4fb07dda..00000000 --- a/asdf-plugin-collection/plugins/httpd/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-httpd - -[![Build](https://github.com/hyperpolymath/asdf-httpd-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-httpd-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-httpd-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-httpd-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Apache HTTP Server](https://httpd.apache.org). - -Web server. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add httpd https://github.com/hyperpolymath/asdf-httpd-plugin.git -``` - -httpd: - -```bash -# Show all installable versions -asdf list-all httpd - -# Install specific version -asdf install httpd latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global httpd latest - -# Now httpd commands are available -httpd --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list httpd - -# Set local version for current directory -asdf local httpd - -# Uninstall a version -asdf uninstall httpd -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/httpd/SECURITY.adoc b/asdf-plugin-collection/plugins/httpd/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/httpd/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/httpd/SECURITY.md b/asdf-plugin-collection/plugins/httpd/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/httpd/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/influxdb/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/influxdb/ABI-FFI-README.adoc new file mode 100644 index 00000000..80f95c5c --- /dev/null +++ b/asdf-plugin-collection/plugins/influxdb/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== INFLUXDB ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/influxdb.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libinfluxdb.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +influxdb/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── influxdb.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── influxdb.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/influxdb.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "influxdb.h" + +int main() { + void* handle = influxdb_init(); + if (!handle) return 1; + + int result = influxdb_process(handle, 42); + if (result != 0) { + const char* err = influxdb_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + influxdb_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -linfluxdb -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import INFLUXDB.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "influxdb")] +extern "C" { + fn influxdb_init() -> *mut std::ffi::c_void; + fn influxdb_free(handle: *mut std::ffi::c_void); + fn influxdb_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = influxdb_init(); + assert!(!handle.is_null()); + + let result = influxdb_process(handle, 42); + assert_eq!(result, 0); + + influxdb_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libinfluxdb = "libinfluxdb" + +function init() + handle = ccall((:influxdb_init, libinfluxdb), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:influxdb_process, libinfluxdb), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:influxdb_free, libinfluxdb), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/influxdb.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/influxdb/ABI-FFI-README.md b/asdf-plugin-collection/plugins/influxdb/ABI-FFI-README.md deleted file mode 100644 index 776a116f..00000000 --- a/asdf-plugin-collection/plugins/influxdb/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# INFLUXDB ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/influxdb.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libinfluxdb.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -influxdb/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── influxdb.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── influxdb.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/influxdb.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "influxdb.h" - -int main() { - void* handle = influxdb_init(); - if (!handle) return 1; - - int result = influxdb_process(handle, 42); - if (result != 0) { - const char* err = influxdb_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - influxdb_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -linfluxdb -L./zig-out/lib -``` - -### From Idris2 - -```idris -import INFLUXDB.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "influxdb")] -extern "C" { - fn influxdb_init() -> *mut std::ffi::c_void; - fn influxdb_free(handle: *mut std::ffi::c_void); - fn influxdb_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = influxdb_init(); - assert!(!handle.is_null()); - - let result = influxdb_process(handle, 42); - assert_eq!(result, 0); - - influxdb_free(handle); - } -} -``` - -### From Julia - -```julia -const libinfluxdb = "libinfluxdb" - -function init() - handle = ccall((:influxdb_init, libinfluxdb), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:influxdb_process, libinfluxdb), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:influxdb_free, libinfluxdb), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/influxdb.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/influxdb/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/influxdb/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/influxdb/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/influxdb/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/influxdb/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/influxdb/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/influxdb/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/influxdb/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/influxdb/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/influxdb/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/influxdb/CONTRIBUTING.md b/asdf-plugin-collection/plugins/influxdb/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/influxdb/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/influxdb/README.adoc b/asdf-plugin-collection/plugins/influxdb/README.adoc index d08e1dd2..cb85c8e4 100644 --- a/asdf-plugin-collection/plugins/influxdb/README.adoc +++ b/asdf-plugin-collection/plugins/influxdb/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-influxdb -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-influxdb-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-influxdb-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-influxdb-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-influxdb-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://www.influxdata.com[InfluxDB]. -**All repos with foreign function interfaces MUST follow this standard:** +Time series database. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add influxdb https://github.com/hyperpolymath/asdf-influxdb-plugin.git +---- -=== Web Projects +influxdb: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all influxdb -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install influxdb latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global influxdb latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now influxdb commands are available +influxdb --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list influxdb -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local influxdb -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall influxdb ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/influxdb/README.md b/asdf-plugin-collection/plugins/influxdb/README.md deleted file mode 100644 index e85372e0..00000000 --- a/asdf-plugin-collection/plugins/influxdb/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-influxdb - -[![Build](https://github.com/hyperpolymath/asdf-influxdb-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-influxdb-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-influxdb-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-influxdb-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [InfluxDB](https://www.influxdata.com). - -Time series database. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add influxdb https://github.com/hyperpolymath/asdf-influxdb-plugin.git -``` - -influxdb: - -```bash -# Show all installable versions -asdf list-all influxdb - -# Install specific version -asdf install influxdb latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global influxdb latest - -# Now influxdb commands are available -influxdb --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list influxdb - -# Set local version for current directory -asdf local influxdb - -# Uninstall a version -asdf uninstall influxdb -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/influxdb/SECURITY.adoc b/asdf-plugin-collection/plugins/influxdb/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/influxdb/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/influxdb/SECURITY.md b/asdf-plugin-collection/plugins/influxdb/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/influxdb/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/kdl-fmt/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/kdl-fmt/ABI-FFI-README.adoc new file mode 100644 index 00000000..0ddb18a7 --- /dev/null +++ b/asdf-plugin-collection/plugins/kdl-fmt/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== KDL_FMT ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/kdl-fmt.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libkdl-fmt.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +kdl-fmt/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── kdl-fmt.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── kdl-fmt.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/kdl-fmt.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "kdl-fmt.h" + +int main() { + void* handle = kdl-fmt_init(); + if (!handle) return 1; + + int result = kdl-fmt_process(handle, 42); + if (result != 0) { + const char* err = kdl-fmt_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + kdl-fmt_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lkdl-fmt -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import KDL_FMT.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "kdl-fmt")] +extern "C" { + fn kdl-fmt_init() -> *mut std::ffi::c_void; + fn kdl-fmt_free(handle: *mut std::ffi::c_void); + fn kdl-fmt_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = kdl-fmt_init(); + assert!(!handle.is_null()); + + let result = kdl-fmt_process(handle, 42); + assert_eq!(result, 0); + + kdl-fmt_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libkdl-fmt = "libkdl-fmt" + +function init() + handle = ccall((:kdl-fmt_init, libkdl-fmt), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:kdl-fmt_process, libkdl-fmt), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:kdl-fmt_free, libkdl-fmt), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/kdl-fmt.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/kdl-fmt/ABI-FFI-README.md b/asdf-plugin-collection/plugins/kdl-fmt/ABI-FFI-README.md deleted file mode 100644 index ddfecda6..00000000 --- a/asdf-plugin-collection/plugins/kdl-fmt/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# KDL_FMT ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/kdl-fmt.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libkdl-fmt.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -kdl-fmt/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── kdl-fmt.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── kdl-fmt.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/kdl-fmt.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "kdl-fmt.h" - -int main() { - void* handle = kdl-fmt_init(); - if (!handle) return 1; - - int result = kdl-fmt_process(handle, 42); - if (result != 0) { - const char* err = kdl-fmt_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - kdl-fmt_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lkdl-fmt -L./zig-out/lib -``` - -### From Idris2 - -```idris -import KDL_FMT.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "kdl-fmt")] -extern "C" { - fn kdl-fmt_init() -> *mut std::ffi::c_void; - fn kdl-fmt_free(handle: *mut std::ffi::c_void); - fn kdl-fmt_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = kdl-fmt_init(); - assert!(!handle.is_null()); - - let result = kdl-fmt_process(handle, 42); - assert_eq!(result, 0); - - kdl-fmt_free(handle); - } -} -``` - -### From Julia - -```julia -const libkdl-fmt = "libkdl-fmt" - -function init() - handle = ccall((:kdl-fmt_init, libkdl-fmt), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:kdl-fmt_process, libkdl-fmt), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:kdl-fmt_free, libkdl-fmt), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/kdl-fmt.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/kdl-fmt/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/kdl-fmt/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/kdl-fmt/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/kdl-fmt/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/kdl-fmt/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/kdl-fmt/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/kdl-fmt/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/kdl-fmt/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/kdl-fmt/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/kdl-fmt/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/kdl-fmt/CONTRIBUTING.md b/asdf-plugin-collection/plugins/kdl-fmt/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/kdl-fmt/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/kdl-fmt/README.adoc b/asdf-plugin-collection/plugins/kdl-fmt/README.adoc index d08e1dd2..1bf9cbc8 100644 --- a/asdf-plugin-collection/plugins/kdl-fmt/README.adoc +++ b/asdf-plugin-collection/plugins/kdl-fmt/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-kdl-fmt -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-kdl-fmt-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-kdl-fmt-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-kdl-fmt-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-kdl-fmt-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://kdl.dev[kdl-fmt]. -**All repos with foreign function interfaces MUST follow this standard:** +KDL document formatter. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add kdl-fmt https://github.com/hyperpolymath/asdf-kdl-fmt-plugin.git +---- -=== Web Projects +kdl-fmt: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all kdl-fmt -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install kdl-fmt latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global kdl-fmt latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now kdl-fmt commands are available +kdl-fmt --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list kdl-fmt -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local kdl-fmt -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall kdl-fmt ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/kdl-fmt/README.md b/asdf-plugin-collection/plugins/kdl-fmt/README.md deleted file mode 100644 index 2e1285d5..00000000 --- a/asdf-plugin-collection/plugins/kdl-fmt/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-kdl-fmt - -[![Build](https://github.com/hyperpolymath/asdf-kdl-fmt-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-kdl-fmt-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-kdl-fmt-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-kdl-fmt-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [kdl-fmt](https://kdl.dev). - -KDL document formatter. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add kdl-fmt https://github.com/hyperpolymath/asdf-kdl-fmt-plugin.git -``` - -kdl-fmt: - -```bash -# Show all installable versions -asdf list-all kdl-fmt - -# Install specific version -asdf install kdl-fmt latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global kdl-fmt latest - -# Now kdl-fmt commands are available -kdl-fmt --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list kdl-fmt - -# Set local version for current directory -asdf local kdl-fmt - -# Uninstall a version -asdf uninstall kdl-fmt -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/kdl-fmt/SECURITY.adoc b/asdf-plugin-collection/plugins/kdl-fmt/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/kdl-fmt/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/kdl-fmt/SECURITY.md b/asdf-plugin-collection/plugins/kdl-fmt/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/kdl-fmt/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/lego/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/lego/ABI-FFI-README.adoc new file mode 100644 index 00000000..112425b2 --- /dev/null +++ b/asdf-plugin-collection/plugins/lego/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== LEGO ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/lego.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to liblego.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +lego/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── lego.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── lego.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/lego.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "lego.h" + +int main() { + void* handle = lego_init(); + if (!handle) return 1; + + int result = lego_process(handle, 42); + if (result != 0) { + const char* err = lego_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + lego_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -llego -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import LEGO.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "lego")] +extern "C" { + fn lego_init() -> *mut std::ffi::c_void; + fn lego_free(handle: *mut std::ffi::c_void); + fn lego_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = lego_init(); + assert!(!handle.is_null()); + + let result = lego_process(handle, 42); + assert_eq!(result, 0); + + lego_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const liblego = "liblego" + +function init() + handle = ccall((:lego_init, liblego), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:lego_process, liblego), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:lego_free, liblego), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/lego.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/lego/ABI-FFI-README.md b/asdf-plugin-collection/plugins/lego/ABI-FFI-README.md deleted file mode 100644 index 376d5f24..00000000 --- a/asdf-plugin-collection/plugins/lego/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# LEGO ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/lego.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to liblego.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -lego/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── lego.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── lego.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/lego.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "lego.h" - -int main() { - void* handle = lego_init(); - if (!handle) return 1; - - int result = lego_process(handle, 42); - if (result != 0) { - const char* err = lego_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - lego_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -llego -L./zig-out/lib -``` - -### From Idris2 - -```idris -import LEGO.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "lego")] -extern "C" { - fn lego_init() -> *mut std::ffi::c_void; - fn lego_free(handle: *mut std::ffi::c_void); - fn lego_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = lego_init(); - assert!(!handle.is_null()); - - let result = lego_process(handle, 42); - assert_eq!(result, 0); - - lego_free(handle); - } -} -``` - -### From Julia - -```julia -const liblego = "liblego" - -function init() - handle = ccall((:lego_init, liblego), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:lego_process, liblego), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:lego_free, liblego), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/lego.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/lego/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/lego/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/lego/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/lego/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/lego/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/lego/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/lego/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/lego/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/lego/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/lego/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/lego/CONTRIBUTING.md b/asdf-plugin-collection/plugins/lego/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/lego/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/lego/README.adoc b/asdf-plugin-collection/plugins/lego/README.adoc index d08e1dd2..d8e272b2 100644 --- a/asdf-plugin-collection/plugins/lego/README.adoc +++ b/asdf-plugin-collection/plugins/lego/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-lego -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-lego-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-lego-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-lego-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-lego-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://go-acme.github.io/lego[LEGO]. -**All repos with foreign function interfaces MUST follow this standard:** +ACME client. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add lego https://github.com/hyperpolymath/asdf-lego-plugin.git +---- -=== Web Projects +lego: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all lego -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install lego latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global lego latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now lego commands are available +lego --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list lego -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local lego -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall lego ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/lego/README.md b/asdf-plugin-collection/plugins/lego/README.md deleted file mode 100644 index d7ce2aac..00000000 --- a/asdf-plugin-collection/plugins/lego/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-lego - -[![Build](https://github.com/hyperpolymath/asdf-lego-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-lego-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-lego-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-lego-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [LEGO](https://go-acme.github.io/lego). - -ACME client. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add lego https://github.com/hyperpolymath/asdf-lego-plugin.git -``` - -lego: - -```bash -# Show all installable versions -asdf list-all lego - -# Install specific version -asdf install lego latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global lego latest - -# Now lego commands are available -lego --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list lego - -# Set local version for current directory -asdf local lego - -# Uninstall a version -asdf uninstall lego -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/lego/SECURITY.adoc b/asdf-plugin-collection/plugins/lego/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/lego/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/lego/SECURITY.md b/asdf-plugin-collection/plugins/lego/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/lego/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/linkerd/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/linkerd/ABI-FFI-README.adoc new file mode 100644 index 00000000..d504aefc --- /dev/null +++ b/asdf-plugin-collection/plugins/linkerd/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== LINKERD ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/linkerd.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to liblinkerd.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +linkerd/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── linkerd.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── linkerd.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/linkerd.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "linkerd.h" + +int main() { + void* handle = linkerd_init(); + if (!handle) return 1; + + int result = linkerd_process(handle, 42); + if (result != 0) { + const char* err = linkerd_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + linkerd_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -llinkerd -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import LINKERD.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "linkerd")] +extern "C" { + fn linkerd_init() -> *mut std::ffi::c_void; + fn linkerd_free(handle: *mut std::ffi::c_void); + fn linkerd_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = linkerd_init(); + assert!(!handle.is_null()); + + let result = linkerd_process(handle, 42); + assert_eq!(result, 0); + + linkerd_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const liblinkerd = "liblinkerd" + +function init() + handle = ccall((:linkerd_init, liblinkerd), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:linkerd_process, liblinkerd), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:linkerd_free, liblinkerd), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/linkerd.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/linkerd/ABI-FFI-README.md b/asdf-plugin-collection/plugins/linkerd/ABI-FFI-README.md deleted file mode 100644 index 5e32aabe..00000000 --- a/asdf-plugin-collection/plugins/linkerd/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# LINKERD ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/linkerd.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to liblinkerd.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -linkerd/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── linkerd.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── linkerd.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/linkerd.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "linkerd.h" - -int main() { - void* handle = linkerd_init(); - if (!handle) return 1; - - int result = linkerd_process(handle, 42); - if (result != 0) { - const char* err = linkerd_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - linkerd_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -llinkerd -L./zig-out/lib -``` - -### From Idris2 - -```idris -import LINKERD.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "linkerd")] -extern "C" { - fn linkerd_init() -> *mut std::ffi::c_void; - fn linkerd_free(handle: *mut std::ffi::c_void); - fn linkerd_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = linkerd_init(); - assert!(!handle.is_null()); - - let result = linkerd_process(handle, 42); - assert_eq!(result, 0); - - linkerd_free(handle); - } -} -``` - -### From Julia - -```julia -const liblinkerd = "liblinkerd" - -function init() - handle = ccall((:linkerd_init, liblinkerd), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:linkerd_process, liblinkerd), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:linkerd_free, liblinkerd), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/linkerd.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/linkerd/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/linkerd/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/linkerd/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/linkerd/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/linkerd/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/linkerd/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/linkerd/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/linkerd/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/linkerd/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/linkerd/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/linkerd/CONTRIBUTING.md b/asdf-plugin-collection/plugins/linkerd/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/linkerd/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/linkerd/README.adoc b/asdf-plugin-collection/plugins/linkerd/README.adoc index d08e1dd2..c4ba49db 100644 --- a/asdf-plugin-collection/plugins/linkerd/README.adoc +++ b/asdf-plugin-collection/plugins/linkerd/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-linkerd -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-linkerd-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-linkerd-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-linkerd-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-linkerd-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://linkerd.io[Linkerd CLI]. -**All repos with foreign function interfaces MUST follow this standard:** +Service mesh CLI. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add linkerd https://github.com/hyperpolymath/asdf-linkerd-plugin.git +---- -=== Web Projects +linkerd: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all linkerd -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install linkerd latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global linkerd latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now linkerd commands are available +linkerd --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list linkerd -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local linkerd -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall linkerd ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/linkerd/README.md b/asdf-plugin-collection/plugins/linkerd/README.md deleted file mode 100644 index d715ecc8..00000000 --- a/asdf-plugin-collection/plugins/linkerd/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-linkerd - -[![Build](https://github.com/hyperpolymath/asdf-linkerd-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-linkerd-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-linkerd-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-linkerd-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Linkerd CLI](https://linkerd.io). - -Service mesh CLI. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add linkerd https://github.com/hyperpolymath/asdf-linkerd-plugin.git -``` - -linkerd: - -```bash -# Show all installable versions -asdf list-all linkerd - -# Install specific version -asdf install linkerd latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global linkerd latest - -# Now linkerd commands are available -linkerd --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list linkerd - -# Set local version for current directory -asdf local linkerd - -# Uninstall a version -asdf uninstall linkerd -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/linkerd/SECURITY.adoc b/asdf-plugin-collection/plugins/linkerd/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/linkerd/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/linkerd/SECURITY.md b/asdf-plugin-collection/plugins/linkerd/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/linkerd/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/mariadb/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/mariadb/ABI-FFI-README.adoc new file mode 100644 index 00000000..9247cd3c --- /dev/null +++ b/asdf-plugin-collection/plugins/mariadb/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== MARIADB ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/mariadb.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libmariadb.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +mariadb/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── mariadb.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── mariadb.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/mariadb.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "mariadb.h" + +int main() { + void* handle = mariadb_init(); + if (!handle) return 1; + + int result = mariadb_process(handle, 42); + if (result != 0) { + const char* err = mariadb_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + mariadb_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lmariadb -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import MARIADB.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "mariadb")] +extern "C" { + fn mariadb_init() -> *mut std::ffi::c_void; + fn mariadb_free(handle: *mut std::ffi::c_void); + fn mariadb_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = mariadb_init(); + assert!(!handle.is_null()); + + let result = mariadb_process(handle, 42); + assert_eq!(result, 0); + + mariadb_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libmariadb = "libmariadb" + +function init() + handle = ccall((:mariadb_init, libmariadb), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:mariadb_process, libmariadb), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:mariadb_free, libmariadb), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/mariadb.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/mariadb/ABI-FFI-README.md b/asdf-plugin-collection/plugins/mariadb/ABI-FFI-README.md deleted file mode 100644 index 449dd815..00000000 --- a/asdf-plugin-collection/plugins/mariadb/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# MARIADB ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/mariadb.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libmariadb.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -mariadb/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── mariadb.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── mariadb.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/mariadb.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "mariadb.h" - -int main() { - void* handle = mariadb_init(); - if (!handle) return 1; - - int result = mariadb_process(handle, 42); - if (result != 0) { - const char* err = mariadb_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - mariadb_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lmariadb -L./zig-out/lib -``` - -### From Idris2 - -```idris -import MARIADB.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "mariadb")] -extern "C" { - fn mariadb_init() -> *mut std::ffi::c_void; - fn mariadb_free(handle: *mut std::ffi::c_void); - fn mariadb_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = mariadb_init(); - assert!(!handle.is_null()); - - let result = mariadb_process(handle, 42); - assert_eq!(result, 0); - - mariadb_free(handle); - } -} -``` - -### From Julia - -```julia -const libmariadb = "libmariadb" - -function init() - handle = ccall((:mariadb_init, libmariadb), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:mariadb_process, libmariadb), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:mariadb_free, libmariadb), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/mariadb.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/mariadb/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/mariadb/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/mariadb/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/mariadb/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/mariadb/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/mariadb/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/mariadb/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/mariadb/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/mariadb/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/mariadb/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/mariadb/CONTRIBUTING.md b/asdf-plugin-collection/plugins/mariadb/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/mariadb/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/mariadb/README.adoc b/asdf-plugin-collection/plugins/mariadb/README.adoc index d08e1dd2..3ab37418 100644 --- a/asdf-plugin-collection/plugins/mariadb/README.adoc +++ b/asdf-plugin-collection/plugins/mariadb/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-mariadb -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-mariadb-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-mariadb-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-mariadb-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-mariadb-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://mariadb.org[MariaDB]. -**All repos with foreign function interfaces MUST follow this standard:** +MySQL-compatible database. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add mariadb https://github.com/hyperpolymath/asdf-mariadb-plugin.git +---- -=== Web Projects +mariadb: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all mariadb -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install mariadb latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global mariadb latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now mariadb commands are available +mariadb --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list mariadb -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local mariadb -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall mariadb ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/mariadb/README.md b/asdf-plugin-collection/plugins/mariadb/README.md deleted file mode 100644 index 212ede30..00000000 --- a/asdf-plugin-collection/plugins/mariadb/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-mariadb - -[![Build](https://github.com/hyperpolymath/asdf-mariadb-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-mariadb-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-mariadb-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-mariadb-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [MariaDB](https://mariadb.org). - -MySQL-compatible database. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add mariadb https://github.com/hyperpolymath/asdf-mariadb-plugin.git -``` - -mariadb: - -```bash -# Show all installable versions -asdf list-all mariadb - -# Install specific version -asdf install mariadb latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global mariadb latest - -# Now mariadb commands are available -mariadb --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list mariadb - -# Set local version for current directory -asdf local mariadb - -# Uninstall a version -asdf uninstall mariadb -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/mariadb/SECURITY.adoc b/asdf-plugin-collection/plugins/mariadb/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/mariadb/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/mariadb/SECURITY.md b/asdf-plugin-collection/plugins/mariadb/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/mariadb/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/mdbook/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/mdbook/ABI-FFI-README.adoc new file mode 100644 index 00000000..1cc92c39 --- /dev/null +++ b/asdf-plugin-collection/plugins/mdbook/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== MDBOOK ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/mdbook.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libmdbook.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +mdbook/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── mdbook.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── mdbook.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/mdbook.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "mdbook.h" + +int main() { + void* handle = mdbook_init(); + if (!handle) return 1; + + int result = mdbook_process(handle, 42); + if (result != 0) { + const char* err = mdbook_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + mdbook_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lmdbook -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import MDBOOK.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "mdbook")] +extern "C" { + fn mdbook_init() -> *mut std::ffi::c_void; + fn mdbook_free(handle: *mut std::ffi::c_void); + fn mdbook_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = mdbook_init(); + assert!(!handle.is_null()); + + let result = mdbook_process(handle, 42); + assert_eq!(result, 0); + + mdbook_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libmdbook = "libmdbook" + +function init() + handle = ccall((:mdbook_init, libmdbook), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:mdbook_process, libmdbook), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:mdbook_free, libmdbook), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/mdbook.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/mdbook/ABI-FFI-README.md b/asdf-plugin-collection/plugins/mdbook/ABI-FFI-README.md deleted file mode 100644 index 0ec85b6b..00000000 --- a/asdf-plugin-collection/plugins/mdbook/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# MDBOOK ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/mdbook.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libmdbook.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -mdbook/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── mdbook.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── mdbook.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/mdbook.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "mdbook.h" - -int main() { - void* handle = mdbook_init(); - if (!handle) return 1; - - int result = mdbook_process(handle, 42); - if (result != 0) { - const char* err = mdbook_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - mdbook_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lmdbook -L./zig-out/lib -``` - -### From Idris2 - -```idris -import MDBOOK.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "mdbook")] -extern "C" { - fn mdbook_init() -> *mut std::ffi::c_void; - fn mdbook_free(handle: *mut std::ffi::c_void); - fn mdbook_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = mdbook_init(); - assert!(!handle.is_null()); - - let result = mdbook_process(handle, 42); - assert_eq!(result, 0); - - mdbook_free(handle); - } -} -``` - -### From Julia - -```julia -const libmdbook = "libmdbook" - -function init() - handle = ccall((:mdbook_init, libmdbook), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:mdbook_process, libmdbook), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:mdbook_free, libmdbook), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/mdbook.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/mdbook/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/mdbook/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/mdbook/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/mdbook/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/mdbook/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/mdbook/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/mdbook/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/mdbook/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/mdbook/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/mdbook/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/mdbook/CONTRIBUTING.md b/asdf-plugin-collection/plugins/mdbook/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/mdbook/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/mdbook/README.adoc b/asdf-plugin-collection/plugins/mdbook/README.adoc index d08e1dd2..ea6cde3e 100644 --- a/asdf-plugin-collection/plugins/mdbook/README.adoc +++ b/asdf-plugin-collection/plugins/mdbook/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-mdbook -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-mdbook-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-mdbook-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-mdbook-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-mdbook-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://rust-lang.github.io/mdBook[mdBook]. -**All repos with foreign function interfaces MUST follow this standard:** +Rust documentation tool. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add mdbook https://github.com/hyperpolymath/asdf-mdbook-plugin.git +---- -=== Web Projects +mdbook: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all mdbook -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install mdbook latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global mdbook latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now mdbook commands are available +mdbook --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list mdbook -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local mdbook -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall mdbook ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/mdbook/README.md b/asdf-plugin-collection/plugins/mdbook/README.md deleted file mode 100644 index d30c58bb..00000000 --- a/asdf-plugin-collection/plugins/mdbook/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-mdbook - -[![Build](https://github.com/hyperpolymath/asdf-mdbook-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-mdbook-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-mdbook-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-mdbook-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [mdBook](https://rust-lang.github.io/mdBook). - -Rust documentation tool. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add mdbook https://github.com/hyperpolymath/asdf-mdbook-plugin.git -``` - -mdbook: - -```bash -# Show all installable versions -asdf list-all mdbook - -# Install specific version -asdf install mdbook latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global mdbook latest - -# Now mdbook commands are available -mdbook --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list mdbook - -# Set local version for current directory -asdf local mdbook - -# Uninstall a version -asdf uninstall mdbook -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/mdbook/SECURITY.adoc b/asdf-plugin-collection/plugins/mdbook/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/mdbook/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/mdbook/SECURITY.md b/asdf-plugin-collection/plugins/mdbook/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/mdbook/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/melange/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/melange/ABI-FFI-README.adoc new file mode 100644 index 00000000..6d9dd689 --- /dev/null +++ b/asdf-plugin-collection/plugins/melange/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== MELANGE ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/melange.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libmelange.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +melange/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── melange.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── melange.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/melange.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "melange.h" + +int main() { + void* handle = melange_init(); + if (!handle) return 1; + + int result = melange_process(handle, 42); + if (result != 0) { + const char* err = melange_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + melange_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lmelange -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import MELANGE.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "melange")] +extern "C" { + fn melange_init() -> *mut std::ffi::c_void; + fn melange_free(handle: *mut std::ffi::c_void); + fn melange_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = melange_init(); + assert!(!handle.is_null()); + + let result = melange_process(handle, 42); + assert_eq!(result, 0); + + melange_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libmelange = "libmelange" + +function init() + handle = ccall((:melange_init, libmelange), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:melange_process, libmelange), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:melange_free, libmelange), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/melange.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/melange/ABI-FFI-README.md b/asdf-plugin-collection/plugins/melange/ABI-FFI-README.md deleted file mode 100644 index 6a925a4d..00000000 --- a/asdf-plugin-collection/plugins/melange/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# MELANGE ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/melange.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libmelange.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -melange/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── melange.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── melange.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/melange.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "melange.h" - -int main() { - void* handle = melange_init(); - if (!handle) return 1; - - int result = melange_process(handle, 42); - if (result != 0) { - const char* err = melange_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - melange_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lmelange -L./zig-out/lib -``` - -### From Idris2 - -```idris -import MELANGE.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "melange")] -extern "C" { - fn melange_init() -> *mut std::ffi::c_void; - fn melange_free(handle: *mut std::ffi::c_void); - fn melange_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = melange_init(); - assert!(!handle.is_null()); - - let result = melange_process(handle, 42); - assert_eq!(result, 0); - - melange_free(handle); - } -} -``` - -### From Julia - -```julia -const libmelange = "libmelange" - -function init() - handle = ccall((:melange_init, libmelange), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:melange_process, libmelange), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:melange_free, libmelange), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/melange.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/melange/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/melange/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/melange/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/melange/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/melange/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/melange/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/melange/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/melange/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/melange/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/melange/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/melange/CONTRIBUTING.md b/asdf-plugin-collection/plugins/melange/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/melange/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/melange/README.adoc b/asdf-plugin-collection/plugins/melange/README.adoc index d08e1dd2..f68195f2 100644 --- a/asdf-plugin-collection/plugins/melange/README.adoc +++ b/asdf-plugin-collection/plugins/melange/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-melange -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-melange-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-melange-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-melange-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-melange-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://github.com/chainguard-dev/melange[Melange]. -**All repos with foreign function interfaces MUST follow this standard:** +APK package builder. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add melange https://github.com/hyperpolymath/asdf-melange-plugin.git +---- -=== Web Projects +melange: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all melange -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install melange latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global melange latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now melange commands are available +melange --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list melange -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local melange -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall melange ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/melange/README.md b/asdf-plugin-collection/plugins/melange/README.md deleted file mode 100644 index 5f6cc5aa..00000000 --- a/asdf-plugin-collection/plugins/melange/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-melange - -[![Build](https://github.com/hyperpolymath/asdf-melange-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-melange-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-melange-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-melange-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Melange](https://github.com/chainguard-dev/melange). - -APK package builder. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add melange https://github.com/hyperpolymath/asdf-melange-plugin.git -``` - -melange: - -```bash -# Show all installable versions -asdf list-all melange - -# Install specific version -asdf install melange latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global melange latest - -# Now melange commands are available -melange --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list melange - -# Set local version for current directory -asdf local melange - -# Uninstall a version -asdf uninstall melange -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/melange/SECURITY.adoc b/asdf-plugin-collection/plugins/melange/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/melange/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/melange/SECURITY.md b/asdf-plugin-collection/plugins/melange/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/melange/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/metaiconic/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/metaiconic/ABI-FFI-README.adoc new file mode 100644 index 00000000..f3cd4789 --- /dev/null +++ b/asdf-plugin-collection/plugins/metaiconic/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== METAICONIC ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/metaiconic.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libmetaiconic.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +metaiconic/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── metaiconic.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── metaiconic.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/metaiconic.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "metaiconic.h" + +int main() { + void* handle = metaiconic_init(); + if (!handle) return 1; + + int result = metaiconic_process(handle, 42); + if (result != 0) { + const char* err = metaiconic_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + metaiconic_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lmetaiconic -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import METAICONIC.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "metaiconic")] +extern "C" { + fn metaiconic_init() -> *mut std::ffi::c_void; + fn metaiconic_free(handle: *mut std::ffi::c_void); + fn metaiconic_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = metaiconic_init(); + assert!(!handle.is_null()); + + let result = metaiconic_process(handle, 42); + assert_eq!(result, 0); + + metaiconic_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libmetaiconic = "libmetaiconic" + +function init() + handle = ccall((:metaiconic_init, libmetaiconic), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:metaiconic_process, libmetaiconic), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:metaiconic_free, libmetaiconic), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/metaiconic.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/metaiconic/ABI-FFI-README.md b/asdf-plugin-collection/plugins/metaiconic/ABI-FFI-README.md deleted file mode 100644 index 55307ef9..00000000 --- a/asdf-plugin-collection/plugins/metaiconic/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# METAICONIC ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/metaiconic.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libmetaiconic.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -metaiconic/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── metaiconic.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── metaiconic.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/metaiconic.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "metaiconic.h" - -int main() { - void* handle = metaiconic_init(); - if (!handle) return 1; - - int result = metaiconic_process(handle, 42); - if (result != 0) { - const char* err = metaiconic_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - metaiconic_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lmetaiconic -L./zig-out/lib -``` - -### From Idris2 - -```idris -import METAICONIC.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "metaiconic")] -extern "C" { - fn metaiconic_init() -> *mut std::ffi::c_void; - fn metaiconic_free(handle: *mut std::ffi::c_void); - fn metaiconic_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = metaiconic_init(); - assert!(!handle.is_null()); - - let result = metaiconic_process(handle, 42); - assert_eq!(result, 0); - - metaiconic_free(handle); - } -} -``` - -### From Julia - -```julia -const libmetaiconic = "libmetaiconic" - -function init() - handle = ccall((:metaiconic_init, libmetaiconic), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:metaiconic_process, libmetaiconic), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:metaiconic_free, libmetaiconic), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/metaiconic.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/metaiconic/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/metaiconic/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/metaiconic/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/metaiconic/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/metaiconic/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/metaiconic/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/metaiconic/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/metaiconic/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/metaiconic/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/metaiconic/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/metaiconic/CONTRIBUTING.md b/asdf-plugin-collection/plugins/metaiconic/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/metaiconic/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/metaiconic/README.adoc b/asdf-plugin-collection/plugins/metaiconic/README.adoc index b5c0dc4c..6edb4187 100644 --- a/asdf-plugin-collection/plugins/metaiconic/README.adoc +++ b/asdf-plugin-collection/plugins/metaiconic/README.adoc @@ -1,114 +1,52 @@ -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] -image:https://img.shields.io/badge/Philosophy-Palimpsest-indigo.svg[Palimpsest,link="https://github.com/hyperpolymath/palimpsest-license"] +== asdf-metaiconic-plugin +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] +image:https://img.shields.io/badge/Philosophy-Palimpsest-indigo.svg[Palimpsest,link="`https://github.com/hyperpolymath/palimpsest-license`"] -// SPDX-License-Identifier: CC-BY-SA-4.0 -= asdf-metaiconic-plugin +Central metadata registry and discovery layer for the +https://asdf-vm.com[asdf] plugin ecosystem. -:toc: macro -:toc-title: Contents -:toclevels: 3 -:icons: font +=== Overview -Unified metadata index and discovery layer for the hyperpolymath asdf plugin ecosystem. +`+asdf-metaiconic-plugin+` serves as the unified metadata index for 65+ +hyperpolymath asdf plugins: -toc::[] +* *Plugin discovery* - Search and browse available plugins +* *Category organization* - Tag-based classification +* *Icon/branding consistency* - SVG icons for all plugins +* *Quality metrics* - CI status aggregation -== Overview +=== Plugin Categories -**asdf-metaiconic-plugin** is the central metadata registry for 68+ asdf plugins in the hyperpolymath ecosystem. It provides: - -* Standardized plugin metadata schema -* Category and tag-based organization -* Plugin discovery and search -* Icon and branding consistency -* Quality metrics aggregation - -== Status - -[cols="1,3"] +[cols=",",options="header",] |=== -| Component | Status - -| Specification -| ✓ link:SPECIFICATION.adoc[Complete] - -| Registry Schema -| ✓ link:registry/plugins.yaml[Implemented] - -| Category Definitions -| ✓ link:registry/categories.yaml[Implemented] - -| Search CLI -| ⏳ Phase 2 - -| Icons -| ⏳ Phase 2 +|Category |Plugins +|Security |trivy, grype, syft, cosign, age, gitleaks, sops +|Databases |mysql, mariadb, cassandra, couchdb, neo4j, arangodb +|Configuration |nickel, dhall, cue, taplo, kdl-fmt +|Static Sites |zola, cobalt, mdbook, franklin, serum, pollen +|Containers |apko, melange, envoy, linkerd |=== -== Quick Start - -[source,bash] ----- -# Search for security plugins -asdf metaiconic search "vulnerability" - -# List all plugins by category -asdf metaiconic list --category security +=== Related Projects -# Get plugin info -asdf metaiconic info trivy ----- - -== Registry Structure - ----- -registry/ -├── plugins.yaml # Master plugin list (68+ entries) -├── categories.yaml # Category definitions (9 categories) -└── schemas/ # Validation schemas ----- - -== Categories - -[cols="1,2"] +[width="100%",cols="40%,60%",options="header",] |=== -| Category | Plugins +|Project |Relationship +|https://github.com/hyperpolymath/asdf-ui-plugin[asdf-ui-plugin] |Visual +consumer -| security | trivy, grype, syft, cosign, gitleaks, age, opa -| database | arangodb, mariadb, neo4j, cassandra, surrealdb -| config | nickel, dhall, cue, yq, taplo, bebop -| network | coredns, envoy, pomerium, linkerd -| crypto | step-ca, cfssl, lego, rekor, fulcio -| build | apko, melange, restic, borg, hashicorp -| language | ada, fortran, affinescript, ocaml, vlang -| ssg | casket-ssg, zola, cobalt, mdbook -| webserver | httpd, varnish, openlitespeed +|https://github.com/hyperpolymath/asdf-security-plugin[asdf-security-plugin] +|Security layer |=== -== Ecosystem Integration - -This plugin is consumed by: - -* **asdf-plugin-configurator** - CLI tool uses registry for search -* **asdf-ui-plugin** - Visual interface uses icons and metadata -* **asdf-control-tower** - Dashboard aggregates plugin status - -See link:ECOSYSTEM.scm[ECOSYSTEM.scm] for full integration map. - -== Infrastructure - -* Multi-forge mirroring (GitHub → GitLab, Codeberg, Bitbucket) -* Instant sync propagation on push/release -* AI assistant configuration (`.claude/CLAUDE.md`) - -== Links +=== License -* link:SPECIFICATION.adoc[Full Specification] -* link:registry/plugins.yaml[Plugin Registry] -* https://github.com/hyperpolymath/asdf-control-tower[Control Tower] -* https://github.com/hyperpolymath/asdf-plugin-configurator[Configurator CLI] +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -== License +''''' -MPL-2.0 +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/metaiconic/README.md b/asdf-plugin-collection/plugins/metaiconic/README.md deleted file mode 100644 index ed9cd4cd..00000000 --- a/asdf-plugin-collection/plugins/metaiconic/README.md +++ /dev/null @@ -1,40 +0,0 @@ -# asdf-metaiconic-plugin - -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] -image:https://img.shields.io/badge/Philosophy-Palimpsest-indigo.svg[Palimpsest,link="https://github.com/hyperpolymath/palimpsest-license"] - -Central metadata registry and discovery layer for the [asdf](https://asdf-vm.com) plugin ecosystem. - -## Overview - -`asdf-metaiconic-plugin` serves as the unified metadata index for 65+ hyperpolymath asdf plugins: - -- **Plugin discovery** - Search and browse available plugins -- **Category organization** - Tag-based classification -- **Icon/branding consistency** - SVG icons for all plugins -- **Quality metrics** - CI status aggregation - -## Plugin Categories - -| Category | Plugins | -|----------|---------| -| Security | trivy, grype, syft, cosign, age, gitleaks, sops | -| Databases | mysql, mariadb, cassandra, couchdb, neo4j, arangodb | -| Configuration | nickel, dhall, cue, taplo, kdl-fmt | -| Static Sites | zola, cobalt, mdbook, franklin, serum, pollen | -| Containers | apko, melange, envoy, linkerd | - -## Related Projects - -| Project | Relationship | -|---------|--------------| -| [asdf-ui-plugin](https://github.com/hyperpolymath/asdf-ui-plugin) | Visual consumer | -| [asdf-security-plugin](https://github.com/hyperpolymath/asdf-security-plugin) | Security layer | - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/metaiconic/SECURITY.adoc b/asdf-plugin-collection/plugins/metaiconic/SECURITY.adoc new file mode 100644 index 00000000..6833c545 --- /dev/null +++ b/asdf-plugin-collection/plugins/metaiconic/SECURITY.adoc @@ -0,0 +1,378 @@ +Security Policy + +We take security seriously. We appreciate your efforts to responsibly +disclose vulnerabilities and will make every effort to acknowledge your +contributions. Table of Contents + +.... +Reporting a Vulnerability +What to Include +Response Timeline +Disclosure Policy +Scope +Safe Harbour +Recognition +Security Updates +Security Best Practices +.... + +Reporting a Vulnerability Preferred Method: GitHub Security Advisories + +The preferred method for reporting security vulnerabilities is through +GitHub’s Security Advisory feature: + +.... +Navigate to Report a Vulnerability +Click "Report a vulnerability" +Complete the form with as much detail as possible +Submit — we'll receive a private notification +.... + +This method ensures: + +.... +End-to-end encryption of your report +Private discussion space for collaboration +Coordinated disclosure tooling +Automatic credit when the advisory is published +.... + +Alternative: Encrypted Email + +If you cannot use GitHub Security Advisories, you may email us directly: + +Email security@hyperpolymath.org PGP Key Download Public Key Fingerprint +See GPG key + +== Import our PGP key + +curl -sSL https://hyperpolymath.org/gpg/security.asc | gpg –import + +== Verify fingerprint + +gpg –fingerprint security@hyperpolymath.org + +== Encrypt your report + +gpg –armor –encrypt –recipient security@hyperpolymath.org report.txt + +.... +⚠️ Important: Do not report security vulnerabilities through public GitHub issues, pull requests, discussions, or social media. +.... + +What to Include + +A good vulnerability report helps us understand and reproduce the issue +quickly. Required Information + +.... +Description: Clear explanation of the vulnerability +Impact: What an attacker could achieve (confidentiality, integrity, availability) +Affected versions: Which versions/commits are affected +Reproduction steps: Detailed steps to reproduce the issue +.... + +Helpful Additional Information + +.... +Proof of concept: Code, scripts, or screenshots demonstrating the vulnerability +Attack scenario: Realistic attack scenario showing exploitability +CVSS score: Your assessment of severity (use CVSS 3.1 Calculator) +CWE ID: Common Weakness Enumeration identifier if known +Suggested fix: If you have ideas for remediation +References: Links to related vulnerabilities, research, or advisories +.... + +Example Report Structure + +=== Summary + +{empty}[One-sentence description of the vulnerability] + +=== Vulnerability Type + +{empty}[e.g., SQL Injection, XSS, SSRF, Path Traversal, etc.] + +=== Affected Component + +{empty}[File path, function name, API endpoint, etc.] + +=== Affected Versions + +{empty}[Version range or specific commits] + +=== Severity Assessment + +* CVSS 3.1 Score: [X.X] +* CVSS Vector: [CVSS:3.1/AV:X/AC:X/PR:X/UI:X/S:X/C:X/I:X/A:X] + +=== Description + +{empty}[Detailed technical description] + +=== Steps to Reproduce + +[arabic] +. [First step] +. [Second step] +. […] + +=== Proof of Concept + +{empty}[Code, curl commands, screenshots, etc.] + +=== Impact + +{empty}[What can an attacker achieve?] + +=== Suggested Remediation + +{empty}[Optional: your ideas for fixing] + +=== References + +{empty}[Links to related issues, CVEs, research] + +Response Timeline + +We commit to the following response times: Stage Timeframe Description +Initial Response 48 hours We acknowledge receipt and confirm we’re +investigating Triage 7 days We assess severity, confirm the +vulnerability, and estimate timeline Status Update Every 7 days Regular +updates on remediation progress Resolution 90 days Target for fix +development and release (complex issues may take longer) Disclosure 90 +days Public disclosure after fix is available (coordinated with you) + +.... +Note: These are targets, not guarantees. Complex vulnerabilities may require more time. We'll communicate openly about any delays. +.... + +Disclosure Policy + +We follow coordinated disclosure (also known as responsible disclosure): + +.... +You report the vulnerability privately +We acknowledge and begin investigation +We develop a fix and prepare a release +We coordinate disclosure timing with you +We publish security advisory and fix simultaneously +You may publish your research after disclosure +.... + +Our Commitments + +.... +We will not take legal action against researchers who follow this policy +We will work with you to understand and resolve the issue +We will credit you in the security advisory (unless you prefer anonymity) +We will notify you before public disclosure +We will publish advisories with sufficient detail for users to assess risk +.... + +Your Commitments + +.... +Report vulnerabilities promptly after discovery +Give us reasonable time to address the issue before disclosure +Do not access, modify, or delete data beyond what's necessary to demonstrate the vulnerability +Do not degrade service availability (no DoS testing on production) +Do not share vulnerability details with others until coordinated disclosure +.... + +Disclosure Timeline + +Day 0 You report vulnerability Day 1-2 We acknowledge receipt Day 7 We +confirm vulnerability and share initial assessment Day 7-90 We develop +and test fix Day 90 Coordinated public disclosure (earlier if fix is +ready; later by mutual agreement) + +If we cannot reach agreement on disclosure timing, we default to 90 days +from your initial report. Scope In Scope ✅ + +The following are within scope for security research: + +.... +This repository (hyperpolymath/terrapin-ssg) and all its code +Official releases and packages published from this repository +Documentation that could lead to security issues +Build and deployment configurations in this repository +Dependencies (report here, we'll coordinate with upstream) +.... + +Out of Scope ❌ + +The following are not in scope: + +.... +Third-party services we integrate with (report directly to them) +Social engineering attacks against maintainers +Physical security +Denial of service attacks against production infrastructure +Spam, phishing, or other non-technical attacks +Issues already reported or publicly known +Theoretical vulnerabilities without proof of concept +.... + +Qualifying Vulnerabilities + +We’re particularly interested in: + +.... +Remote code execution +SQL injection, command injection, code injection +Authentication/authorisation bypass +Cross-site scripting (XSS) and cross-site request forgery (CSRF) +Server-side request forgery (SSRF) +Path traversal / local file inclusion +Information disclosure (credentials, PII, secrets) +Cryptographic weaknesses +Deserialisation vulnerabilities +Memory safety issues (buffer overflows, use-after-free, etc.) +Supply chain vulnerabilities (dependency confusion, etc.) +Significant logic flaws +.... + +Non-Qualifying Issues + +The following generally do not qualify as security vulnerabilities: + +.... +Missing security headers on non-sensitive pages +Clickjacking on pages without sensitive actions +Self-XSS (requires victim to paste code) +Missing rate limiting (unless it enables a specific attack) +Username/email enumeration (unless high-risk context) +Missing cookie flags on non-sensitive cookies +Software version disclosure +Verbose error messages (unless exposing secrets) +Best practice deviations without demonstrable impact +.... + +Safe Harbour + +We support security research conducted in good faith. Our Promise + +If you conduct security research in accordance with this policy: + +.... +✅ We will not initiate legal action against you +✅ We will not report your activity to law enforcement +✅ We will work with you in good faith to resolve issues +✅ We consider your research authorised under the Computer Fraud and Abuse Act (CFAA), UK Computer Misuse Act, and similar laws +✅ We waive any potential claim against you for circumvention of security controls +.... + +Good Faith Requirements + +To qualify for safe harbour, you must: + +.... +Comply with this security policy +Report vulnerabilities promptly +Avoid privacy violations (do not access others' data) +Avoid service degradation (no destructive testing) +Not exploit vulnerabilities beyond proof-of-concept +Not use vulnerabilities for profit (beyond bug bounties where offered) + +⚠️ Important: This safe harbour does not extend to third-party systems. Always check their policies before testing. +.... + +Recognition + +We believe in recognising security researchers who help us improve. Hall +of Fame + +Researchers who report valid vulnerabilities will be acknowledged in our +Security Acknowledgments (unless they prefer anonymity). + +Recognition includes: + +.... +Your name (or chosen alias) +Link to your website/profile (optional) +Brief description of the vulnerability class +Date of report +.... + +What We Offer + +.... +✅ Public credit in security advisories +✅ Acknowledgment in release notes +✅ Entry in our Hall of Fame +✅ Reference/recommendation letter upon request (for significant findings) +.... + +What We Don’t Currently Offer + +.... +❌ Monetary bug bounties +❌ Hardware or swag +❌ Paid security research contracts + +Note: We're a community project with limited resources. Your contributions help everyone who uses this software. +.... + +Security Updates Receiving Updates + +To stay informed about security updates: + +.... +Watch this repository: Click "Watch" → "Custom" → Select "Security alerts" +GitHub Security Advisories: Published at Security Advisories +Release notes: Security fixes noted in CHANGELOG +.... + +Update Policy Severity Response Critical/High Patch release as soon as +fix is ready Medium Included in next scheduled release (or earlier) Low +Included in next scheduled release Supported Versions Version Supported +Notes main branch ✅ Yes Latest development Latest release ✅ Yes +Current stable Previous minor release ✅ Yes Security fixes backported +Older versions ❌ No Please upgrade Security Best Practices + +When using terrapin-ssg, we recommend: General + +.... +Keep dependencies up to date +Use the latest stable release +Subscribe to security notifications +Review configuration against security documentation +Follow principle of least privilege +.... + +For Contributors + +.... +Never commit secrets, credentials, or API keys +Use signed commits (git config commit.gpgsign true) +Review dependencies before adding them +Run security linters locally before pushing +Report any concerns about existing code +.... + +Additional Resources + +.... +Our PGP Public Key +Security Advisories +Changelog +Contributing Guidelines +CVE Database +CVSS Calculator +.... + +Contact Purpose Contact Security issues Report via GitHub or +security@hyperpolymath.org General questions GitHub Discussions Other +enquiries See README for contact information Policy Changes + +This security policy may be updated from time to time. Significant +changes will be: + +.... +Committed to this repository with a clear commit message +Noted in the changelog +Announced via GitHub Discussions (for major changes) +.... + +Thank you for helping keep terrapin-ssg and its users safe. diff --git a/asdf-plugin-collection/plugins/metaiconic/SECURITY.md b/asdf-plugin-collection/plugins/metaiconic/SECURITY.md deleted file mode 100644 index 5eb5e20d..00000000 --- a/asdf-plugin-collection/plugins/metaiconic/SECURITY.md +++ /dev/null @@ -1,328 +0,0 @@ -Security Policy - -We take security seriously. We appreciate your efforts to responsibly disclose vulnerabilities and will make every effort to acknowledge your contributions. -Table of Contents - - Reporting a Vulnerability - What to Include - Response Timeline - Disclosure Policy - Scope - Safe Harbour - Recognition - Security Updates - Security Best Practices - -Reporting a Vulnerability -Preferred Method: GitHub Security Advisories - -The preferred method for reporting security vulnerabilities is through GitHub's Security Advisory feature: - - Navigate to Report a Vulnerability - Click "Report a vulnerability" - Complete the form with as much detail as possible - Submit — we'll receive a private notification - -This method ensures: - - End-to-end encryption of your report - Private discussion space for collaboration - Coordinated disclosure tooling - Automatic credit when the advisory is published - -Alternative: Encrypted Email - -If you cannot use GitHub Security Advisories, you may email us directly: - -Email security@hyperpolymath.org -PGP Key Download Public Key -Fingerprint See GPG key - -# Import our PGP key -curl -sSL https://hyperpolymath.org/gpg/security.asc | gpg --import - -# Verify fingerprint -gpg --fingerprint security@hyperpolymath.org - -# Encrypt your report -gpg --armor --encrypt --recipient security@hyperpolymath.org report.txt - - ⚠️ Important: Do not report security vulnerabilities through public GitHub issues, pull requests, discussions, or social media. - -What to Include - -A good vulnerability report helps us understand and reproduce the issue quickly. -Required Information - - Description: Clear explanation of the vulnerability - Impact: What an attacker could achieve (confidentiality, integrity, availability) - Affected versions: Which versions/commits are affected - Reproduction steps: Detailed steps to reproduce the issue - -Helpful Additional Information - - Proof of concept: Code, scripts, or screenshots demonstrating the vulnerability - Attack scenario: Realistic attack scenario showing exploitability - CVSS score: Your assessment of severity (use CVSS 3.1 Calculator) - CWE ID: Common Weakness Enumeration identifier if known - Suggested fix: If you have ideas for remediation - References: Links to related vulnerabilities, research, or advisories - -Example Report Structure - -## Summary -[One-sentence description of the vulnerability] - -## Vulnerability Type -[e.g., SQL Injection, XSS, SSRF, Path Traversal, etc.] - -## Affected Component -[File path, function name, API endpoint, etc.] - -## Affected Versions -[Version range or specific commits] - -## Severity Assessment -- CVSS 3.1 Score: [X.X] -- CVSS Vector: [CVSS:3.1/AV:X/AC:X/PR:X/UI:X/S:X/C:X/I:X/A:X] - -## Description -[Detailed technical description] - -## Steps to Reproduce -1. [First step] -2. [Second step] -3. [...] - -## Proof of Concept -[Code, curl commands, screenshots, etc.] - -## Impact -[What can an attacker achieve?] - -## Suggested Remediation -[Optional: your ideas for fixing] - -## References -[Links to related issues, CVEs, research] - -Response Timeline - -We commit to the following response times: -Stage Timeframe Description -Initial Response 48 hours We acknowledge receipt and confirm we're investigating -Triage 7 days We assess severity, confirm the vulnerability, and estimate timeline -Status Update Every 7 days Regular updates on remediation progress -Resolution 90 days Target for fix development and release (complex issues may take longer) -Disclosure 90 days Public disclosure after fix is available (coordinated with you) - - Note: These are targets, not guarantees. Complex vulnerabilities may require more time. We'll communicate openly about any delays. - -Disclosure Policy - -We follow coordinated disclosure (also known as responsible disclosure): - - You report the vulnerability privately - We acknowledge and begin investigation - We develop a fix and prepare a release - We coordinate disclosure timing with you - We publish security advisory and fix simultaneously - You may publish your research after disclosure - -Our Commitments - - We will not take legal action against researchers who follow this policy - We will work with you to understand and resolve the issue - We will credit you in the security advisory (unless you prefer anonymity) - We will notify you before public disclosure - We will publish advisories with sufficient detail for users to assess risk - -Your Commitments - - Report vulnerabilities promptly after discovery - Give us reasonable time to address the issue before disclosure - Do not access, modify, or delete data beyond what's necessary to demonstrate the vulnerability - Do not degrade service availability (no DoS testing on production) - Do not share vulnerability details with others until coordinated disclosure - -Disclosure Timeline - -Day 0 You report vulnerability -Day 1-2 We acknowledge receipt -Day 7 We confirm vulnerability and share initial assessment -Day 7-90 We develop and test fix -Day 90 Coordinated public disclosure - (earlier if fix is ready; later by mutual agreement) - -If we cannot reach agreement on disclosure timing, we default to 90 days from your initial report. -Scope -In Scope ✅ - -The following are within scope for security research: - - This repository (hyperpolymath/terrapin-ssg) and all its code - Official releases and packages published from this repository - Documentation that could lead to security issues - Build and deployment configurations in this repository - Dependencies (report here, we'll coordinate with upstream) - -Out of Scope ❌ - -The following are not in scope: - - Third-party services we integrate with (report directly to them) - Social engineering attacks against maintainers - Physical security - Denial of service attacks against production infrastructure - Spam, phishing, or other non-technical attacks - Issues already reported or publicly known - Theoretical vulnerabilities without proof of concept - -Qualifying Vulnerabilities - -We're particularly interested in: - - Remote code execution - SQL injection, command injection, code injection - Authentication/authorisation bypass - Cross-site scripting (XSS) and cross-site request forgery (CSRF) - Server-side request forgery (SSRF) - Path traversal / local file inclusion - Information disclosure (credentials, PII, secrets) - Cryptographic weaknesses - Deserialisation vulnerabilities - Memory safety issues (buffer overflows, use-after-free, etc.) - Supply chain vulnerabilities (dependency confusion, etc.) - Significant logic flaws - -Non-Qualifying Issues - -The following generally do not qualify as security vulnerabilities: - - Missing security headers on non-sensitive pages - Clickjacking on pages without sensitive actions - Self-XSS (requires victim to paste code) - Missing rate limiting (unless it enables a specific attack) - Username/email enumeration (unless high-risk context) - Missing cookie flags on non-sensitive cookies - Software version disclosure - Verbose error messages (unless exposing secrets) - Best practice deviations without demonstrable impact - -Safe Harbour - -We support security research conducted in good faith. -Our Promise - -If you conduct security research in accordance with this policy: - - ✅ We will not initiate legal action against you - ✅ We will not report your activity to law enforcement - ✅ We will work with you in good faith to resolve issues - ✅ We consider your research authorised under the Computer Fraud and Abuse Act (CFAA), UK Computer Misuse Act, and similar laws - ✅ We waive any potential claim against you for circumvention of security controls - -Good Faith Requirements - -To qualify for safe harbour, you must: - - Comply with this security policy - Report vulnerabilities promptly - Avoid privacy violations (do not access others' data) - Avoid service degradation (no destructive testing) - Not exploit vulnerabilities beyond proof-of-concept - Not use vulnerabilities for profit (beyond bug bounties where offered) - - ⚠️ Important: This safe harbour does not extend to third-party systems. Always check their policies before testing. - -Recognition - -We believe in recognising security researchers who help us improve. -Hall of Fame - -Researchers who report valid vulnerabilities will be acknowledged in our Security Acknowledgments (unless they prefer anonymity). - -Recognition includes: - - Your name (or chosen alias) - Link to your website/profile (optional) - Brief description of the vulnerability class - Date of report - -What We Offer - - ✅ Public credit in security advisories - ✅ Acknowledgment in release notes - ✅ Entry in our Hall of Fame - ✅ Reference/recommendation letter upon request (for significant findings) - -What We Don't Currently Offer - - ❌ Monetary bug bounties - ❌ Hardware or swag - ❌ Paid security research contracts - - Note: We're a community project with limited resources. Your contributions help everyone who uses this software. - -Security Updates -Receiving Updates - -To stay informed about security updates: - - Watch this repository: Click "Watch" → "Custom" → Select "Security alerts" - GitHub Security Advisories: Published at Security Advisories - Release notes: Security fixes noted in CHANGELOG - -Update Policy -Severity Response -Critical/High Patch release as soon as fix is ready -Medium Included in next scheduled release (or earlier) -Low Included in next scheduled release -Supported Versions -Version Supported Notes -main branch ✅ Yes Latest development -Latest release ✅ Yes Current stable -Previous minor release ✅ Yes Security fixes backported -Older versions ❌ No Please upgrade -Security Best Practices - -When using terrapin-ssg, we recommend: -General - - Keep dependencies up to date - Use the latest stable release - Subscribe to security notifications - Review configuration against security documentation - Follow principle of least privilege - -For Contributors - - Never commit secrets, credentials, or API keys - Use signed commits (git config commit.gpgsign true) - Review dependencies before adding them - Run security linters locally before pushing - Report any concerns about existing code - -Additional Resources - - Our PGP Public Key - Security Advisories - Changelog - Contributing Guidelines - CVE Database - CVSS Calculator - -Contact -Purpose Contact -Security issues Report via GitHub or security@hyperpolymath.org -General questions GitHub Discussions -Other enquiries See README for contact information -Policy Changes - -This security policy may be updated from time to time. Significant changes will be: - - Committed to this repository with a clear commit message - Noted in the changelog - Announced via GitHub Discussions (for major changes) - -Thank you for helping keep terrapin-ssg and its users safe. diff --git a/asdf-plugin-collection/plugins/mysql/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/mysql/ABI-FFI-README.adoc new file mode 100644 index 00000000..3c44c4c3 --- /dev/null +++ b/asdf-plugin-collection/plugins/mysql/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== MYSQL ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/mysql.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libmysql.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +mysql/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── mysql.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── mysql.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/mysql.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "mysql.h" + +int main() { + void* handle = mysql_init(); + if (!handle) return 1; + + int result = mysql_process(handle, 42); + if (result != 0) { + const char* err = mysql_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + mysql_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lmysql -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import MYSQL.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "mysql")] +extern "C" { + fn mysql_init() -> *mut std::ffi::c_void; + fn mysql_free(handle: *mut std::ffi::c_void); + fn mysql_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = mysql_init(); + assert!(!handle.is_null()); + + let result = mysql_process(handle, 42); + assert_eq!(result, 0); + + mysql_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libmysql = "libmysql" + +function init() + handle = ccall((:mysql_init, libmysql), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:mysql_process, libmysql), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:mysql_free, libmysql), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/mysql.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/mysql/ABI-FFI-README.md b/asdf-plugin-collection/plugins/mysql/ABI-FFI-README.md deleted file mode 100644 index 6b5cae94..00000000 --- a/asdf-plugin-collection/plugins/mysql/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# MYSQL ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/mysql.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libmysql.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -mysql/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── mysql.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── mysql.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/mysql.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "mysql.h" - -int main() { - void* handle = mysql_init(); - if (!handle) return 1; - - int result = mysql_process(handle, 42); - if (result != 0) { - const char* err = mysql_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - mysql_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lmysql -L./zig-out/lib -``` - -### From Idris2 - -```idris -import MYSQL.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "mysql")] -extern "C" { - fn mysql_init() -> *mut std::ffi::c_void; - fn mysql_free(handle: *mut std::ffi::c_void); - fn mysql_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = mysql_init(); - assert!(!handle.is_null()); - - let result = mysql_process(handle, 42); - assert_eq!(result, 0); - - mysql_free(handle); - } -} -``` - -### From Julia - -```julia -const libmysql = "libmysql" - -function init() - handle = ccall((:mysql_init, libmysql), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:mysql_process, libmysql), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:mysql_free, libmysql), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/mysql.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/mysql/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/mysql/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/mysql/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/mysql/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/mysql/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/mysql/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/mysql/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/mysql/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/mysql/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/mysql/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/mysql/CONTRIBUTING.md b/asdf-plugin-collection/plugins/mysql/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/mysql/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/mysql/README.adoc b/asdf-plugin-collection/plugins/mysql/README.adoc index d08e1dd2..fada33ed 100644 --- a/asdf-plugin-collection/plugins/mysql/README.adoc +++ b/asdf-plugin-collection/plugins/mysql/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-mysql -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-mysql-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-mysql-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-mysql-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-mysql-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://www.mysql.com[MySQL]. -**All repos with foreign function interfaces MUST follow this standard:** +Relational database. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add mysql https://github.com/hyperpolymath/asdf-mysql-plugin.git +---- -=== Web Projects +mysql: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all mysql -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install mysql latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global mysql latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now mysql commands are available +mysql --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list mysql -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local mysql -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall mysql ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/mysql/README.md b/asdf-plugin-collection/plugins/mysql/README.md deleted file mode 100644 index b23513f5..00000000 --- a/asdf-plugin-collection/plugins/mysql/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-mysql - -[![Build](https://github.com/hyperpolymath/asdf-mysql-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-mysql-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-mysql-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-mysql-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [MySQL](https://www.mysql.com). - -Relational database. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add mysql https://github.com/hyperpolymath/asdf-mysql-plugin.git -``` - -mysql: - -```bash -# Show all installable versions -asdf list-all mysql - -# Install specific version -asdf install mysql latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global mysql latest - -# Now mysql commands are available -mysql --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list mysql - -# Set local version for current directory -asdf local mysql - -# Uninstall a version -asdf uninstall mysql -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/mysql/SECURITY.adoc b/asdf-plugin-collection/plugins/mysql/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/mysql/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/mysql/SECURITY.md b/asdf-plugin-collection/plugins/mysql/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/mysql/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/neo4j/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/neo4j/ABI-FFI-README.adoc new file mode 100644 index 00000000..0767166f --- /dev/null +++ b/asdf-plugin-collection/plugins/neo4j/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== NEO4J ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/neo4j.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libneo4j.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +neo4j/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── neo4j.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── neo4j.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/neo4j.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "neo4j.h" + +int main() { + void* handle = neo4j_init(); + if (!handle) return 1; + + int result = neo4j_process(handle, 42); + if (result != 0) { + const char* err = neo4j_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + neo4j_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lneo4j -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import NEO4J.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "neo4j")] +extern "C" { + fn neo4j_init() -> *mut std::ffi::c_void; + fn neo4j_free(handle: *mut std::ffi::c_void); + fn neo4j_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = neo4j_init(); + assert!(!handle.is_null()); + + let result = neo4j_process(handle, 42); + assert_eq!(result, 0); + + neo4j_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libneo4j = "libneo4j" + +function init() + handle = ccall((:neo4j_init, libneo4j), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:neo4j_process, libneo4j), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:neo4j_free, libneo4j), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/neo4j.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/neo4j/ABI-FFI-README.md b/asdf-plugin-collection/plugins/neo4j/ABI-FFI-README.md deleted file mode 100644 index c5d9ed77..00000000 --- a/asdf-plugin-collection/plugins/neo4j/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# NEO4J ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/neo4j.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libneo4j.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -neo4j/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── neo4j.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── neo4j.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/neo4j.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "neo4j.h" - -int main() { - void* handle = neo4j_init(); - if (!handle) return 1; - - int result = neo4j_process(handle, 42); - if (result != 0) { - const char* err = neo4j_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - neo4j_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lneo4j -L./zig-out/lib -``` - -### From Idris2 - -```idris -import NEO4J.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "neo4j")] -extern "C" { - fn neo4j_init() -> *mut std::ffi::c_void; - fn neo4j_free(handle: *mut std::ffi::c_void); - fn neo4j_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = neo4j_init(); - assert!(!handle.is_null()); - - let result = neo4j_process(handle, 42); - assert_eq!(result, 0); - - neo4j_free(handle); - } -} -``` - -### From Julia - -```julia -const libneo4j = "libneo4j" - -function init() - handle = ccall((:neo4j_init, libneo4j), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:neo4j_process, libneo4j), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:neo4j_free, libneo4j), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/neo4j.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/neo4j/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/neo4j/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/neo4j/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/neo4j/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/neo4j/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/neo4j/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/neo4j/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/neo4j/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/neo4j/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/neo4j/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/neo4j/CONTRIBUTING.md b/asdf-plugin-collection/plugins/neo4j/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/neo4j/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/neo4j/README.adoc b/asdf-plugin-collection/plugins/neo4j/README.adoc index d08e1dd2..4963e8ab 100644 --- a/asdf-plugin-collection/plugins/neo4j/README.adoc +++ b/asdf-plugin-collection/plugins/neo4j/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-neo4j -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-neo4j-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-neo4j-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-neo4j-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-neo4j-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://neo4j.com[Neo4j]. -**All repos with foreign function interfaces MUST follow this standard:** +Graph database. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add neo4j https://github.com/hyperpolymath/asdf-neo4j-plugin.git +---- -=== Web Projects +neo4j: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all neo4j -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install neo4j latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global neo4j latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now neo4j commands are available +neo4j --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list neo4j -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local neo4j -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall neo4j ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/neo4j/README.md b/asdf-plugin-collection/plugins/neo4j/README.md deleted file mode 100644 index e2d18f20..00000000 --- a/asdf-plugin-collection/plugins/neo4j/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-neo4j - -[![Build](https://github.com/hyperpolymath/asdf-neo4j-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-neo4j-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-neo4j-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-neo4j-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Neo4j](https://neo4j.com). - -Graph database. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add neo4j https://github.com/hyperpolymath/asdf-neo4j-plugin.git -``` - -neo4j: - -```bash -# Show all installable versions -asdf list-all neo4j - -# Install specific version -asdf install neo4j latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global neo4j latest - -# Now neo4j commands are available -neo4j --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list neo4j - -# Set local version for current directory -asdf local neo4j - -# Uninstall a version -asdf uninstall neo4j -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/neo4j/SECURITY.adoc b/asdf-plugin-collection/plugins/neo4j/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/neo4j/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/neo4j/SECURITY.md b/asdf-plugin-collection/plugins/neo4j/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/neo4j/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/nickel/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/nickel/ABI-FFI-README.adoc new file mode 100644 index 00000000..785d64d6 --- /dev/null +++ b/asdf-plugin-collection/plugins/nickel/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== NICKEL ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/nickel.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libnickel.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +nickel/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── nickel.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── nickel.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/nickel.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "nickel.h" + +int main() { + void* handle = nickel_init(); + if (!handle) return 1; + + int result = nickel_process(handle, 42); + if (result != 0) { + const char* err = nickel_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + nickel_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lnickel -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import NICKEL.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "nickel")] +extern "C" { + fn nickel_init() -> *mut std::ffi::c_void; + fn nickel_free(handle: *mut std::ffi::c_void); + fn nickel_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = nickel_init(); + assert!(!handle.is_null()); + + let result = nickel_process(handle, 42); + assert_eq!(result, 0); + + nickel_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libnickel = "libnickel" + +function init() + handle = ccall((:nickel_init, libnickel), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:nickel_process, libnickel), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:nickel_free, libnickel), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/nickel.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/nickel/ABI-FFI-README.md b/asdf-plugin-collection/plugins/nickel/ABI-FFI-README.md deleted file mode 100644 index 8b3ac653..00000000 --- a/asdf-plugin-collection/plugins/nickel/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# NICKEL ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/nickel.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libnickel.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -nickel/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── nickel.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── nickel.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/nickel.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "nickel.h" - -int main() { - void* handle = nickel_init(); - if (!handle) return 1; - - int result = nickel_process(handle, 42); - if (result != 0) { - const char* err = nickel_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - nickel_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lnickel -L./zig-out/lib -``` - -### From Idris2 - -```idris -import NICKEL.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "nickel")] -extern "C" { - fn nickel_init() -> *mut std::ffi::c_void; - fn nickel_free(handle: *mut std::ffi::c_void); - fn nickel_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = nickel_init(); - assert!(!handle.is_null()); - - let result = nickel_process(handle, 42); - assert_eq!(result, 0); - - nickel_free(handle); - } -} -``` - -### From Julia - -```julia -const libnickel = "libnickel" - -function init() - handle = ccall((:nickel_init, libnickel), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:nickel_process, libnickel), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:nickel_free, libnickel), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/nickel.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/nickel/CODE_OF_CONDUCT (1).adoc b/asdf-plugin-collection/plugins/nickel/CODE_OF_CONDUCT (1).adoc new file mode 100644 index 00000000..6cc4271e --- /dev/null +++ b/asdf-plugin-collection/plugins/nickel/CODE_OF_CONDUCT (1).adoc @@ -0,0 +1,339 @@ +== Code of Conduct + +=== Our Pledge + +We as members, contributors, and leaders pledge to make participation in +Asdf Tool Plugins a harassment-free experience for everyone, regardless +of age, body size, visible or invisible disability, ethnicity, sex +characteristics, gender identity and expression, level of experience, +education, socio-economic status, nationality, personal appearance, +race, caste, colour, religion, or sexual identity and orientation. + +We pledge to act and interact in ways that contribute to an open, +welcoming, diverse, inclusive, and healthy community. + +We recognise that a thriving open source community requires +*psychological safety* — an environment where people can contribute, ask +questions, make mistakes, and learn without fear of ridicule or +retaliation. + +''''' + +=== Our Standards + +==== Expected Behaviour + +The following behaviours contribute to a positive environment: + +*Communication* - Using welcoming and inclusive language - Being +respectful of differing viewpoints and experiences - Giving and +gracefully accepting constructive feedback - Assuming good intent while +addressing impact - Communicating clearly and patiently, especially with +newcomers + +*Collaboration* - Focusing on what is best for the community - Showing +empathy and kindness toward other community members - Being +collaborative rather than competitive - Mentoring and supporting less +experienced contributors - Celebrating others’ contributions and +successes + +*Professionalism* - Accepting responsibility and apologising to those +affected by our mistakes - Learning from the experience and avoiding +repetition - Respecting others’ time and attention - Staying on topic in +project spaces - Following project guidelines and conventions + +*Accessibility* - Using plain language and avoiding unnecessary jargon - +Providing alt text for images and transcripts for audio/video - Being +patient with those using assistive technologies - Accommodating +different communication styles and needs - Recognising that not everyone +communicates the same way + +==== Unacceptable Behaviour + +The following behaviours are considered harassment and are unacceptable: + +*Harassment* - The use of sexualised language or imagery, and sexual +attention or advances of any kind - Trolling, insulting or derogatory +comments, and personal or political attacks - Public or private +harassment - Deliberate intimidation, stalking, or following (online or +in-person) - Unwelcome physical contact or simulated physical contact +(e.g., emoji) - Sustained disruption of talks, events, or online +discussions + +*Discrimination* - Discriminatory jokes and language - Posting or +threatening to post others’ personally identifying information +("`doxing`") - Advocating for, or encouraging, any of the above +behaviour - Microaggressions — subtle, often unintentional, +discriminatory comments or actions + +*Professional Misconduct* - Publishing others’ private information +without explicit permission - Misrepresenting affiliation or +contributions - Plagiarism or claiming credit for others’ work - +Retaliating against anyone who reports a Code of Conduct violation - +Other conduct which could reasonably be considered inappropriate in a +professional setting + +==== Grey Areas + +Some situations require judgement. When uncertain: + +* *Intent vs Impact*: Good intentions do not excuse harmful impact. +Focus on making things right. +* *Power Dynamics*: Those with more power (maintainers, employers, +experienced contributors) must be especially mindful of their impact. +* *Cultural Differences*: What’s acceptable varies by culture. When in +doubt, err on the side of caution and ask. +* *Humour*: Jokes at others’ expense are rarely funny to everyone. Punch +up, not down. + +''''' + +=== Scope + +This Code of Conduct applies within all community spaces, including: + +*Online Spaces* - Repository discussions, issues, and pull/merge +requests - Project chat channels (Matrix, Discord, Slack, IRC) - Mailing +lists and forums - Social media when representing the project - Video +calls and virtual meetings + +*In-Person Spaces* - Conferences, meetups, and events - Workshops and +training sessions - Any gathering where you represent the project + +*Representation* This Code of Conduct also applies when an individual is +officially representing the community in public spaces. Examples +include: + +* Using an official project email address +* Posting via an official social media account +* Acting as an appointed representative at an event +* Speaking on behalf of the project + +''''' + +=== Enforcement + +==== Reporting + +If you experience or witness unacceptable behaviour, or have any other +concerns, please report it as soon as possible. + +*How to Report* + +[width="99%",cols="30%,33%,37%",options="header",] +|=== +|Method |Details |Best For +|*Email* |j.d.a.jewell@open.ac.uk |Detailed reports, sensitive matters + +|*Private Message* |Contact any maintainer directly |Quick questions, +minor issues + +|*Anonymous Form* |[Link to form if available] |When you need anonymity +|=== + +*What to Include* + +* Your contact information (unless anonymous) +* Names/usernames of those involved +* Description of what happened +* When and where it occurred +* Any witnesses +* Any supporting evidence (screenshots, links) +* How you would like us to respond (if you have a preference) + +*What Happens Next* + +[arabic] +. You will receive acknowledgment within *\{\{RESPONSE_TIME}}* +. The \{\{CONDUCT_TEAM}} will review the report +. We may ask for additional information +. We will determine appropriate action +. We will inform you of the outcome (respecting others’ privacy) + +==== Confidentiality + +All reports will be handled with discretion: + +* Reporter identity is protected by default +* Details are shared only with those who need to know +* We will ask before naming you in any communication +* Anonymous reports are accepted and investigated + +==== Conflicts of Interest + +If a \{\{CONDUCT_TEAM}} member is involved in an incident: + +* They will recuse themselves from the process +* Another maintainer or external party will handle the report +* We will disclose any potential conflicts + +''''' + +=== Enforcement Guidelines + +The \{\{CONDUCT_TEAM}} will follow these guidelines in determining +consequences: + +==== 1. Correction + +*Community Impact*: Use of inappropriate language or other behaviour +deemed unprofessional or unwelcome. + +*Consequence*: A private, written warning providing clarity around the +nature of the violation and an explanation of why the behaviour was +inappropriate. A public apology may be requested. + +*Duration*: Immediate + +==== 2. Warning + +*Community Impact*: A violation through a single incident or series of +actions. + +*Consequence*: A warning with consequences for continued behaviour. No +interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, for a specified period. This +includes avoiding interactions in community spaces as well as external +channels like social media. Violating these terms may lead to a +temporary or permanent ban. + +*Duration*: 1-4 weeks + +==== 3. Temporary Ban + +*Community Impact*: A serious violation of community standards, +including sustained inappropriate behaviour. + +*Consequence*: A temporary ban from any sort of interaction or public +communication with the community for a specified period. No public or +private interaction with the people involved, including unsolicited +interaction with those enforcing the Code of Conduct, is allowed during +this period. Violating these terms may lead to a permanent ban. + +*Duration*: 1-6 months + +==== 4. Permanent Ban + +*Community Impact*: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behaviour, harassment of an +individual, or aggression toward or disparagement of classes of +individuals. + +*Consequence*: A permanent ban from any sort of public interaction +within the community. + +*Duration*: Permanent (with appeal rights after 12 months) + +==== Enforcement Across Perimeters + +For contributors with elevated access (Perimeter 2 or 1): + +[cols=",",options="header",] +|=== +|Level |Additional Consequence +|Correction |Noted in contributor record +|Warning |Access privileges may be temporarily reduced +|Temporary Ban |Access reduced to Perimeter 3 for ban duration +|Permanent Ban |All access revoked +|=== + +''''' + +=== Appeals + +If you believe an enforcement decision was made in error: + +[arabic] +. *Wait 7 days* after the decision (cooling-off period) +. *Email* j.d.a.jewell@open.ac.uk with subject line "`Appeal: [Original +Report ID]`" +. *Explain* why you believe the decision should be reconsidered +. *Provide* any new information not previously available + +*Appeals Process* + +* Appeals are reviewed by a different \{\{CONDUCT_TEAM}} member than the +original +* You will receive a response within 14 days +* The appeals decision is final +* You may only appeal once per incident + +*Grounds for Appeal* + +* Procedural errors in the original investigation +* New evidence not previously available +* Disproportionate response to the violation +* Misunderstanding of facts + +''''' + +=== Supporting Those Who Report + +We are committed to supporting those who report violations: + +*We Will* - Believe and take all reports seriously - Respect your +privacy and confidentiality preferences - Keep you informed of progress +(if you wish) - Take steps to protect you from retaliation - Provide +resources if you need support + +*We Will Not* - Require you to confront the person directly - Dismiss +reports without investigation - Reveal your identity without consent - +Tolerate retaliation against reporters - Rush you to make decisions + +''''' + +=== Prevention + +Beyond enforcement, we actively work to prevent issues: + +*Onboarding* - All contributors are expected to read this Code of +Conduct - Perimeter 2 applicants must confirm they’ve read and +understood it - Maintainers receive additional training on enforcement + +*Culture* - We model the behaviour we expect - We intervene early when +we see potential issues - We thank people for positive contributions - +We create opportunities for diverse voices + +*Review* - This Code of Conduct is reviewed annually - Community +feedback is welcomed - Changes are communicated clearly + +''''' + +=== Acknowledgments + +This Code of Conduct is adapted from: + +* https://www.contributor-covenant.org/[Contributor Covenant], version +2.1 +* https://www.djangoproject.com/conduct/[Django Code of Conduct] +* https://www.rust-lang.org/policies/code-of-conduct[Rust Code of +Conduct] +* https://www.python.org/psf/conduct/[Python Community Code of Conduct] + +We thank these communities for their leadership in creating welcoming +spaces. + +''''' + +=== Questions? + +If you have questions about this Code of Conduct: + +* Open a +https://github.com/hyperpolymath/asdf-tool-plugins/discussions[Discussion] +(for general questions) +* Email j.d.a.jewell@open.ac.uk (for private questions) +* Contact any maintainer directly + +''''' + +=== Summary + +*Be kind. Be respectful. Be collaborative.* + +We’re all here because we care about this project. Let’s make it a place +where everyone can do their best work. + +''''' + +Last updated: 2026 · Based on Contributor Covenant 2.1 diff --git a/asdf-plugin-collection/plugins/nickel/CODE_OF_CONDUCT (1).md b/asdf-plugin-collection/plugins/nickel/CODE_OF_CONDUCT (1).md deleted file mode 100644 index d234420d..00000000 --- a/asdf-plugin-collection/plugins/nickel/CODE_OF_CONDUCT (1).md +++ /dev/null @@ -1,327 +0,0 @@ -# Code of Conduct - - - -## Our Pledge - -We as members, contributors, and leaders pledge to make participation in Asdf Tool Plugins a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, colour, religion, or sexual identity and orientation. - -We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. - -We recognise that a thriving open source community requires **psychological safety** — an environment where people can contribute, ask questions, make mistakes, and learn without fear of ridicule or retaliation. - ---- - -## Our Standards - -### Expected Behaviour - -The following behaviours contribute to a positive environment: - -**Communication** -- Using welcoming and inclusive language -- Being respectful of differing viewpoints and experiences -- Giving and gracefully accepting constructive feedback -- Assuming good intent while addressing impact -- Communicating clearly and patiently, especially with newcomers - -**Collaboration** -- Focusing on what is best for the community -- Showing empathy and kindness toward other community members -- Being collaborative rather than competitive -- Mentoring and supporting less experienced contributors -- Celebrating others' contributions and successes - -**Professionalism** -- Accepting responsibility and apologising to those affected by our mistakes -- Learning from the experience and avoiding repetition -- Respecting others' time and attention -- Staying on topic in project spaces -- Following project guidelines and conventions - -**Accessibility** -- Using plain language and avoiding unnecessary jargon -- Providing alt text for images and transcripts for audio/video -- Being patient with those using assistive technologies -- Accommodating different communication styles and needs -- Recognising that not everyone communicates the same way - -### Unacceptable Behaviour - -The following behaviours are considered harassment and are unacceptable: - -**Harassment** -- The use of sexualised language or imagery, and sexual attention or advances of any kind -- Trolling, insulting or derogatory comments, and personal or political attacks -- Public or private harassment -- Deliberate intimidation, stalking, or following (online or in-person) -- Unwelcome physical contact or simulated physical contact (e.g., emoji) -- Sustained disruption of talks, events, or online discussions - -**Discrimination** -- Discriminatory jokes and language -- Posting or threatening to post others' personally identifying information ("doxing") -- Advocating for, or encouraging, any of the above behaviour -- Microaggressions — subtle, often unintentional, discriminatory comments or actions - -**Professional Misconduct** -- Publishing others' private information without explicit permission -- Misrepresenting affiliation or contributions -- Plagiarism or claiming credit for others' work -- Retaliating against anyone who reports a Code of Conduct violation -- Other conduct which could reasonably be considered inappropriate in a professional setting - -### Grey Areas - -Some situations require judgement. When uncertain: - -- **Intent vs Impact**: Good intentions do not excuse harmful impact. Focus on making things right. -- **Power Dynamics**: Those with more power (maintainers, employers, experienced contributors) must be especially mindful of their impact. -- **Cultural Differences**: What's acceptable varies by culture. When in doubt, err on the side of caution and ask. -- **Humour**: Jokes at others' expense are rarely funny to everyone. Punch up, not down. - ---- - -## Scope - -This Code of Conduct applies within all community spaces, including: - -**Online Spaces** -- Repository discussions, issues, and pull/merge requests -- Project chat channels (Matrix, Discord, Slack, IRC) -- Mailing lists and forums -- Social media when representing the project -- Video calls and virtual meetings - -**In-Person Spaces** -- Conferences, meetups, and events -- Workshops and training sessions -- Any gathering where you represent the project - -**Representation** -This Code of Conduct also applies when an individual is officially representing the community in public spaces. Examples include: - -- Using an official project email address -- Posting via an official social media account -- Acting as an appointed representative at an event -- Speaking on behalf of the project - ---- - -## Enforcement - -### Reporting - -If you experience or witness unacceptable behaviour, or have any other concerns, please report it as soon as possible. - -**How to Report** - -| Method | Details | Best For | -|--------|---------|----------| -| **Email** | j.d.a.jewell@open.ac.uk | Detailed reports, sensitive matters | -| **Private Message** | Contact any maintainer directly | Quick questions, minor issues | -| **Anonymous Form** | [Link to form if available] | When you need anonymity | - -**What to Include** - -- Your contact information (unless anonymous) -- Names/usernames of those involved -- Description of what happened -- When and where it occurred -- Any witnesses -- Any supporting evidence (screenshots, links) -- How you would like us to respond (if you have a preference) - -**What Happens Next** - -1. You will receive acknowledgment within **{{RESPONSE_TIME}}** -2. The {{CONDUCT_TEAM}} will review the report -3. We may ask for additional information -4. We will determine appropriate action -5. We will inform you of the outcome (respecting others' privacy) - -### Confidentiality - -All reports will be handled with discretion: - -- Reporter identity is protected by default -- Details are shared only with those who need to know -- We will ask before naming you in any communication -- Anonymous reports are accepted and investigated - -### Conflicts of Interest - -If a {{CONDUCT_TEAM}} member is involved in an incident: - -- They will recuse themselves from the process -- Another maintainer or external party will handle the report -- We will disclose any potential conflicts - ---- - -## Enforcement Guidelines - -The {{CONDUCT_TEAM}} will follow these guidelines in determining consequences: - -### 1. Correction - -**Community Impact**: Use of inappropriate language or other behaviour deemed unprofessional or unwelcome. - -**Consequence**: A private, written warning providing clarity around the nature of the violation and an explanation of why the behaviour was inappropriate. A public apology may be requested. - -**Duration**: Immediate - -### 2. Warning - -**Community Impact**: A violation through a single incident or series of actions. - -**Consequence**: A warning with consequences for continued behaviour. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. - -**Duration**: 1-4 weeks - -### 3. Temporary Ban - -**Community Impact**: A serious violation of community standards, including sustained inappropriate behaviour. - -**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. - -**Duration**: 1-6 months - -### 4. Permanent Ban - -**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behaviour, harassment of an individual, or aggression toward or disparagement of classes of individuals. - -**Consequence**: A permanent ban from any sort of public interaction within the community. - -**Duration**: Permanent (with appeal rights after 12 months) - -### Enforcement Across Perimeters - -For contributors with elevated access (Perimeter 2 or 1): - -| Level | Additional Consequence | -|-------|----------------------| -| Correction | Noted in contributor record | -| Warning | Access privileges may be temporarily reduced | -| Temporary Ban | Access reduced to Perimeter 3 for ban duration | -| Permanent Ban | All access revoked | - ---- - -## Appeals - -If you believe an enforcement decision was made in error: - -1. **Wait 7 days** after the decision (cooling-off period) -2. **Email** j.d.a.jewell@open.ac.uk with subject line "Appeal: [Original Report ID]" -3. **Explain** why you believe the decision should be reconsidered -4. **Provide** any new information not previously available - -**Appeals Process** - -- Appeals are reviewed by a different {{CONDUCT_TEAM}} member than the original -- You will receive a response within 14 days -- The appeals decision is final -- You may only appeal once per incident - -**Grounds for Appeal** - -- Procedural errors in the original investigation -- New evidence not previously available -- Disproportionate response to the violation -- Misunderstanding of facts - ---- - -## Supporting Those Who Report - -We are committed to supporting those who report violations: - -**We Will** -- Believe and take all reports seriously -- Respect your privacy and confidentiality preferences -- Keep you informed of progress (if you wish) -- Take steps to protect you from retaliation -- Provide resources if you need support - -**We Will Not** -- Require you to confront the person directly -- Dismiss reports without investigation -- Reveal your identity without consent -- Tolerate retaliation against reporters -- Rush you to make decisions - ---- - -## Prevention - -Beyond enforcement, we actively work to prevent issues: - -**Onboarding** -- All contributors are expected to read this Code of Conduct -- Perimeter 2 applicants must confirm they've read and understood it -- Maintainers receive additional training on enforcement - -**Culture** -- We model the behaviour we expect -- We intervene early when we see potential issues -- We thank people for positive contributions -- We create opportunities for diverse voices - -**Review** -- This Code of Conduct is reviewed annually -- Community feedback is welcomed -- Changes are communicated clearly - ---- - -## Acknowledgments - -This Code of Conduct is adapted from: - -- [Contributor Covenant](https://www.contributor-covenant.org/), version 2.1 -- [Django Code of Conduct](https://www.djangoproject.com/conduct/) -- [Rust Code of Conduct](https://www.rust-lang.org/policies/code-of-conduct) -- [Python Community Code of Conduct](https://www.python.org/psf/conduct/) - -We thank these communities for their leadership in creating welcoming spaces. - ---- - -## Questions? - -If you have questions about this Code of Conduct: - -- Open a [Discussion](https://github.com/hyperpolymath/asdf-tool-plugins/discussions) (for general questions) -- Email j.d.a.jewell@open.ac.uk (for private questions) -- Contact any maintainer directly - ---- - -## Summary - -**Be kind. Be respectful. Be collaborative.** - -We're all here because we care about this project. Let's make it a place where everyone can do their best work. - ---- - -Last updated: 2026 · Based on Contributor Covenant 2.1 diff --git a/asdf-plugin-collection/plugins/nickel/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/nickel/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/nickel/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/nickel/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/nickel/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/nickel/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/nickel/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/nickel/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/nickel/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/nickel/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/nickel/CONTRIBUTING.md b/asdf-plugin-collection/plugins/nickel/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/nickel/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/nickel/README.adoc b/asdf-plugin-collection/plugins/nickel/README.adoc index d08e1dd2..5c4ae9ec 100644 --- a/asdf-plugin-collection/plugins/nickel/README.adoc +++ b/asdf-plugin-collection/plugins/nickel/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-nickel -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-nickel-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-nickel-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-nickel-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-nickel-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://nickel-lang.org[Nickel]. -**All repos with foreign function interfaces MUST follow this standard:** +Configuration language. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add nickel https://github.com/hyperpolymath/asdf-nickel-plugin.git +---- -=== Web Projects +nickel: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all nickel -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install nickel latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global nickel latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now nickel commands are available +nickel --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list nickel -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local nickel -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall nickel ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/nickel/README.md b/asdf-plugin-collection/plugins/nickel/README.md deleted file mode 100644 index e041b947..00000000 --- a/asdf-plugin-collection/plugins/nickel/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-nickel - -[![Build](https://github.com/hyperpolymath/asdf-nickel-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-nickel-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-nickel-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-nickel-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Nickel](https://nickel-lang.org). - -Configuration language. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add nickel https://github.com/hyperpolymath/asdf-nickel-plugin.git -``` - -nickel: - -```bash -# Show all installable versions -asdf list-all nickel - -# Install specific version -asdf install nickel latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global nickel latest - -# Now nickel commands are available -nickel --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list nickel - -# Set local version for current directory -asdf local nickel - -# Uninstall a version -asdf uninstall nickel -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/nickel/SECURITY (1).adoc b/asdf-plugin-collection/plugins/nickel/SECURITY (1).adoc new file mode 100644 index 00000000..a66ca685 --- /dev/null +++ b/asdf-plugin-collection/plugins/nickel/SECURITY (1).adoc @@ -0,0 +1,452 @@ +== Security Policy + +We take security seriously. We appreciate your efforts to responsibly +disclose vulnerabilities and will make every effort to acknowledge your +contributions. + +=== Table of Contents + +* link:#reporting-a-vulnerability[Reporting a Vulnerability] +* link:#what-to-include[What to Include] +* link:#response-timeline[Response Timeline] +* link:#disclosure-policy[Disclosure Policy] +* link:#scope[Scope] +* link:#safe-harbour[Safe Harbour] +* link:#recognition[Recognition] +* link:#security-updates[Security Updates] +* link:#security-best-practices[Security Best Practices] + +''''' + +=== Reporting a Vulnerability + +==== Preferred Method: GitHub Security Advisories + +The preferred method for reporting security vulnerabilities is through +GitHub’s Security Advisory feature: + +[arabic] +. Navigate to +https://github.com/hyperpolymath/asdf-tool-plugins/security/advisories/new[Report +a Vulnerability] +. Click *"`Report a vulnerability`"* +. Complete the form with as much detail as possible +. Submit — we’ll receive a private notification + +This method ensures: + +* End-to-end encryption of your report +* Private discussion space for collaboration +* Coordinated disclosure tooling +* Automatic credit when the advisory is published + +==== Alternative: Encrypted Email + +If you cannot use GitHub Security Advisories, you may email us directly: + +[cols=",",] +|=== +|*Email* |6759885+hyperpolymath@users.noreply.github.com +|*PGP Key* |link:%7B%7BPGP_KEY_URL%7D%7D[Download Public Key] +|*Fingerprint* |`+{{PGP_FINGERPRINT}}+` +|=== + +[source,bash] +---- +# Import our PGP key +curl -sSL {{PGP_KEY_URL}} | gpg --import + +# Verify fingerprint +gpg --fingerprint 6759885+hyperpolymath@users.noreply.github.com + +# Encrypt your report +gpg --armor --encrypt --recipient 6759885+hyperpolymath@users.noreply.github.com report.txt +---- + +____ +*⚠️ Important:* Do not report security vulnerabilities through public +GitHub issues, pull requests, discussions, or social media. +____ + +''''' + +=== What to Include + +A good vulnerability report helps us understand and reproduce the issue +quickly. + +==== Required Information + +* *Description*: Clear explanation of the vulnerability +* *Impact*: What an attacker could achieve (confidentiality, integrity, +availability) +* *Affected versions*: Which versions/commits are affected +* *Reproduction steps*: Detailed steps to reproduce the issue + +==== Helpful Additional Information + +* *Proof of concept*: Code, scripts, or screenshots demonstrating the +vulnerability +* *Attack scenario*: Realistic attack scenario showing exploitability +* *CVSS score*: Your assessment of severity (use +https://www.first.org/cvss/calculator/3.1[CVSS 3.1 Calculator]) +* *CWE ID*: Common Weakness Enumeration identifier if known +* *Suggested fix*: If you have ideas for remediation +* *References*: Links to related vulnerabilities, research, or +advisories + +==== Example Report Structure + +[source,markdown] +---- +## Summary +[One-sentence description of the vulnerability] + +## Vulnerability Type +[e.g., SQL Injection, XSS, SSRF, Path Traversal, etc.] + +## Affected Component +[File path, function name, API endpoint, etc.] + +## Affected Versions +[Version range or specific commits] + +## Severity Assessment +- CVSS 3.1 Score: [X.X] +- CVSS Vector: [CVSS:3.1/AV:X/AC:X/PR:X/UI:X/S:X/C:X/I:X/A:X] + +## Description +[Detailed technical description] + +## Steps to Reproduce +1. [First step] +2. [Second step] +3. [...] + +## Proof of Concept +[Code, curl commands, screenshots, etc.] + +## Impact +[What can an attacker achieve?] + +## Suggested Remediation +[Optional: your ideas for fixing] + +## References +[Links to related issues, CVEs, research] +---- + +''''' + +=== Response Timeline + +We commit to the following response times: + +[width="100%",cols="24%,35%,41%",options="header",] +|=== +|Stage |Timeframe |Description +|*Initial Response* |48 hours |We acknowledge receipt and confirm we’re +investigating + +|*Triage* |7 days |We assess severity, confirm the vulnerability, and +estimate timeline + +|*Status Update* |Every 7 days |Regular updates on remediation progress + +|*Resolution* |90 days |Target for fix development and release (complex +issues may take longer) + +|*Disclosure* |90 days |Public disclosure after fix is available +(coordinated with you) +|=== + +____ +*Note:* These are targets, not guarantees. Complex vulnerabilities may +require more time. We’ll communicate openly about any delays. +____ + +''''' + +=== Disclosure Policy + +We follow *coordinated disclosure* (also known as responsible +disclosure): + +[arabic] +. *You report* the vulnerability privately +. *We acknowledge* and begin investigation +. *We develop* a fix and prepare a release +. *We coordinate* disclosure timing with you +. *We publish* security advisory and fix simultaneously +. *You may publish* your research after disclosure + +==== Our Commitments + +* We will not take legal action against researchers who follow this +policy +* We will work with you to understand and resolve the issue +* We will credit you in the security advisory (unless you prefer +anonymity) +* We will notify you before public disclosure +* We will publish advisories with sufficient detail for users to assess +risk + +==== Your Commitments + +* Report vulnerabilities promptly after discovery +* Give us reasonable time to address the issue before disclosure +* Do not access, modify, or delete data beyond what’s necessary to +demonstrate the vulnerability +* Do not degrade service availability (no DoS testing on production) +* Do not share vulnerability details with others until coordinated +disclosure + +==== Disclosure Timeline + +.... +Day 0 You report vulnerability +Day 1-2 We acknowledge receipt +Day 7 We confirm vulnerability and share initial assessment +Day 7-90 We develop and test fix +Day 90 Coordinated public disclosure + (earlier if fix is ready; later by mutual agreement) +.... + +If we cannot reach agreement on disclosure timing, we default to 90 days +from your initial report. + +''''' + +=== Scope + +==== In Scope ✅ + +The following are within scope for security research: + +* This repository (`+hyperpolymath/asdf-tool-plugins+`) and all its code +* Official releases and packages published from this repository +* Documentation that could lead to security issues +* Build and deployment configurations in this repository +* Dependencies (report here, we’ll coordinate with upstream) + +==== Out of Scope ❌ + +The following are *not* in scope: + +* Third-party services we integrate with (report directly to them) +* Social engineering attacks against maintainers +* Physical security +* Denial of service attacks against production infrastructure +* Spam, phishing, or other non-technical attacks +* Issues already reported or publicly known +* Theoretical vulnerabilities without proof of concept + +==== Qualifying Vulnerabilities + +We’re particularly interested in: + +* Remote code execution +* SQL injection, command injection, code injection +* Authentication/authorisation bypass +* Cross-site scripting (XSS) and cross-site request forgery (CSRF) +* Server-side request forgery (SSRF) +* Path traversal / local file inclusion +* Information disclosure (credentials, PII, secrets) +* Cryptographic weaknesses +* Deserialisation vulnerabilities +* Memory safety issues (buffer overflows, use-after-free, etc.) +* Supply chain vulnerabilities (dependency confusion, etc.) +* Significant logic flaws + +==== Non-Qualifying Issues + +The following generally do not qualify as security vulnerabilities: + +* Missing security headers on non-sensitive pages +* Clickjacking on pages without sensitive actions +* Self-XSS (requires victim to paste code) +* Missing rate limiting (unless it enables a specific attack) +* Username/email enumeration (unless high-risk context) +* Missing cookie flags on non-sensitive cookies +* Software version disclosure +* Verbose error messages (unless exposing secrets) +* Best practice deviations without demonstrable impact + +''''' + +=== Safe Harbour + +We support security research conducted in good faith. + +==== Our Promise + +If you conduct security research in accordance with this policy: + +* ✅ We will not initiate legal action against you +* ✅ We will not report your activity to law enforcement +* ✅ We will work with you in good faith to resolve issues +* ✅ We consider your research authorised under the Computer Fraud and +Abuse Act (CFAA), UK Computer Misuse Act, and similar laws +* ✅ We waive any potential claim against you for circumvention of +security controls + +==== Good Faith Requirements + +To qualify for safe harbour, you must: + +* Comply with this security policy +* Report vulnerabilities promptly +* Avoid privacy violations (do not access others’ data) +* Avoid service degradation (no destructive testing) +* Not exploit vulnerabilities beyond proof-of-concept +* Not use vulnerabilities for profit (beyond bug bounties where offered) + +____ +*⚠️ Important:* This safe harbour does not extend to third-party +systems. Always check their policies before testing. +____ + +''''' + +=== Recognition + +We believe in recognising security researchers who help us improve. + +==== Hall of Fame + +Researchers who report valid vulnerabilities will be acknowledged in our +link:SECURITY-ACKNOWLEDGMENTS.md[Security Acknowledgments] (unless they +prefer anonymity). + +Recognition includes: + +* Your name (or chosen alias) +* Link to your website/profile (optional) +* Brief description of the vulnerability class +* Date of report + +==== What We Offer + +* ✅ Public credit in security advisories +* ✅ Acknowledgment in release notes +* ✅ Entry in our Hall of Fame +* ✅ Reference/recommendation letter upon request (for significant +findings) + +==== What We Don’t Currently Offer + +* ❌ Monetary bug bounties +* ❌ Hardware or swag +* ❌ Paid security research contracts + +____ +*Note:* We’re a community project with limited resources. Your +contributions help everyone who uses this software. +____ + +''''' + +=== Security Updates + +==== Receiving Updates + +To stay informed about security updates: + +* *Watch this repository*: Click "`Watch`" → "`Custom`" → Select +"`Security alerts`" +* *GitHub Security Advisories*: Published at +https://github.com/hyperpolymath/asdf-tool-plugins/security/advisories[Security +Advisories] +* *Release notes*: Security fixes noted in link:CHANGELOG.md[CHANGELOG] + +==== Update Policy + +[cols=",",options="header",] +|=== +|Severity |Response +|*Critical/High* |Patch release as soon as fix is ready +|*Medium* |Included in next scheduled release (or earlier) +|*Low* |Included in next scheduled release +|=== + +==== Supported Versions + +[cols=",,",options="header",] +|=== +|Version |Supported |Notes +|`+main+` branch |✅ Yes |Latest development +|Latest release |✅ Yes |Current stable +|Previous minor release |✅ Yes |Security fixes backported +|Older versions |❌ No |Please upgrade +|=== + +''''' + +=== Security Best Practices + +When using Asdf Tool Plugins, we recommend: + +==== General + +* Keep dependencies up to date +* Use the latest stable release +* Subscribe to security notifications +* Review configuration against security documentation +* Follow principle of least privilege + +==== For Contributors + +* Never commit secrets, credentials, or API keys +* Use signed commits (`+git config commit.gpgsign true+`) +* Review dependencies before adding them +* Run security linters locally before pushing +* Report any concerns about existing code + +''''' + +=== Additional Resources + +* link:%7B%7BPGP_KEY_URL%7D%7D[Our PGP Public Key] +* https://github.com/hyperpolymath/asdf-tool-plugins/security/advisories[Security +Advisories] +* link:CHANGELOG.md[Changelog] +* link:CONTRIBUTING.md[Contributing Guidelines] +* https://cve.mitre.org/[CVE Database] +* https://www.first.org/cvss/calculator/3.1[CVSS Calculator] + +''''' + +=== Contact + +[width="100%",cols="50%,50%",options="header",] +|=== +|Purpose |Contact +|*Security issues* +|https://github.com/hyperpolymath/asdf-tool-plugins/security/advisories/new[Report +via GitHub] or 6759885+hyperpolymath@users.noreply.github.com + +|*General questions* +|https://github.com/hyperpolymath/asdf-tool-plugins/discussions[GitHub +Discussions] + +|*Other enquiries* |See link:README.md[README] for contact information +|=== + +''''' + +=== Policy Changes + +This security policy may be updated from time to time. Significant +changes will be: + +* Committed to this repository with a clear commit message +* Noted in the changelog +* Announced via GitHub Discussions (for major changes) + +''''' + +_Thank you for helping keep Asdf Tool Plugins and its users safe._ 🛡️ + +''''' + +Last updated: 2026 · Policy version: 1.0.0 diff --git a/asdf-plugin-collection/plugins/nickel/SECURITY (1).md b/asdf-plugin-collection/plugins/nickel/SECURITY (1).md deleted file mode 100644 index f61f4ad7..00000000 --- a/asdf-plugin-collection/plugins/nickel/SECURITY (1).md +++ /dev/null @@ -1,406 +0,0 @@ -# Security Policy - - - -We take security seriously. We appreciate your efforts to responsibly disclose vulnerabilities and will make every effort to acknowledge your contributions. - -## Table of Contents - -- [Reporting a Vulnerability](#reporting-a-vulnerability) -- [What to Include](#what-to-include) -- [Response Timeline](#response-timeline) -- [Disclosure Policy](#disclosure-policy) -- [Scope](#scope) -- [Safe Harbour](#safe-harbour) -- [Recognition](#recognition) -- [Security Updates](#security-updates) -- [Security Best Practices](#security-best-practices) - ---- - -## Reporting a Vulnerability - -### Preferred Method: GitHub Security Advisories - -The preferred method for reporting security vulnerabilities is through GitHub's Security Advisory feature: - -1. Navigate to [Report a Vulnerability](https://github.com/hyperpolymath/asdf-tool-plugins/security/advisories/new) -2. Click **"Report a vulnerability"** -3. Complete the form with as much detail as possible -4. Submit — we'll receive a private notification - -This method ensures: - -- End-to-end encryption of your report -- Private discussion space for collaboration -- Coordinated disclosure tooling -- Automatic credit when the advisory is published - -### Alternative: Encrypted Email - -If you cannot use GitHub Security Advisories, you may email us directly: - -| | | -|---|---| -| **Email** | 6759885+hyperpolymath@users.noreply.github.com | -| **PGP Key** | [Download Public Key]({{PGP_KEY_URL}}) | -| **Fingerprint** | `{{PGP_FINGERPRINT}}` | - -```bash -# Import our PGP key -curl -sSL {{PGP_KEY_URL}} | gpg --import - -# Verify fingerprint -gpg --fingerprint 6759885+hyperpolymath@users.noreply.github.com - -# Encrypt your report -gpg --armor --encrypt --recipient 6759885+hyperpolymath@users.noreply.github.com report.txt -``` - -> **⚠️ Important:** Do not report security vulnerabilities through public GitHub issues, pull requests, discussions, or social media. - ---- - -## What to Include - -A good vulnerability report helps us understand and reproduce the issue quickly. - -### Required Information - -- **Description**: Clear explanation of the vulnerability -- **Impact**: What an attacker could achieve (confidentiality, integrity, availability) -- **Affected versions**: Which versions/commits are affected -- **Reproduction steps**: Detailed steps to reproduce the issue - -### Helpful Additional Information - -- **Proof of concept**: Code, scripts, or screenshots demonstrating the vulnerability -- **Attack scenario**: Realistic attack scenario showing exploitability -- **CVSS score**: Your assessment of severity (use [CVSS 3.1 Calculator](https://www.first.org/cvss/calculator/3.1)) -- **CWE ID**: Common Weakness Enumeration identifier if known -- **Suggested fix**: If you have ideas for remediation -- **References**: Links to related vulnerabilities, research, or advisories - -### Example Report Structure - -```markdown -## Summary -[One-sentence description of the vulnerability] - -## Vulnerability Type -[e.g., SQL Injection, XSS, SSRF, Path Traversal, etc.] - -## Affected Component -[File path, function name, API endpoint, etc.] - -## Affected Versions -[Version range or specific commits] - -## Severity Assessment -- CVSS 3.1 Score: [X.X] -- CVSS Vector: [CVSS:3.1/AV:X/AC:X/PR:X/UI:X/S:X/C:X/I:X/A:X] - -## Description -[Detailed technical description] - -## Steps to Reproduce -1. [First step] -2. [Second step] -3. [...] - -## Proof of Concept -[Code, curl commands, screenshots, etc.] - -## Impact -[What can an attacker achieve?] - -## Suggested Remediation -[Optional: your ideas for fixing] - -## References -[Links to related issues, CVEs, research] -``` - ---- - -## Response Timeline - -We commit to the following response times: - -| Stage | Timeframe | Description | -|-------|-----------|-------------| -| **Initial Response** | 48 hours | We acknowledge receipt and confirm we're investigating | -| **Triage** | 7 days | We assess severity, confirm the vulnerability, and estimate timeline | -| **Status Update** | Every 7 days | Regular updates on remediation progress | -| **Resolution** | 90 days | Target for fix development and release (complex issues may take longer) | -| **Disclosure** | 90 days | Public disclosure after fix is available (coordinated with you) | - -> **Note:** These are targets, not guarantees. Complex vulnerabilities may require more time. We'll communicate openly about any delays. - ---- - -## Disclosure Policy - -We follow **coordinated disclosure** (also known as responsible disclosure): - -1. **You report** the vulnerability privately -2. **We acknowledge** and begin investigation -3. **We develop** a fix and prepare a release -4. **We coordinate** disclosure timing with you -5. **We publish** security advisory and fix simultaneously -6. **You may publish** your research after disclosure - -### Our Commitments - -- We will not take legal action against researchers who follow this policy -- We will work with you to understand and resolve the issue -- We will credit you in the security advisory (unless you prefer anonymity) -- We will notify you before public disclosure -- We will publish advisories with sufficient detail for users to assess risk - -### Your Commitments - -- Report vulnerabilities promptly after discovery -- Give us reasonable time to address the issue before disclosure -- Do not access, modify, or delete data beyond what's necessary to demonstrate the vulnerability -- Do not degrade service availability (no DoS testing on production) -- Do not share vulnerability details with others until coordinated disclosure - -### Disclosure Timeline - -``` -Day 0 You report vulnerability -Day 1-2 We acknowledge receipt -Day 7 We confirm vulnerability and share initial assessment -Day 7-90 We develop and test fix -Day 90 Coordinated public disclosure - (earlier if fix is ready; later by mutual agreement) -``` - -If we cannot reach agreement on disclosure timing, we default to 90 days from your initial report. - ---- - -## Scope - -### In Scope ✅ - -The following are within scope for security research: - -- This repository (`hyperpolymath/asdf-tool-plugins`) and all its code -- Official releases and packages published from this repository -- Documentation that could lead to security issues -- Build and deployment configurations in this repository -- Dependencies (report here, we'll coordinate with upstream) - -### Out of Scope ❌ - -The following are **not** in scope: - -- Third-party services we integrate with (report directly to them) -- Social engineering attacks against maintainers -- Physical security -- Denial of service attacks against production infrastructure -- Spam, phishing, or other non-technical attacks -- Issues already reported or publicly known -- Theoretical vulnerabilities without proof of concept - -### Qualifying Vulnerabilities - -We're particularly interested in: - -- Remote code execution -- SQL injection, command injection, code injection -- Authentication/authorisation bypass -- Cross-site scripting (XSS) and cross-site request forgery (CSRF) -- Server-side request forgery (SSRF) -- Path traversal / local file inclusion -- Information disclosure (credentials, PII, secrets) -- Cryptographic weaknesses -- Deserialisation vulnerabilities -- Memory safety issues (buffer overflows, use-after-free, etc.) -- Supply chain vulnerabilities (dependency confusion, etc.) -- Significant logic flaws - -### Non-Qualifying Issues - -The following generally do not qualify as security vulnerabilities: - -- Missing security headers on non-sensitive pages -- Clickjacking on pages without sensitive actions -- Self-XSS (requires victim to paste code) -- Missing rate limiting (unless it enables a specific attack) -- Username/email enumeration (unless high-risk context) -- Missing cookie flags on non-sensitive cookies -- Software version disclosure -- Verbose error messages (unless exposing secrets) -- Best practice deviations without demonstrable impact - ---- - -## Safe Harbour - -We support security research conducted in good faith. - -### Our Promise - -If you conduct security research in accordance with this policy: - -- ✅ We will not initiate legal action against you -- ✅ We will not report your activity to law enforcement -- ✅ We will work with you in good faith to resolve issues -- ✅ We consider your research authorised under the Computer Fraud and Abuse Act (CFAA), UK Computer Misuse Act, and similar laws -- ✅ We waive any potential claim against you for circumvention of security controls - -### Good Faith Requirements - -To qualify for safe harbour, you must: - -- Comply with this security policy -- Report vulnerabilities promptly -- Avoid privacy violations (do not access others' data) -- Avoid service degradation (no destructive testing) -- Not exploit vulnerabilities beyond proof-of-concept -- Not use vulnerabilities for profit (beyond bug bounties where offered) - -> **⚠️ Important:** This safe harbour does not extend to third-party systems. Always check their policies before testing. - ---- - -## Recognition - -We believe in recognising security researchers who help us improve. - -### Hall of Fame - -Researchers who report valid vulnerabilities will be acknowledged in our [Security Acknowledgments](SECURITY-ACKNOWLEDGMENTS.md) (unless they prefer anonymity). - -Recognition includes: - -- Your name (or chosen alias) -- Link to your website/profile (optional) -- Brief description of the vulnerability class -- Date of report - -### What We Offer - -- ✅ Public credit in security advisories -- ✅ Acknowledgment in release notes -- ✅ Entry in our Hall of Fame -- ✅ Reference/recommendation letter upon request (for significant findings) - -### What We Don't Currently Offer - -- ❌ Monetary bug bounties -- ❌ Hardware or swag -- ❌ Paid security research contracts - -> **Note:** We're a community project with limited resources. Your contributions help everyone who uses this software. - ---- - -## Security Updates - -### Receiving Updates - -To stay informed about security updates: - -- **Watch this repository**: Click "Watch" → "Custom" → Select "Security alerts" -- **GitHub Security Advisories**: Published at [Security Advisories](https://github.com/hyperpolymath/asdf-tool-plugins/security/advisories) -- **Release notes**: Security fixes noted in [CHANGELOG](CHANGELOG.md) - -### Update Policy - -| Severity | Response | -|----------|----------| -| **Critical/High** | Patch release as soon as fix is ready | -| **Medium** | Included in next scheduled release (or earlier) | -| **Low** | Included in next scheduled release | - -### Supported Versions - - - -| Version | Supported | Notes | -|---------|-----------|-------| -| `main` branch | ✅ Yes | Latest development | -| Latest release | ✅ Yes | Current stable | -| Previous minor release | ✅ Yes | Security fixes backported | -| Older versions | ❌ No | Please upgrade | - ---- - -## Security Best Practices - -When using Asdf Tool Plugins, we recommend: - -### General - -- Keep dependencies up to date -- Use the latest stable release -- Subscribe to security notifications -- Review configuration against security documentation -- Follow principle of least privilege - -### For Contributors - -- Never commit secrets, credentials, or API keys -- Use signed commits (`git config commit.gpgsign true`) -- Review dependencies before adding them -- Run security linters locally before pushing -- Report any concerns about existing code - ---- - -## Additional Resources - -- [Our PGP Public Key]({{PGP_KEY_URL}}) -- [Security Advisories](https://github.com/hyperpolymath/asdf-tool-plugins/security/advisories) -- [Changelog](CHANGELOG.md) -- [Contributing Guidelines](CONTRIBUTING.md) -- [CVE Database](https://cve.mitre.org/) -- [CVSS Calculator](https://www.first.org/cvss/calculator/3.1) - ---- - -## Contact - -| Purpose | Contact | -|---------|---------| -| **Security issues** | [Report via GitHub](https://github.com/hyperpolymath/asdf-tool-plugins/security/advisories/new) or 6759885+hyperpolymath@users.noreply.github.com | -| **General questions** | [GitHub Discussions](https://github.com/hyperpolymath/asdf-tool-plugins/discussions) | -| **Other enquiries** | See [README](README.md) for contact information | - ---- - -## Policy Changes - -This security policy may be updated from time to time. Significant changes will be: - -- Committed to this repository with a clear commit message -- Noted in the changelog -- Announced via GitHub Discussions (for major changes) - ---- - -*Thank you for helping keep Asdf Tool Plugins and its users safe.* 🛡️ - ---- - -Last updated: 2026 · Policy version: 1.0.0 diff --git a/asdf-plugin-collection/plugins/nickel/SECURITY.adoc b/asdf-plugin-collection/plugins/nickel/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/nickel/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/nickel/SECURITY.md b/asdf-plugin-collection/plugins/nickel/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/nickel/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/ocaml/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/ocaml/ABI-FFI-README.adoc new file mode 100644 index 00000000..ab805e19 --- /dev/null +++ b/asdf-plugin-collection/plugins/ocaml/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== OCAML ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/ocaml.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libocaml.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +ocaml/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── ocaml.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── ocaml.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/ocaml.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "ocaml.h" + +int main() { + void* handle = ocaml_init(); + if (!handle) return 1; + + int result = ocaml_process(handle, 42); + if (result != 0) { + const char* err = ocaml_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + ocaml_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -locaml -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import OCAML.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "ocaml")] +extern "C" { + fn ocaml_init() -> *mut std::ffi::c_void; + fn ocaml_free(handle: *mut std::ffi::c_void); + fn ocaml_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = ocaml_init(); + assert!(!handle.is_null()); + + let result = ocaml_process(handle, 42); + assert_eq!(result, 0); + + ocaml_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libocaml = "libocaml" + +function init() + handle = ccall((:ocaml_init, libocaml), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:ocaml_process, libocaml), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:ocaml_free, libocaml), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/ocaml.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/ocaml/ABI-FFI-README.md b/asdf-plugin-collection/plugins/ocaml/ABI-FFI-README.md deleted file mode 100644 index 50d6c260..00000000 --- a/asdf-plugin-collection/plugins/ocaml/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# OCAML ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/ocaml.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libocaml.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -ocaml/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── ocaml.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── ocaml.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/ocaml.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "ocaml.h" - -int main() { - void* handle = ocaml_init(); - if (!handle) return 1; - - int result = ocaml_process(handle, 42); - if (result != 0) { - const char* err = ocaml_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - ocaml_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -locaml -L./zig-out/lib -``` - -### From Idris2 - -```idris -import OCAML.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "ocaml")] -extern "C" { - fn ocaml_init() -> *mut std::ffi::c_void; - fn ocaml_free(handle: *mut std::ffi::c_void); - fn ocaml_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = ocaml_init(); - assert!(!handle.is_null()); - - let result = ocaml_process(handle, 42); - assert_eq!(result, 0); - - ocaml_free(handle); - } -} -``` - -### From Julia - -```julia -const libocaml = "libocaml" - -function init() - handle = ccall((:ocaml_init, libocaml), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:ocaml_process, libocaml), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:ocaml_free, libocaml), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/ocaml.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/ocaml/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/ocaml/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/ocaml/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/ocaml/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/ocaml/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/ocaml/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/ocaml/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/ocaml/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/ocaml/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/ocaml/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/ocaml/CONTRIBUTING.md b/asdf-plugin-collection/plugins/ocaml/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/ocaml/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/ocaml/README.adoc b/asdf-plugin-collection/plugins/ocaml/README.adoc index d08e1dd2..434b0833 100644 --- a/asdf-plugin-collection/plugins/ocaml/README.adoc +++ b/asdf-plugin-collection/plugins/ocaml/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-ocaml -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-ocaml-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-ocaml-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-ocaml-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-ocaml-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://ocaml.org[OCaml]. -**All repos with foreign function interfaces MUST follow this standard:** +Functional programming language. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add ocaml https://github.com/hyperpolymath/asdf-ocaml-plugin.git +---- -=== Web Projects +ocaml: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all ocaml -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install ocaml latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global ocaml latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now ocaml commands are available +ocaml --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list ocaml -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local ocaml -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall ocaml ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/ocaml/README.md b/asdf-plugin-collection/plugins/ocaml/README.md deleted file mode 100644 index 5ad2c9bd..00000000 --- a/asdf-plugin-collection/plugins/ocaml/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-ocaml - -[![Build](https://github.com/hyperpolymath/asdf-ocaml-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-ocaml-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-ocaml-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-ocaml-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [OCaml](https://ocaml.org). - -Functional programming language. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add ocaml https://github.com/hyperpolymath/asdf-ocaml-plugin.git -``` - -ocaml: - -```bash -# Show all installable versions -asdf list-all ocaml - -# Install specific version -asdf install ocaml latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global ocaml latest - -# Now ocaml commands are available -ocaml --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list ocaml - -# Set local version for current directory -asdf local ocaml - -# Uninstall a version -asdf uninstall ocaml -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/ocaml/SECURITY.adoc b/asdf-plugin-collection/plugins/ocaml/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/ocaml/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/ocaml/SECURITY.md b/asdf-plugin-collection/plugins/ocaml/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/ocaml/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/opa/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/opa/ABI-FFI-README.adoc new file mode 100644 index 00000000..b78e8453 --- /dev/null +++ b/asdf-plugin-collection/plugins/opa/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== OPA ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/opa.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libopa.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +opa/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── opa.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── opa.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/opa.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "opa.h" + +int main() { + void* handle = opa_init(); + if (!handle) return 1; + + int result = opa_process(handle, 42); + if (result != 0) { + const char* err = opa_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + opa_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lopa -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import OPA.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "opa")] +extern "C" { + fn opa_init() -> *mut std::ffi::c_void; + fn opa_free(handle: *mut std::ffi::c_void); + fn opa_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = opa_init(); + assert!(!handle.is_null()); + + let result = opa_process(handle, 42); + assert_eq!(result, 0); + + opa_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libopa = "libopa" + +function init() + handle = ccall((:opa_init, libopa), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:opa_process, libopa), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:opa_free, libopa), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/opa.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/opa/ABI-FFI-README.md b/asdf-plugin-collection/plugins/opa/ABI-FFI-README.md deleted file mode 100644 index 0bafe4a2..00000000 --- a/asdf-plugin-collection/plugins/opa/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# OPA ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/opa.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libopa.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -opa/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── opa.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── opa.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/opa.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "opa.h" - -int main() { - void* handle = opa_init(); - if (!handle) return 1; - - int result = opa_process(handle, 42); - if (result != 0) { - const char* err = opa_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - opa_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lopa -L./zig-out/lib -``` - -### From Idris2 - -```idris -import OPA.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "opa")] -extern "C" { - fn opa_init() -> *mut std::ffi::c_void; - fn opa_free(handle: *mut std::ffi::c_void); - fn opa_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = opa_init(); - assert!(!handle.is_null()); - - let result = opa_process(handle, 42); - assert_eq!(result, 0); - - opa_free(handle); - } -} -``` - -### From Julia - -```julia -const libopa = "libopa" - -function init() - handle = ccall((:opa_init, libopa), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:opa_process, libopa), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:opa_free, libopa), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/opa.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/opa/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/opa/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/opa/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/opa/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/opa/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/opa/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/opa/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/opa/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/opa/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/opa/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/opa/CONTRIBUTING.md b/asdf-plugin-collection/plugins/opa/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/opa/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/opa/README.adoc b/asdf-plugin-collection/plugins/opa/README.adoc index d08e1dd2..1c1f19b4 100644 --- a/asdf-plugin-collection/plugins/opa/README.adoc +++ b/asdf-plugin-collection/plugins/opa/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-opa -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-opa-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-opa-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-opa-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-opa-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://www.openpolicyagent.org[Open Policy Agent]. -**All repos with foreign function interfaces MUST follow this standard:** +Policy engine. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add opa https://github.com/hyperpolymath/asdf-opa-plugin.git +---- -=== Web Projects +opa: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all opa -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install opa latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global opa latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now opa commands are available +opa --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list opa -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local opa -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall opa ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/opa/README.md b/asdf-plugin-collection/plugins/opa/README.md deleted file mode 100644 index de54dba8..00000000 --- a/asdf-plugin-collection/plugins/opa/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-opa - -[![Build](https://github.com/hyperpolymath/asdf-opa-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-opa-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-opa-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-opa-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Open Policy Agent](https://www.openpolicyagent.org). - -Policy engine. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add opa https://github.com/hyperpolymath/asdf-opa-plugin.git -``` - -opa: - -```bash -# Show all installable versions -asdf list-all opa - -# Install specific version -asdf install opa latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global opa latest - -# Now opa commands are available -opa --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list opa - -# Set local version for current directory -asdf local opa - -# Uninstall a version -asdf uninstall opa -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/opa/SECURITY.adoc b/asdf-plugin-collection/plugins/opa/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/opa/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/opa/SECURITY.md b/asdf-plugin-collection/plugins/opa/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/opa/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/openlitespeed/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/openlitespeed/ABI-FFI-README.adoc new file mode 100644 index 00000000..43898c94 --- /dev/null +++ b/asdf-plugin-collection/plugins/openlitespeed/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== OPENLITESPEED ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/openlitespeed.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libopenlitespeed.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +openlitespeed/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── openlitespeed.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── openlitespeed.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/openlitespeed.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "openlitespeed.h" + +int main() { + void* handle = openlitespeed_init(); + if (!handle) return 1; + + int result = openlitespeed_process(handle, 42); + if (result != 0) { + const char* err = openlitespeed_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + openlitespeed_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lopenlitespeed -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import OPENLITESPEED.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "openlitespeed")] +extern "C" { + fn openlitespeed_init() -> *mut std::ffi::c_void; + fn openlitespeed_free(handle: *mut std::ffi::c_void); + fn openlitespeed_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = openlitespeed_init(); + assert!(!handle.is_null()); + + let result = openlitespeed_process(handle, 42); + assert_eq!(result, 0); + + openlitespeed_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libopenlitespeed = "libopenlitespeed" + +function init() + handle = ccall((:openlitespeed_init, libopenlitespeed), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:openlitespeed_process, libopenlitespeed), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:openlitespeed_free, libopenlitespeed), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/openlitespeed.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/openlitespeed/ABI-FFI-README.md b/asdf-plugin-collection/plugins/openlitespeed/ABI-FFI-README.md deleted file mode 100644 index c3f2c832..00000000 --- a/asdf-plugin-collection/plugins/openlitespeed/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# OPENLITESPEED ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/openlitespeed.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libopenlitespeed.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -openlitespeed/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── openlitespeed.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── openlitespeed.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/openlitespeed.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "openlitespeed.h" - -int main() { - void* handle = openlitespeed_init(); - if (!handle) return 1; - - int result = openlitespeed_process(handle, 42); - if (result != 0) { - const char* err = openlitespeed_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - openlitespeed_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lopenlitespeed -L./zig-out/lib -``` - -### From Idris2 - -```idris -import OPENLITESPEED.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "openlitespeed")] -extern "C" { - fn openlitespeed_init() -> *mut std::ffi::c_void; - fn openlitespeed_free(handle: *mut std::ffi::c_void); - fn openlitespeed_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = openlitespeed_init(); - assert!(!handle.is_null()); - - let result = openlitespeed_process(handle, 42); - assert_eq!(result, 0); - - openlitespeed_free(handle); - } -} -``` - -### From Julia - -```julia -const libopenlitespeed = "libopenlitespeed" - -function init() - handle = ccall((:openlitespeed_init, libopenlitespeed), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:openlitespeed_process, libopenlitespeed), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:openlitespeed_free, libopenlitespeed), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/openlitespeed.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/openlitespeed/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/openlitespeed/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/openlitespeed/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/openlitespeed/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/openlitespeed/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/openlitespeed/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/openlitespeed/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/openlitespeed/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/openlitespeed/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/openlitespeed/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/openlitespeed/CONTRIBUTING.md b/asdf-plugin-collection/plugins/openlitespeed/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/openlitespeed/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/openlitespeed/README.adoc b/asdf-plugin-collection/plugins/openlitespeed/README.adoc index d08e1dd2..4ec2b20f 100644 --- a/asdf-plugin-collection/plugins/openlitespeed/README.adoc +++ b/asdf-plugin-collection/plugins/openlitespeed/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-openlitespeed -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-openlitespeed-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-openlitespeed-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-openlitespeed-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-openlitespeed-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://openlitespeed.org[OpenLiteSpeed]. -**All repos with foreign function interfaces MUST follow this standard:** +High-performance web server. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add openlitespeed https://github.com/hyperpolymath/asdf-openlitespeed-plugin.git +---- -=== Web Projects +openlitespeed: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all openlitespeed -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install openlitespeed latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global openlitespeed latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now openlitespeed commands are available +openlitespeed --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list openlitespeed -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local openlitespeed -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall openlitespeed ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/openlitespeed/README.md b/asdf-plugin-collection/plugins/openlitespeed/README.md deleted file mode 100644 index 967acbf5..00000000 --- a/asdf-plugin-collection/plugins/openlitespeed/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-openlitespeed - -[![Build](https://github.com/hyperpolymath/asdf-openlitespeed-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-openlitespeed-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-openlitespeed-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-openlitespeed-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [OpenLiteSpeed](https://openlitespeed.org). - -High-performance web server. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add openlitespeed https://github.com/hyperpolymath/asdf-openlitespeed-plugin.git -``` - -openlitespeed: - -```bash -# Show all installable versions -asdf list-all openlitespeed - -# Install specific version -asdf install openlitespeed latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global openlitespeed latest - -# Now openlitespeed commands are available -openlitespeed --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list openlitespeed - -# Set local version for current directory -asdf local openlitespeed - -# Uninstall a version -asdf uninstall openlitespeed -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/openlitespeed/SECURITY.adoc b/asdf-plugin-collection/plugins/openlitespeed/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/openlitespeed/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/openlitespeed/SECURITY.md b/asdf-plugin-collection/plugins/openlitespeed/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/openlitespeed/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/openssh/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/openssh/ABI-FFI-README.adoc new file mode 100644 index 00000000..36317683 --- /dev/null +++ b/asdf-plugin-collection/plugins/openssh/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== OPENSSH ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/openssh.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libopenssh.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +openssh/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── openssh.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── openssh.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/openssh.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "openssh.h" + +int main() { + void* handle = openssh_init(); + if (!handle) return 1; + + int result = openssh_process(handle, 42); + if (result != 0) { + const char* err = openssh_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + openssh_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lopenssh -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import OPENSSH.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "openssh")] +extern "C" { + fn openssh_init() -> *mut std::ffi::c_void; + fn openssh_free(handle: *mut std::ffi::c_void); + fn openssh_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = openssh_init(); + assert!(!handle.is_null()); + + let result = openssh_process(handle, 42); + assert_eq!(result, 0); + + openssh_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libopenssh = "libopenssh" + +function init() + handle = ccall((:openssh_init, libopenssh), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:openssh_process, libopenssh), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:openssh_free, libopenssh), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/openssh.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/openssh/ABI-FFI-README.md b/asdf-plugin-collection/plugins/openssh/ABI-FFI-README.md deleted file mode 100644 index e6a77f77..00000000 --- a/asdf-plugin-collection/plugins/openssh/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# OPENSSH ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/openssh.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libopenssh.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -openssh/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── openssh.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── openssh.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/openssh.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "openssh.h" - -int main() { - void* handle = openssh_init(); - if (!handle) return 1; - - int result = openssh_process(handle, 42); - if (result != 0) { - const char* err = openssh_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - openssh_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lopenssh -L./zig-out/lib -``` - -### From Idris2 - -```idris -import OPENSSH.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "openssh")] -extern "C" { - fn openssh_init() -> *mut std::ffi::c_void; - fn openssh_free(handle: *mut std::ffi::c_void); - fn openssh_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = openssh_init(); - assert!(!handle.is_null()); - - let result = openssh_process(handle, 42); - assert_eq!(result, 0); - - openssh_free(handle); - } -} -``` - -### From Julia - -```julia -const libopenssh = "libopenssh" - -function init() - handle = ccall((:openssh_init, libopenssh), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:openssh_process, libopenssh), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:openssh_free, libopenssh), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/openssh.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/openssh/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/openssh/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/openssh/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/openssh/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/openssh/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/openssh/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/openssh/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/openssh/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/openssh/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/openssh/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/openssh/CONTRIBUTING.md b/asdf-plugin-collection/plugins/openssh/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/openssh/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/openssh/README.adoc b/asdf-plugin-collection/plugins/openssh/README.adoc index d08e1dd2..6b5d8461 100644 --- a/asdf-plugin-collection/plugins/openssh/README.adoc +++ b/asdf-plugin-collection/plugins/openssh/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-openssh -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-openssh-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-openssh-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-openssh-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-openssh-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://www.openssh.com[OpenSSH]. -**All repos with foreign function interfaces MUST follow this standard:** +SSH connectivity tools. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add openssh https://github.com/hyperpolymath/asdf-openssh-plugin.git +---- -=== Web Projects +openssh: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all openssh -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install openssh latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global openssh latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now openssh commands are available +openssh --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list openssh -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local openssh -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall openssh ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/openssh/README.md b/asdf-plugin-collection/plugins/openssh/README.md deleted file mode 100644 index 0d151fcd..00000000 --- a/asdf-plugin-collection/plugins/openssh/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-openssh - -[![Build](https://github.com/hyperpolymath/asdf-openssh-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-openssh-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-openssh-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-openssh-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [OpenSSH](https://www.openssh.com). - -SSH connectivity tools. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add openssh https://github.com/hyperpolymath/asdf-openssh-plugin.git -``` - -openssh: - -```bash -# Show all installable versions -asdf list-all openssh - -# Install specific version -asdf install openssh latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global openssh latest - -# Now openssh commands are available -openssh --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list openssh - -# Set local version for current directory -asdf local openssh - -# Uninstall a version -asdf uninstall openssh -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/openssh/SECURITY.adoc b/asdf-plugin-collection/plugins/openssh/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/openssh/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/openssh/SECURITY.md b/asdf-plugin-collection/plugins/openssh/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/openssh/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/openssl/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/openssl/ABI-FFI-README.adoc new file mode 100644 index 00000000..279d3f42 --- /dev/null +++ b/asdf-plugin-collection/plugins/openssl/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== OPENSSL ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/openssl.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libopenssl.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +openssl/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── openssl.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── openssl.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/openssl.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "openssl.h" + +int main() { + void* handle = openssl_init(); + if (!handle) return 1; + + int result = openssl_process(handle, 42); + if (result != 0) { + const char* err = openssl_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + openssl_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lopenssl -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import OPENSSL.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "openssl")] +extern "C" { + fn openssl_init() -> *mut std::ffi::c_void; + fn openssl_free(handle: *mut std::ffi::c_void); + fn openssl_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = openssl_init(); + assert!(!handle.is_null()); + + let result = openssl_process(handle, 42); + assert_eq!(result, 0); + + openssl_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libopenssl = "libopenssl" + +function init() + handle = ccall((:openssl_init, libopenssl), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:openssl_process, libopenssl), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:openssl_free, libopenssl), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/openssl.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/openssl/ABI-FFI-README.md b/asdf-plugin-collection/plugins/openssl/ABI-FFI-README.md deleted file mode 100644 index a541fd49..00000000 --- a/asdf-plugin-collection/plugins/openssl/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# OPENSSL ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/openssl.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libopenssl.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -openssl/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── openssl.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── openssl.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/openssl.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "openssl.h" - -int main() { - void* handle = openssl_init(); - if (!handle) return 1; - - int result = openssl_process(handle, 42); - if (result != 0) { - const char* err = openssl_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - openssl_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lopenssl -L./zig-out/lib -``` - -### From Idris2 - -```idris -import OPENSSL.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "openssl")] -extern "C" { - fn openssl_init() -> *mut std::ffi::c_void; - fn openssl_free(handle: *mut std::ffi::c_void); - fn openssl_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = openssl_init(); - assert!(!handle.is_null()); - - let result = openssl_process(handle, 42); - assert_eq!(result, 0); - - openssl_free(handle); - } -} -``` - -### From Julia - -```julia -const libopenssl = "libopenssl" - -function init() - handle = ccall((:openssl_init, libopenssl), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:openssl_process, libopenssl), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:openssl_free, libopenssl), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/openssl.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/openssl/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/openssl/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/openssl/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/openssl/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/openssl/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/openssl/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/openssl/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/openssl/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/openssl/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/openssl/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/openssl/CONTRIBUTING.md b/asdf-plugin-collection/plugins/openssl/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/openssl/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/openssl/README.adoc b/asdf-plugin-collection/plugins/openssl/README.adoc index d08e1dd2..b121263d 100644 --- a/asdf-plugin-collection/plugins/openssl/README.adoc +++ b/asdf-plugin-collection/plugins/openssl/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-openssl -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-openssl-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-openssl-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-openssl-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-openssl-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://www.openssl.org[OpenSSL]. -**All repos with foreign function interfaces MUST follow this standard:** +TLS/SSL cryptography. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add openssl https://github.com/hyperpolymath/asdf-openssl-plugin.git +---- -=== Web Projects +openssl: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all openssl -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install openssl latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global openssl latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now openssl commands are available +openssl --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list openssl -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local openssl -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall openssl ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/openssl/README.md b/asdf-plugin-collection/plugins/openssl/README.md deleted file mode 100644 index add8b9f4..00000000 --- a/asdf-plugin-collection/plugins/openssl/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-openssl - -[![Build](https://github.com/hyperpolymath/asdf-openssl-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-openssl-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-openssl-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-openssl-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [OpenSSL](https://www.openssl.org). - -TLS/SSL cryptography. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add openssl https://github.com/hyperpolymath/asdf-openssl-plugin.git -``` - -openssl: - -```bash -# Show all installable versions -asdf list-all openssl - -# Install specific version -asdf install openssl latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global openssl latest - -# Now openssl commands are available -openssl --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list openssl - -# Set local version for current directory -asdf local openssl - -# Uninstall a version -asdf uninstall openssl -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/openssl/SECURITY.adoc b/asdf-plugin-collection/plugins/openssl/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/openssl/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/openssl/SECURITY.md b/asdf-plugin-collection/plugins/openssl/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/openssl/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/orchid/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/orchid/ABI-FFI-README.adoc new file mode 100644 index 00000000..37457c75 --- /dev/null +++ b/asdf-plugin-collection/plugins/orchid/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== ORCHID ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/orchid.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to liborchid.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +orchid/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── orchid.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── orchid.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/orchid.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "orchid.h" + +int main() { + void* handle = orchid_init(); + if (!handle) return 1; + + int result = orchid_process(handle, 42); + if (result != 0) { + const char* err = orchid_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + orchid_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lorchid -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import ORCHID.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "orchid")] +extern "C" { + fn orchid_init() -> *mut std::ffi::c_void; + fn orchid_free(handle: *mut std::ffi::c_void); + fn orchid_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = orchid_init(); + assert!(!handle.is_null()); + + let result = orchid_process(handle, 42); + assert_eq!(result, 0); + + orchid_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const liborchid = "liborchid" + +function init() + handle = ccall((:orchid_init, liborchid), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:orchid_process, liborchid), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:orchid_free, liborchid), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/orchid.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/orchid/ABI-FFI-README.md b/asdf-plugin-collection/plugins/orchid/ABI-FFI-README.md deleted file mode 100644 index 8a8a6412..00000000 --- a/asdf-plugin-collection/plugins/orchid/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# ORCHID ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/orchid.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to liborchid.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -orchid/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── orchid.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── orchid.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/orchid.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "orchid.h" - -int main() { - void* handle = orchid_init(); - if (!handle) return 1; - - int result = orchid_process(handle, 42); - if (result != 0) { - const char* err = orchid_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - orchid_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lorchid -L./zig-out/lib -``` - -### From Idris2 - -```idris -import ORCHID.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "orchid")] -extern "C" { - fn orchid_init() -> *mut std::ffi::c_void; - fn orchid_free(handle: *mut std::ffi::c_void); - fn orchid_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = orchid_init(); - assert!(!handle.is_null()); - - let result = orchid_process(handle, 42); - assert_eq!(result, 0); - - orchid_free(handle); - } -} -``` - -### From Julia - -```julia -const liborchid = "liborchid" - -function init() - handle = ccall((:orchid_init, liborchid), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:orchid_process, liborchid), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:orchid_free, liborchid), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/orchid.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/orchid/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/orchid/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/orchid/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/orchid/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/orchid/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/orchid/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/orchid/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/orchid/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/orchid/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/orchid/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/orchid/CONTRIBUTING.md b/asdf-plugin-collection/plugins/orchid/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/orchid/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/orchid/README.adoc b/asdf-plugin-collection/plugins/orchid/README.adoc index d08e1dd2..c91f2a58 100644 --- a/asdf-plugin-collection/plugins/orchid/README.adoc +++ b/asdf-plugin-collection/plugins/orchid/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-orchid -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-orchid-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-orchid-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-orchid-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-orchid-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://orchid.software[Orchid]. -**All repos with foreign function interfaces MUST follow this standard:** +Static site generator. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add orchid https://github.com/hyperpolymath/asdf-orchid-plugin.git +---- -=== Web Projects +orchid: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all orchid -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install orchid latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global orchid latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now orchid commands are available +orchid --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list orchid -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local orchid -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall orchid ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/orchid/README.md b/asdf-plugin-collection/plugins/orchid/README.md deleted file mode 100644 index 8ea1b9e8..00000000 --- a/asdf-plugin-collection/plugins/orchid/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-orchid - -[![Build](https://github.com/hyperpolymath/asdf-orchid-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-orchid-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-orchid-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-orchid-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Orchid](https://orchid.software). - -Static site generator. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add orchid https://github.com/hyperpolymath/asdf-orchid-plugin.git -``` - -orchid: - -```bash -# Show all installable versions -asdf list-all orchid - -# Install specific version -asdf install orchid latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global orchid latest - -# Now orchid commands are available -orchid --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list orchid - -# Set local version for current directory -asdf local orchid - -# Uninstall a version -asdf uninstall orchid -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/orchid/SECURITY.adoc b/asdf-plugin-collection/plugins/orchid/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/orchid/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/orchid/SECURITY.md b/asdf-plugin-collection/plugins/orchid/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/orchid/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/pollen/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/pollen/ABI-FFI-README.adoc new file mode 100644 index 00000000..b966efbf --- /dev/null +++ b/asdf-plugin-collection/plugins/pollen/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== POLLEN ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/pollen.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libpollen.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +pollen/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── pollen.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── pollen.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/pollen.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "pollen.h" + +int main() { + void* handle = pollen_init(); + if (!handle) return 1; + + int result = pollen_process(handle, 42); + if (result != 0) { + const char* err = pollen_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + pollen_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lpollen -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import POLLEN.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "pollen")] +extern "C" { + fn pollen_init() -> *mut std::ffi::c_void; + fn pollen_free(handle: *mut std::ffi::c_void); + fn pollen_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = pollen_init(); + assert!(!handle.is_null()); + + let result = pollen_process(handle, 42); + assert_eq!(result, 0); + + pollen_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libpollen = "libpollen" + +function init() + handle = ccall((:pollen_init, libpollen), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:pollen_process, libpollen), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:pollen_free, libpollen), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/pollen.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/pollen/ABI-FFI-README.md b/asdf-plugin-collection/plugins/pollen/ABI-FFI-README.md deleted file mode 100644 index bb2648b1..00000000 --- a/asdf-plugin-collection/plugins/pollen/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# POLLEN ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/pollen.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libpollen.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -pollen/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── pollen.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── pollen.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/pollen.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "pollen.h" - -int main() { - void* handle = pollen_init(); - if (!handle) return 1; - - int result = pollen_process(handle, 42); - if (result != 0) { - const char* err = pollen_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - pollen_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lpollen -L./zig-out/lib -``` - -### From Idris2 - -```idris -import POLLEN.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "pollen")] -extern "C" { - fn pollen_init() -> *mut std::ffi::c_void; - fn pollen_free(handle: *mut std::ffi::c_void); - fn pollen_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = pollen_init(); - assert!(!handle.is_null()); - - let result = pollen_process(handle, 42); - assert_eq!(result, 0); - - pollen_free(handle); - } -} -``` - -### From Julia - -```julia -const libpollen = "libpollen" - -function init() - handle = ccall((:pollen_init, libpollen), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:pollen_process, libpollen), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:pollen_free, libpollen), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/pollen.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/pollen/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/pollen/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/pollen/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/pollen/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/pollen/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/pollen/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/pollen/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/pollen/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/pollen/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/pollen/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/pollen/CONTRIBUTING.md b/asdf-plugin-collection/plugins/pollen/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/pollen/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/pollen/README.adoc b/asdf-plugin-collection/plugins/pollen/README.adoc index d08e1dd2..bdea8c0c 100644 --- a/asdf-plugin-collection/plugins/pollen/README.adoc +++ b/asdf-plugin-collection/plugins/pollen/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-pollen -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-pollen-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-pollen-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-pollen-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-pollen-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://docs.racket-lang.org/pollen[Pollen]. -**All repos with foreign function interfaces MUST follow this standard:** +Racket publishing system. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add pollen https://github.com/hyperpolymath/asdf-pollen-plugin.git +---- -=== Web Projects +pollen: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all pollen -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install pollen latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global pollen latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now pollen commands are available +pollen --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list pollen -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local pollen -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall pollen ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/pollen/README.md b/asdf-plugin-collection/plugins/pollen/README.md deleted file mode 100644 index 3c872089..00000000 --- a/asdf-plugin-collection/plugins/pollen/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-pollen - -[![Build](https://github.com/hyperpolymath/asdf-pollen-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-pollen-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-pollen-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-pollen-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Pollen](https://docs.racket-lang.org/pollen). - -Racket publishing system. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add pollen https://github.com/hyperpolymath/asdf-pollen-plugin.git -``` - -pollen: - -```bash -# Show all installable versions -asdf list-all pollen - -# Install specific version -asdf install pollen latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global pollen latest - -# Now pollen commands are available -pollen --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list pollen - -# Set local version for current directory -asdf local pollen - -# Uninstall a version -asdf uninstall pollen -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/pollen/SECURITY.adoc b/asdf-plugin-collection/plugins/pollen/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/pollen/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/pollen/SECURITY.md b/asdf-plugin-collection/plugins/pollen/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/pollen/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/pomerium/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/pomerium/ABI-FFI-README.adoc new file mode 100644 index 00000000..9a11b87e --- /dev/null +++ b/asdf-plugin-collection/plugins/pomerium/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== POMERIUM ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/pomerium.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libpomerium.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +pomerium/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── pomerium.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── pomerium.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/pomerium.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "pomerium.h" + +int main() { + void* handle = pomerium_init(); + if (!handle) return 1; + + int result = pomerium_process(handle, 42); + if (result != 0) { + const char* err = pomerium_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + pomerium_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lpomerium -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import POMERIUM.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "pomerium")] +extern "C" { + fn pomerium_init() -> *mut std::ffi::c_void; + fn pomerium_free(handle: *mut std::ffi::c_void); + fn pomerium_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = pomerium_init(); + assert!(!handle.is_null()); + + let result = pomerium_process(handle, 42); + assert_eq!(result, 0); + + pomerium_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libpomerium = "libpomerium" + +function init() + handle = ccall((:pomerium_init, libpomerium), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:pomerium_process, libpomerium), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:pomerium_free, libpomerium), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/pomerium.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/pomerium/ABI-FFI-README.md b/asdf-plugin-collection/plugins/pomerium/ABI-FFI-README.md deleted file mode 100644 index 4cc404ec..00000000 --- a/asdf-plugin-collection/plugins/pomerium/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# POMERIUM ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/pomerium.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libpomerium.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -pomerium/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── pomerium.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── pomerium.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/pomerium.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "pomerium.h" - -int main() { - void* handle = pomerium_init(); - if (!handle) return 1; - - int result = pomerium_process(handle, 42); - if (result != 0) { - const char* err = pomerium_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - pomerium_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lpomerium -L./zig-out/lib -``` - -### From Idris2 - -```idris -import POMERIUM.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "pomerium")] -extern "C" { - fn pomerium_init() -> *mut std::ffi::c_void; - fn pomerium_free(handle: *mut std::ffi::c_void); - fn pomerium_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = pomerium_init(); - assert!(!handle.is_null()); - - let result = pomerium_process(handle, 42); - assert_eq!(result, 0); - - pomerium_free(handle); - } -} -``` - -### From Julia - -```julia -const libpomerium = "libpomerium" - -function init() - handle = ccall((:pomerium_init, libpomerium), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:pomerium_process, libpomerium), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:pomerium_free, libpomerium), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/pomerium.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/pomerium/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/pomerium/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/pomerium/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/pomerium/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/pomerium/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/pomerium/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/pomerium/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/pomerium/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/pomerium/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/pomerium/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/pomerium/CONTRIBUTING.md b/asdf-plugin-collection/plugins/pomerium/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/pomerium/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/pomerium/README.adoc b/asdf-plugin-collection/plugins/pomerium/README.adoc index d08e1dd2..31f3305d 100644 --- a/asdf-plugin-collection/plugins/pomerium/README.adoc +++ b/asdf-plugin-collection/plugins/pomerium/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-pomerium -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-pomerium-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-pomerium-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-pomerium-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-pomerium-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://www.pomerium.com[Pomerium]. -**All repos with foreign function interfaces MUST follow this standard:** +Identity-aware proxy. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add pomerium https://github.com/hyperpolymath/asdf-pomerium-plugin.git +---- -=== Web Projects +pomerium: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all pomerium -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install pomerium latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global pomerium latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now pomerium commands are available +pomerium --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list pomerium -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local pomerium -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall pomerium ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/pomerium/README.md b/asdf-plugin-collection/plugins/pomerium/README.md deleted file mode 100644 index 2da9d408..00000000 --- a/asdf-plugin-collection/plugins/pomerium/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-pomerium - -[![Build](https://github.com/hyperpolymath/asdf-pomerium-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-pomerium-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-pomerium-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-pomerium-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Pomerium](https://www.pomerium.com). - -Identity-aware proxy. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add pomerium https://github.com/hyperpolymath/asdf-pomerium-plugin.git -``` - -pomerium: - -```bash -# Show all installable versions -asdf list-all pomerium - -# Install specific version -asdf install pomerium latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global pomerium latest - -# Now pomerium commands are available -pomerium --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list pomerium - -# Set local version for current directory -asdf local pomerium - -# Uninstall a version -asdf uninstall pomerium -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/pomerium/SECURITY.adoc b/asdf-plugin-collection/plugins/pomerium/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/pomerium/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/pomerium/SECURITY.md b/asdf-plugin-collection/plugins/pomerium/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/pomerium/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/rekor/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/rekor/ABI-FFI-README.adoc new file mode 100644 index 00000000..55ffa8ff --- /dev/null +++ b/asdf-plugin-collection/plugins/rekor/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== REKOR ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/rekor.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to librekor.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +rekor/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── rekor.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── rekor.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/rekor.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "rekor.h" + +int main() { + void* handle = rekor_init(); + if (!handle) return 1; + + int result = rekor_process(handle, 42); + if (result != 0) { + const char* err = rekor_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + rekor_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lrekor -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import REKOR.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "rekor")] +extern "C" { + fn rekor_init() -> *mut std::ffi::c_void; + fn rekor_free(handle: *mut std::ffi::c_void); + fn rekor_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = rekor_init(); + assert!(!handle.is_null()); + + let result = rekor_process(handle, 42); + assert_eq!(result, 0); + + rekor_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const librekor = "librekor" + +function init() + handle = ccall((:rekor_init, librekor), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:rekor_process, librekor), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:rekor_free, librekor), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/rekor.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/rekor/ABI-FFI-README.md b/asdf-plugin-collection/plugins/rekor/ABI-FFI-README.md deleted file mode 100644 index 0722435d..00000000 --- a/asdf-plugin-collection/plugins/rekor/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# REKOR ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/rekor.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to librekor.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -rekor/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── rekor.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── rekor.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/rekor.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "rekor.h" - -int main() { - void* handle = rekor_init(); - if (!handle) return 1; - - int result = rekor_process(handle, 42); - if (result != 0) { - const char* err = rekor_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - rekor_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lrekor -L./zig-out/lib -``` - -### From Idris2 - -```idris -import REKOR.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "rekor")] -extern "C" { - fn rekor_init() -> *mut std::ffi::c_void; - fn rekor_free(handle: *mut std::ffi::c_void); - fn rekor_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = rekor_init(); - assert!(!handle.is_null()); - - let result = rekor_process(handle, 42); - assert_eq!(result, 0); - - rekor_free(handle); - } -} -``` - -### From Julia - -```julia -const librekor = "librekor" - -function init() - handle = ccall((:rekor_init, librekor), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:rekor_process, librekor), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:rekor_free, librekor), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/rekor.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/rekor/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/rekor/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/rekor/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/rekor/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/rekor/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/rekor/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/rekor/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/rekor/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/rekor/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/rekor/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/rekor/CONTRIBUTING.md b/asdf-plugin-collection/plugins/rekor/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/rekor/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/rekor/README.adoc b/asdf-plugin-collection/plugins/rekor/README.adoc index d08e1dd2..512c1faf 100644 --- a/asdf-plugin-collection/plugins/rekor/README.adoc +++ b/asdf-plugin-collection/plugins/rekor/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-rekor -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-rekor-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-rekor-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-rekor-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-rekor-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://sigstore.dev[Rekor]. -**All repos with foreign function interfaces MUST follow this standard:** +Sigstore transparency log. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add rekor https://github.com/hyperpolymath/asdf-rekor-plugin.git +---- -=== Web Projects +rekor: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all rekor -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install rekor latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global rekor latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now rekor commands are available +rekor --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list rekor -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local rekor -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall rekor ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/rekor/README.md b/asdf-plugin-collection/plugins/rekor/README.md deleted file mode 100644 index b031657a..00000000 --- a/asdf-plugin-collection/plugins/rekor/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-rekor - -[![Build](https://github.com/hyperpolymath/asdf-rekor-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-rekor-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-rekor-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-rekor-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Rekor](https://sigstore.dev). - -Sigstore transparency log. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add rekor https://github.com/hyperpolymath/asdf-rekor-plugin.git -``` - -rekor: - -```bash -# Show all installable versions -asdf list-all rekor - -# Install specific version -asdf install rekor latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global rekor latest - -# Now rekor commands are available -rekor --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list rekor - -# Set local version for current directory -asdf local rekor - -# Uninstall a version -asdf uninstall rekor -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/rekor/SECURITY.adoc b/asdf-plugin-collection/plugins/rekor/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/rekor/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/rekor/SECURITY.md b/asdf-plugin-collection/plugins/rekor/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/rekor/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/rescript/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/rescript/ABI-FFI-README.adoc new file mode 100644 index 00000000..d31a905e --- /dev/null +++ b/asdf-plugin-collection/plugins/rescript/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== AFFINESCRIPT ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/affinescript.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to librescript.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +affinescript/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── affinescript.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── affinescript.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/affinescript.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "affinescript.h" + +int main() { + void* handle = rescript_init(); + if (!handle) return 1; + + int result = rescript_process(handle, 42); + if (result != 0) { + const char* err = rescript_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + rescript_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lrescript -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import AFFINESCRIPT.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "affinescript")] +extern "C" { + fn rescript_init() -> *mut std::ffi::c_void; + fn rescript_free(handle: *mut std::ffi::c_void); + fn rescript_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = rescript_init(); + assert!(!handle.is_null()); + + let result = rescript_process(handle, 42); + assert_eq!(result, 0); + + rescript_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const librescript = "librescript" + +function init() + handle = ccall((:rescript_init, librescript), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:rescript_process, librescript), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:rescript_free, librescript), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/affinescript.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/rescript/ABI-FFI-README.md b/asdf-plugin-collection/plugins/rescript/ABI-FFI-README.md deleted file mode 100644 index 358c9ee2..00000000 --- a/asdf-plugin-collection/plugins/rescript/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# AFFINESCRIPT ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/affinescript.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to librescript.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -affinescript/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── affinescript.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── affinescript.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/affinescript.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "affinescript.h" - -int main() { - void* handle = rescript_init(); - if (!handle) return 1; - - int result = rescript_process(handle, 42); - if (result != 0) { - const char* err = rescript_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - rescript_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lrescript -L./zig-out/lib -``` - -### From Idris2 - -```idris -import AFFINESCRIPT.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "affinescript")] -extern "C" { - fn rescript_init() -> *mut std::ffi::c_void; - fn rescript_free(handle: *mut std::ffi::c_void); - fn rescript_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = rescript_init(); - assert!(!handle.is_null()); - - let result = rescript_process(handle, 42); - assert_eq!(result, 0); - - rescript_free(handle); - } -} -``` - -### From Julia - -```julia -const librescript = "librescript" - -function init() - handle = ccall((:rescript_init, librescript), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:rescript_process, librescript), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:rescript_free, librescript), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/affinescript.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/rescript/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/rescript/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/rescript/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/rescript/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/rescript/CODE_OF_CONDUCT.md deleted file mode 100644 index 66a1ffed..00000000 --- a/asdf-plugin-collection/plugins/rescript/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/rescript/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/rescript/CONTRIBUTING.adoc index 2a29fd14..084ee525 100644 --- a/asdf-plugin-collection/plugins/rescript/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/rescript/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: MPL-2.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/rescript/CONTRIBUTING.md b/asdf-plugin-collection/plugins/rescript/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/rescript/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/rescript/README.adoc b/asdf-plugin-collection/plugins/rescript/README.adoc index d08e1dd2..84007da3 100644 --- a/asdf-plugin-collection/plugins/rescript/README.adoc +++ b/asdf-plugin-collection/plugins/rescript/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-affinescript -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-affinescript-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-affinescript-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-affinescript-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-affinescript-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-PMPL–1.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://affinescript-lang.org[AffineScript]. -**All repos with foreign function interfaces MUST follow this standard:** +Type-safe JavaScript. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add affinescript https://github.com/hyperpolymath/asdf-affinescript-plugin.git +---- -=== Web Projects +affinescript: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all affinescript -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install affinescript latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global affinescript latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now affinescript commands are available +affinescript --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list affinescript -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local affinescript -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall affinescript ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/rescript/README.md b/asdf-plugin-collection/plugins/rescript/README.md deleted file mode 100644 index c30e28b1..00000000 --- a/asdf-plugin-collection/plugins/rescript/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-affinescript - -[![Build](https://github.com/hyperpolymath/asdf-affinescript-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-affinescript-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-affinescript-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-affinescript-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-PMPL--1.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [AffineScript](https://affinescript-lang.org). - -Type-safe JavaScript. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add affinescript https://github.com/hyperpolymath/asdf-affinescript-plugin.git -``` - -affinescript: - -```bash -# Show all installable versions -asdf list-all affinescript - -# Install specific version -asdf install affinescript latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global affinescript latest - -# Now affinescript commands are available -affinescript --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list affinescript - -# Set local version for current directory -asdf local affinescript - -# Uninstall a version -asdf uninstall affinescript -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/rescript/SECURITY.adoc b/asdf-plugin-collection/plugins/rescript/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/rescript/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/rescript/SECURITY.md b/asdf-plugin-collection/plugins/rescript/SECURITY.md deleted file mode 100644 index f6df8cb5..00000000 --- a/asdf-plugin-collection/plugins/rescript/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/restic/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/restic/ABI-FFI-README.adoc new file mode 100644 index 00000000..f8a06f74 --- /dev/null +++ b/asdf-plugin-collection/plugins/restic/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== RESTIC ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/restic.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to librestic.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +restic/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── restic.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── restic.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/restic.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "restic.h" + +int main() { + void* handle = restic_init(); + if (!handle) return 1; + + int result = restic_process(handle, 42); + if (result != 0) { + const char* err = restic_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + restic_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lrestic -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import RESTIC.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "restic")] +extern "C" { + fn restic_init() -> *mut std::ffi::c_void; + fn restic_free(handle: *mut std::ffi::c_void); + fn restic_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = restic_init(); + assert!(!handle.is_null()); + + let result = restic_process(handle, 42); + assert_eq!(result, 0); + + restic_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const librestic = "librestic" + +function init() + handle = ccall((:restic_init, librestic), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:restic_process, librestic), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:restic_free, librestic), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/restic.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/restic/ABI-FFI-README.md b/asdf-plugin-collection/plugins/restic/ABI-FFI-README.md deleted file mode 100644 index df6de0ef..00000000 --- a/asdf-plugin-collection/plugins/restic/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# RESTIC ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/restic.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to librestic.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -restic/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── restic.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── restic.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/restic.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "restic.h" - -int main() { - void* handle = restic_init(); - if (!handle) return 1; - - int result = restic_process(handle, 42); - if (result != 0) { - const char* err = restic_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - restic_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lrestic -L./zig-out/lib -``` - -### From Idris2 - -```idris -import RESTIC.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "restic")] -extern "C" { - fn restic_init() -> *mut std::ffi::c_void; - fn restic_free(handle: *mut std::ffi::c_void); - fn restic_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = restic_init(); - assert!(!handle.is_null()); - - let result = restic_process(handle, 42); - assert_eq!(result, 0); - - restic_free(handle); - } -} -``` - -### From Julia - -```julia -const librestic = "librestic" - -function init() - handle = ccall((:restic_init, librestic), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:restic_process, librestic), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:restic_free, librestic), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/restic.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/restic/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/restic/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/restic/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/restic/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/restic/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/restic/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/restic/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/restic/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/restic/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/restic/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/restic/CONTRIBUTING.md b/asdf-plugin-collection/plugins/restic/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/restic/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/restic/README.adoc b/asdf-plugin-collection/plugins/restic/README.adoc index d08e1dd2..23d77c86 100644 --- a/asdf-plugin-collection/plugins/restic/README.adoc +++ b/asdf-plugin-collection/plugins/restic/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-restic -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-restic-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-restic-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-restic-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-restic-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://restic.net[Restic]. -**All repos with foreign function interfaces MUST follow this standard:** +Fast secure backup. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add restic https://github.com/hyperpolymath/asdf-restic-plugin.git +---- -=== Web Projects +restic: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all restic -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install restic latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global restic latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now restic commands are available +restic --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list restic -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local restic -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall restic ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/restic/README.md b/asdf-plugin-collection/plugins/restic/README.md deleted file mode 100644 index 442f2bd1..00000000 --- a/asdf-plugin-collection/plugins/restic/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-restic - -[![Build](https://github.com/hyperpolymath/asdf-restic-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-restic-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-restic-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-restic-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Restic](https://restic.net). - -Fast secure backup. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add restic https://github.com/hyperpolymath/asdf-restic-plugin.git -``` - -restic: - -```bash -# Show all installable versions -asdf list-all restic - -# Install specific version -asdf install restic latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global restic latest - -# Now restic commands are available -restic --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list restic - -# Set local version for current directory -asdf local restic - -# Uninstall a version -asdf uninstall restic -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/restic/SECURITY.adoc b/asdf-plugin-collection/plugins/restic/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/restic/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/restic/SECURITY.md b/asdf-plugin-collection/plugins/restic/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/restic/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/rethinkdb/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/rethinkdb/ABI-FFI-README.adoc new file mode 100644 index 00000000..75445ff6 --- /dev/null +++ b/asdf-plugin-collection/plugins/rethinkdb/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== RETHINKDB ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/rethinkdb.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to librethinkdb.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +rethinkdb/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── rethinkdb.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── rethinkdb.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/rethinkdb.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "rethinkdb.h" + +int main() { + void* handle = rethinkdb_init(); + if (!handle) return 1; + + int result = rethinkdb_process(handle, 42); + if (result != 0) { + const char* err = rethinkdb_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + rethinkdb_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lrethinkdb -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import RETHINKDB.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "rethinkdb")] +extern "C" { + fn rethinkdb_init() -> *mut std::ffi::c_void; + fn rethinkdb_free(handle: *mut std::ffi::c_void); + fn rethinkdb_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = rethinkdb_init(); + assert!(!handle.is_null()); + + let result = rethinkdb_process(handle, 42); + assert_eq!(result, 0); + + rethinkdb_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const librethinkdb = "librethinkdb" + +function init() + handle = ccall((:rethinkdb_init, librethinkdb), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:rethinkdb_process, librethinkdb), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:rethinkdb_free, librethinkdb), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/rethinkdb.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/rethinkdb/ABI-FFI-README.md b/asdf-plugin-collection/plugins/rethinkdb/ABI-FFI-README.md deleted file mode 100644 index 3e1dca88..00000000 --- a/asdf-plugin-collection/plugins/rethinkdb/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# RETHINKDB ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/rethinkdb.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to librethinkdb.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -rethinkdb/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── rethinkdb.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── rethinkdb.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/rethinkdb.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "rethinkdb.h" - -int main() { - void* handle = rethinkdb_init(); - if (!handle) return 1; - - int result = rethinkdb_process(handle, 42); - if (result != 0) { - const char* err = rethinkdb_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - rethinkdb_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lrethinkdb -L./zig-out/lib -``` - -### From Idris2 - -```idris -import RETHINKDB.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "rethinkdb")] -extern "C" { - fn rethinkdb_init() -> *mut std::ffi::c_void; - fn rethinkdb_free(handle: *mut std::ffi::c_void); - fn rethinkdb_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = rethinkdb_init(); - assert!(!handle.is_null()); - - let result = rethinkdb_process(handle, 42); - assert_eq!(result, 0); - - rethinkdb_free(handle); - } -} -``` - -### From Julia - -```julia -const librethinkdb = "librethinkdb" - -function init() - handle = ccall((:rethinkdb_init, librethinkdb), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:rethinkdb_process, librethinkdb), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:rethinkdb_free, librethinkdb), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/rethinkdb.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/rethinkdb/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/rethinkdb/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/rethinkdb/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/rethinkdb/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/rethinkdb/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/rethinkdb/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/rethinkdb/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/rethinkdb/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/rethinkdb/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/rethinkdb/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/rethinkdb/CONTRIBUTING.md b/asdf-plugin-collection/plugins/rethinkdb/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/rethinkdb/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/rethinkdb/README.adoc b/asdf-plugin-collection/plugins/rethinkdb/README.adoc index d08e1dd2..b110a454 100644 --- a/asdf-plugin-collection/plugins/rethinkdb/README.adoc +++ b/asdf-plugin-collection/plugins/rethinkdb/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-rethinkdb -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-rethinkdb-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-rethinkdb-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-rethinkdb-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-rethinkdb-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://rethinkdb.com[RethinkDB]. -**All repos with foreign function interfaces MUST follow this standard:** +Real-time document database. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add rethinkdb https://github.com/hyperpolymath/asdf-rethinkdb-plugin.git +---- -=== Web Projects +rethinkdb: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all rethinkdb -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install rethinkdb latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global rethinkdb latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now rethinkdb commands are available +rethinkdb --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list rethinkdb -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local rethinkdb -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall rethinkdb ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/rethinkdb/README.md b/asdf-plugin-collection/plugins/rethinkdb/README.md deleted file mode 100644 index b2ad7d5d..00000000 --- a/asdf-plugin-collection/plugins/rethinkdb/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-rethinkdb - -[![Build](https://github.com/hyperpolymath/asdf-rethinkdb-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-rethinkdb-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-rethinkdb-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-rethinkdb-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [RethinkDB](https://rethinkdb.com). - -Real-time document database. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add rethinkdb https://github.com/hyperpolymath/asdf-rethinkdb-plugin.git -``` - -rethinkdb: - -```bash -# Show all installable versions -asdf list-all rethinkdb - -# Install specific version -asdf install rethinkdb latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global rethinkdb latest - -# Now rethinkdb commands are available -rethinkdb --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list rethinkdb - -# Set local version for current directory -asdf local rethinkdb - -# Uninstall a version -asdf uninstall rethinkdb -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/rethinkdb/SECURITY.adoc b/asdf-plugin-collection/plugins/rethinkdb/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/rethinkdb/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/rethinkdb/SECURITY.md b/asdf-plugin-collection/plugins/rethinkdb/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/rethinkdb/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/security/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/security/ABI-FFI-README.adoc new file mode 100644 index 00000000..a80ffdfd --- /dev/null +++ b/asdf-plugin-collection/plugins/security/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== SECURITY ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/security.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libsecurity.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +security/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── security.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── security.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/security.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "security.h" + +int main() { + void* handle = security_init(); + if (!handle) return 1; + + int result = security_process(handle, 42); + if (result != 0) { + const char* err = security_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + security_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lsecurity -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import SECURITY.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "security")] +extern "C" { + fn security_init() -> *mut std::ffi::c_void; + fn security_free(handle: *mut std::ffi::c_void); + fn security_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = security_init(); + assert!(!handle.is_null()); + + let result = security_process(handle, 42); + assert_eq!(result, 0); + + security_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libsecurity = "libsecurity" + +function init() + handle = ccall((:security_init, libsecurity), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:security_process, libsecurity), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:security_free, libsecurity), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/security.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/security/ABI-FFI-README.md b/asdf-plugin-collection/plugins/security/ABI-FFI-README.md deleted file mode 100644 index 28dfe6f4..00000000 --- a/asdf-plugin-collection/plugins/security/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# SECURITY ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/security.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libsecurity.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -security/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── security.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── security.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/security.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "security.h" - -int main() { - void* handle = security_init(); - if (!handle) return 1; - - int result = security_process(handle, 42); - if (result != 0) { - const char* err = security_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - security_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lsecurity -L./zig-out/lib -``` - -### From Idris2 - -```idris -import SECURITY.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "security")] -extern "C" { - fn security_init() -> *mut std::ffi::c_void; - fn security_free(handle: *mut std::ffi::c_void); - fn security_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = security_init(); - assert!(!handle.is_null()); - - let result = security_process(handle, 42); - assert_eq!(result, 0); - - security_free(handle); - } -} -``` - -### From Julia - -```julia -const libsecurity = "libsecurity" - -function init() - handle = ccall((:security_init, libsecurity), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:security_process, libsecurity), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:security_free, libsecurity), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/security.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/security/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/security/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/security/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/security/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/security/CODE_OF_CONDUCT.md deleted file mode 100644 index caeda1c6..00000000 --- a/asdf-plugin-collection/plugins/security/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,27 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. - diff --git a/asdf-plugin-collection/plugins/security/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/security/CONTRIBUTING.adoc index eb045d61..084ee525 100644 --- a/asdf-plugin-collection/plugins/security/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/security/CONTRIBUTING.adoc @@ -1,20 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/security/CONTRIBUTING.md b/asdf-plugin-collection/plugins/security/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/security/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/security/README.adoc b/asdf-plugin-collection/plugins/security/README.adoc index acbc80f7..92df847a 100644 --- a/asdf-plugin-collection/plugins/security/README.adoc +++ b/asdf-plugin-collection/plugins/security/README.adoc @@ -1,122 +1,54 @@ -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] -image:https://img.shields.io/badge/Philosophy-Palimpsest-indigo.svg[Palimpsest,link="https://github.com/hyperpolymath/palimpsest-license"] +== asdf-security-plugin +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] +image:https://img.shields.io/badge/Philosophy-Palimpsest-indigo.svg[Palimpsest,link="`https://github.com/hyperpolymath/palimpsest-license`"] -// SPDX-License-Identifier: CC-BY-SA-4.0 -= asdf-security-plugin +Security-focused extensions and policies for the +https://asdf-vm.com[asdf] version manager ecosystem. -:toc: macro -:toc-title: Contents -:toclevels: 2 +=== Status -**Security scanning plugin for asdf version manager** +____ +*Note:* This repository is currently a project skeleton. Implementation +is pending. +____ -toc::[] +=== Overview -== Status +`+asdf-security-plugin+` provides security tooling and policies for the +asdf plugin ecosystem: -[NOTE] -==== -This plugin is *fully functional* at version 1.0.0. -==== +* *Security scanning* - Vulnerability detection for installed tools +* *Policy enforcement* - Ensure only approved versions are installed +* *Audit logging* - Track version changes and installations +* *Signature verification* - Validate tool authenticity -== Overview +=== Planned Features -`asdf-security-plugin` is a security-focused plugin for the https://asdf-vm.com/[asdf version manager]. It provides security scanning capabilities for asdf installations, including plugin auditing, signature verification, and vulnerability reporting. +* Integration with Trivy, Grype, and Syft for scanning +* Policy-as-code support via OPA/Rego +* SBOM generation for installed tool chains +* Supply chain attestation via Sigstore -== Installation +=== Related Projects -[source,bash] ----- -asdf plugin add asdf-security https://github.com/hyperpolymath/asdf-security-plugin.git -asdf install asdf-security 1.0.0 -asdf global asdf-security 1.0.0 ----- - -== Usage - -[source,bash] ----- -asdf-security [args...] ----- - -=== Commands - -[cols="2,3",options="header"] +[width="100%",cols="40%,60%",options="header",] |=== -| Command | Description - -| `audit` -| Audit all installed asdf plugins for known vulnerabilities - -| `verify ` -| Verify GPG signatures and SHA256 checksums of a plugin - -| `report` -| Generate a comprehensive security report of all plugins +|Project |Relationship +|https://github.com/hyperpolymath/asdf-metaiconic-plugin[asdf-metaiconic-plugin] +|Metadata registry -| `update-db` -| Update the local vulnerability database +|https://github.com/hyperpolymath/asdf-ui-plugin[asdf-ui-plugin] |Visual +interface |=== -=== Examples - -[source,bash] ----- -# Audit all plugins -asdf-security audit - -# Verify a specific plugin -asdf-security verify nodejs - -# Generate security report -asdf-security report - -# Update vulnerability database -asdf-security update-db ----- - -== Components - -[cols="2,3",options="header"] -|=== -| Component | Description - -| `bin/list-all` -| Lists available versions of asdf-security - -| `bin/download` -| Downloads the specified version - -| `bin/install` -| Installs asdf-security to the specified path - -| `lib/utils.bash` -| Shared utility functions - -| `.github/workflows/` -| CI/CD infrastructure including security scanning - -| `hooks/` -| Pre-commit validation hooks for security standards -|=== - -== Security Features - -* *Plugin Auditing*: Scans installed plugins against known vulnerability databases -* *Signature Verification*: Validates GPG signatures on plugin releases -* *Checksum Validation*: SHA256 integrity verification for downloads -* *Security Reports*: Comprehensive JSON/text reports of security posture - -== Development Standards - -Per the Hyperpolymath Language Policy: +=== License -* **Primary languages**: Bash/POSIX Shell (for asdf plugin scripts) -* **Package management**: Guix (primary), Guix (fallback) -* **Security**: SHA256+ hashing, HTTPS only, no hardcoded secrets, SHA-pinned dependencies -* **Code quality**: ShellCheck linting, SPDX license headers +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -== License +''''' -MPL-2.0 +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/security/README.md b/asdf-plugin-collection/plugins/security/README.md deleted file mode 100644 index 9ee2db44..00000000 --- a/asdf-plugin-collection/plugins/security/README.md +++ /dev/null @@ -1,41 +0,0 @@ -# asdf-security-plugin - -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] -image:https://img.shields.io/badge/Philosophy-Palimpsest-indigo.svg[Palimpsest,link="https://github.com/hyperpolymath/palimpsest-license"] - -Security-focused extensions and policies for the [asdf](https://asdf-vm.com) version manager ecosystem. - -## Status - -> **Note:** This repository is currently a project skeleton. Implementation is pending. - -## Overview - -`asdf-security-plugin` provides security tooling and policies for the asdf plugin ecosystem: - -- **Security scanning** - Vulnerability detection for installed tools -- **Policy enforcement** - Ensure only approved versions are installed -- **Audit logging** - Track version changes and installations -- **Signature verification** - Validate tool authenticity - -## Planned Features - -- Integration with Trivy, Grype, and Syft for scanning -- Policy-as-code support via OPA/Rego -- SBOM generation for installed tool chains -- Supply chain attestation via Sigstore - -## Related Projects - -| Project | Relationship | -|---------|--------------| -| [asdf-metaiconic-plugin](https://github.com/hyperpolymath/asdf-metaiconic-plugin) | Metadata registry | -| [asdf-ui-plugin](https://github.com/hyperpolymath/asdf-ui-plugin) | Visual interface | - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/security/SECURITY.adoc b/asdf-plugin-collection/plugins/security/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/security/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/security/SECURITY.md b/asdf-plugin-collection/plugins/security/SECURITY.md deleted file mode 100644 index 159a0b7a..00000000 --- a/asdf-plugin-collection/plugins/security/SECURITY.md +++ /dev/null @@ -1,25 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection - diff --git a/asdf-plugin-collection/plugins/serum/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/serum/ABI-FFI-README.adoc new file mode 100644 index 00000000..324cdd6c --- /dev/null +++ b/asdf-plugin-collection/plugins/serum/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== SERUM ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/serum.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libserum.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +serum/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── serum.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── serum.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/serum.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "serum.h" + +int main() { + void* handle = serum_init(); + if (!handle) return 1; + + int result = serum_process(handle, 42); + if (result != 0) { + const char* err = serum_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + serum_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lserum -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import SERUM.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "serum")] +extern "C" { + fn serum_init() -> *mut std::ffi::c_void; + fn serum_free(handle: *mut std::ffi::c_void); + fn serum_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = serum_init(); + assert!(!handle.is_null()); + + let result = serum_process(handle, 42); + assert_eq!(result, 0); + + serum_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libserum = "libserum" + +function init() + handle = ccall((:serum_init, libserum), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:serum_process, libserum), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:serum_free, libserum), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/serum.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/serum/ABI-FFI-README.md b/asdf-plugin-collection/plugins/serum/ABI-FFI-README.md deleted file mode 100644 index 55ed6746..00000000 --- a/asdf-plugin-collection/plugins/serum/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# SERUM ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/serum.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libserum.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -serum/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── serum.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── serum.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/serum.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "serum.h" - -int main() { - void* handle = serum_init(); - if (!handle) return 1; - - int result = serum_process(handle, 42); - if (result != 0) { - const char* err = serum_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - serum_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lserum -L./zig-out/lib -``` - -### From Idris2 - -```idris -import SERUM.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "serum")] -extern "C" { - fn serum_init() -> *mut std::ffi::c_void; - fn serum_free(handle: *mut std::ffi::c_void); - fn serum_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = serum_init(); - assert!(!handle.is_null()); - - let result = serum_process(handle, 42); - assert_eq!(result, 0); - - serum_free(handle); - } -} -``` - -### From Julia - -```julia -const libserum = "libserum" - -function init() - handle = ccall((:serum_init, libserum), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:serum_process, libserum), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:serum_free, libserum), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/serum.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/serum/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/serum/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/serum/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/serum/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/serum/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/serum/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/serum/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/serum/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/serum/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/serum/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/serum/CONTRIBUTING.md b/asdf-plugin-collection/plugins/serum/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/serum/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/serum/README.adoc b/asdf-plugin-collection/plugins/serum/README.adoc index d08e1dd2..8de14fa8 100644 --- a/asdf-plugin-collection/plugins/serum/README.adoc +++ b/asdf-plugin-collection/plugins/serum/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-serum -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-serum-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-serum-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-serum-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-serum-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://dalgona.github.io/Serum[Serum]. -**All repos with foreign function interfaces MUST follow this standard:** +Elixir static site generator. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add serum https://github.com/hyperpolymath/asdf-serum-plugin.git +---- -=== Web Projects +serum: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all serum -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install serum latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global serum latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now serum commands are available +serum --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list serum -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local serum -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall serum ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/serum/README.md b/asdf-plugin-collection/plugins/serum/README.md deleted file mode 100644 index f325d7f4..00000000 --- a/asdf-plugin-collection/plugins/serum/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-serum - -[![Build](https://github.com/hyperpolymath/asdf-serum-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-serum-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-serum-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-serum-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Serum](https://dalgona.github.io/Serum). - -Elixir static site generator. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add serum https://github.com/hyperpolymath/asdf-serum-plugin.git -``` - -serum: - -```bash -# Show all installable versions -asdf list-all serum - -# Install specific version -asdf install serum latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global serum latest - -# Now serum commands are available -serum --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list serum - -# Set local version for current directory -asdf local serum - -# Uninstall a version -asdf uninstall serum -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/serum/SECURITY.adoc b/asdf-plugin-collection/plugins/serum/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/serum/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/serum/SECURITY.md b/asdf-plugin-collection/plugins/serum/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/serum/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/sops/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/sops/ABI-FFI-README.adoc new file mode 100644 index 00000000..172c85b4 --- /dev/null +++ b/asdf-plugin-collection/plugins/sops/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== SOPS ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/sops.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libsops.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +sops/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── sops.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── sops.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/sops.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "sops.h" + +int main() { + void* handle = sops_init(); + if (!handle) return 1; + + int result = sops_process(handle, 42); + if (result != 0) { + const char* err = sops_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + sops_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lsops -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import SOPS.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "sops")] +extern "C" { + fn sops_init() -> *mut std::ffi::c_void; + fn sops_free(handle: *mut std::ffi::c_void); + fn sops_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = sops_init(); + assert!(!handle.is_null()); + + let result = sops_process(handle, 42); + assert_eq!(result, 0); + + sops_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libsops = "libsops" + +function init() + handle = ccall((:sops_init, libsops), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:sops_process, libsops), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:sops_free, libsops), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/sops.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/sops/ABI-FFI-README.md b/asdf-plugin-collection/plugins/sops/ABI-FFI-README.md deleted file mode 100644 index 94692b76..00000000 --- a/asdf-plugin-collection/plugins/sops/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# SOPS ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/sops.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libsops.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -sops/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── sops.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── sops.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/sops.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "sops.h" - -int main() { - void* handle = sops_init(); - if (!handle) return 1; - - int result = sops_process(handle, 42); - if (result != 0) { - const char* err = sops_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - sops_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lsops -L./zig-out/lib -``` - -### From Idris2 - -```idris -import SOPS.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "sops")] -extern "C" { - fn sops_init() -> *mut std::ffi::c_void; - fn sops_free(handle: *mut std::ffi::c_void); - fn sops_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = sops_init(); - assert!(!handle.is_null()); - - let result = sops_process(handle, 42); - assert_eq!(result, 0); - - sops_free(handle); - } -} -``` - -### From Julia - -```julia -const libsops = "libsops" - -function init() - handle = ccall((:sops_init, libsops), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:sops_process, libsops), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:sops_free, libsops), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/sops.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/sops/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/sops/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/sops/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/sops/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/sops/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/sops/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/sops/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/sops/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/sops/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/sops/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/sops/CONTRIBUTING.md b/asdf-plugin-collection/plugins/sops/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/sops/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/sops/README.adoc b/asdf-plugin-collection/plugins/sops/README.adoc index 72f888e1..59bf0404 100644 --- a/asdf-plugin-collection/plugins/sops/README.adoc +++ b/asdf-plugin-collection/plugins/sops/README.adoc @@ -1,26 +1,83 @@ -= asdf-sops +== asdf-sops -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] -:url-asdf: https://asdf-vm.com +https://github.com/hyperpolymath/asdf-sops-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-sops-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-sops-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-sops-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -An {url-asdf}[asdf] plugin for https://github.com/getsops/sops[SOPS] - Secrets OPerationS. +https://asdf-vm.com[asdf] plugin for +https://github.com/getsops/sops[SOPS]. -== Installation +Secrets editor. + +=== Contents + +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] + +=== Dependencies + +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] + +=== Install + +Plugin: [source,bash] ---- asdf plugin add sops https://github.com/hyperpolymath/asdf-sops-plugin.git ---- -== Usage +sops: [source,bash] ---- -asdf list all sops +# Show all installable versions +asdf list-all sops + +# Install specific version asdf install sops latest + +# Set a version globally (in your ~/.tool-versions file) asdf global sops latest + +# Now sops commands are available +sops --version ---- -== License +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. + +=== Usage + +[source,bash] +---- +# List installed versions +asdf list sops + +# Set local version for current directory +asdf local sops + +# Uninstall a version +asdf uninstall sops +---- + +=== Contributing + +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License + +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. + +''''' -SPDX-License-Identifier: CC-BY-SA-4.0 +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/sops/README.md b/asdf-plugin-collection/plugins/sops/README.md deleted file mode 100644 index 64c9008d..00000000 --- a/asdf-plugin-collection/plugins/sops/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-sops - -[![Build](https://github.com/hyperpolymath/asdf-sops-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-sops-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-sops-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-sops-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [SOPS](https://github.com/getsops/sops). - -Secrets editor. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add sops https://github.com/hyperpolymath/asdf-sops-plugin.git -``` - -sops: - -```bash -# Show all installable versions -asdf list-all sops - -# Install specific version -asdf install sops latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global sops latest - -# Now sops commands are available -sops --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list sops - -# Set local version for current directory -asdf local sops - -# Uninstall a version -asdf uninstall sops -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/sops/SECURITY.adoc b/asdf-plugin-collection/plugins/sops/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/sops/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/sops/SECURITY.md b/asdf-plugin-collection/plugins/sops/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/sops/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/step-ca/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/step-ca/ABI-FFI-README.adoc new file mode 100644 index 00000000..48e73b27 --- /dev/null +++ b/asdf-plugin-collection/plugins/step-ca/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== STEP_CA ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/step-ca.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libstep-ca.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +step-ca/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── step-ca.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── step-ca.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/step-ca.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "step-ca.h" + +int main() { + void* handle = step-ca_init(); + if (!handle) return 1; + + int result = step-ca_process(handle, 42); + if (result != 0) { + const char* err = step-ca_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + step-ca_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lstep-ca -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import STEP_CA.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "step-ca")] +extern "C" { + fn step-ca_init() -> *mut std::ffi::c_void; + fn step-ca_free(handle: *mut std::ffi::c_void); + fn step-ca_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = step-ca_init(); + assert!(!handle.is_null()); + + let result = step-ca_process(handle, 42); + assert_eq!(result, 0); + + step-ca_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libstep-ca = "libstep-ca" + +function init() + handle = ccall((:step-ca_init, libstep-ca), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:step-ca_process, libstep-ca), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:step-ca_free, libstep-ca), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/step-ca.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/step-ca/ABI-FFI-README.md b/asdf-plugin-collection/plugins/step-ca/ABI-FFI-README.md deleted file mode 100644 index 3a8993d5..00000000 --- a/asdf-plugin-collection/plugins/step-ca/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# STEP_CA ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/step-ca.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libstep-ca.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -step-ca/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── step-ca.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── step-ca.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/step-ca.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "step-ca.h" - -int main() { - void* handle = step-ca_init(); - if (!handle) return 1; - - int result = step-ca_process(handle, 42); - if (result != 0) { - const char* err = step-ca_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - step-ca_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lstep-ca -L./zig-out/lib -``` - -### From Idris2 - -```idris -import STEP_CA.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "step-ca")] -extern "C" { - fn step-ca_init() -> *mut std::ffi::c_void; - fn step-ca_free(handle: *mut std::ffi::c_void); - fn step-ca_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = step-ca_init(); - assert!(!handle.is_null()); - - let result = step-ca_process(handle, 42); - assert_eq!(result, 0); - - step-ca_free(handle); - } -} -``` - -### From Julia - -```julia -const libstep-ca = "libstep-ca" - -function init() - handle = ccall((:step-ca_init, libstep-ca), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:step-ca_process, libstep-ca), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:step-ca_free, libstep-ca), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/step-ca.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/step-ca/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/step-ca/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/step-ca/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/step-ca/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/step-ca/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/step-ca/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/step-ca/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/step-ca/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/step-ca/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/step-ca/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/step-ca/CONTRIBUTING.md b/asdf-plugin-collection/plugins/step-ca/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/step-ca/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/step-ca/README.adoc b/asdf-plugin-collection/plugins/step-ca/README.adoc index d08e1dd2..6fe8354d 100644 --- a/asdf-plugin-collection/plugins/step-ca/README.adoc +++ b/asdf-plugin-collection/plugins/step-ca/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-step-ca -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-step-ca-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-step-ca-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-step-ca-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-step-ca-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://smallstep.com/certificates[step-ca]. -**All repos with foreign function interfaces MUST follow this standard:** +Private CA. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add step-ca https://github.com/hyperpolymath/asdf-step-ca-plugin.git +---- -=== Web Projects +step-ca: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all step-ca -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install step-ca latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global step-ca latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now step-ca commands are available +step-ca --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list step-ca -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local step-ca -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall step-ca ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/step-ca/README.md b/asdf-plugin-collection/plugins/step-ca/README.md deleted file mode 100644 index b7069748..00000000 --- a/asdf-plugin-collection/plugins/step-ca/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-step-ca - -[![Build](https://github.com/hyperpolymath/asdf-step-ca-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-step-ca-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-step-ca-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-step-ca-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [step-ca](https://smallstep.com/certificates). - -Private CA. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add step-ca https://github.com/hyperpolymath/asdf-step-ca-plugin.git -``` - -step-ca: - -```bash -# Show all installable versions -asdf list-all step-ca - -# Install specific version -asdf install step-ca latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global step-ca latest - -# Now step-ca commands are available -step-ca --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list step-ca - -# Set local version for current directory -asdf local step-ca - -# Uninstall a version -asdf uninstall step-ca -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/step-ca/SECURITY.adoc b/asdf-plugin-collection/plugins/step-ca/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/step-ca/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/step-ca/SECURITY.md b/asdf-plugin-collection/plugins/step-ca/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/step-ca/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/surrealdb/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/surrealdb/ABI-FFI-README.adoc new file mode 100644 index 00000000..193bfa2a --- /dev/null +++ b/asdf-plugin-collection/plugins/surrealdb/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== SURREALDB ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/surrealdb.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libsurrealdb.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +surrealdb/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── surrealdb.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── surrealdb.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/surrealdb.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "surrealdb.h" + +int main() { + void* handle = surrealdb_init(); + if (!handle) return 1; + + int result = surrealdb_process(handle, 42); + if (result != 0) { + const char* err = surrealdb_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + surrealdb_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lsurrealdb -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import SURREALDB.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "surrealdb")] +extern "C" { + fn surrealdb_init() -> *mut std::ffi::c_void; + fn surrealdb_free(handle: *mut std::ffi::c_void); + fn surrealdb_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = surrealdb_init(); + assert!(!handle.is_null()); + + let result = surrealdb_process(handle, 42); + assert_eq!(result, 0); + + surrealdb_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libsurrealdb = "libsurrealdb" + +function init() + handle = ccall((:surrealdb_init, libsurrealdb), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:surrealdb_process, libsurrealdb), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:surrealdb_free, libsurrealdb), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/surrealdb.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/surrealdb/ABI-FFI-README.md b/asdf-plugin-collection/plugins/surrealdb/ABI-FFI-README.md deleted file mode 100644 index 49f768ff..00000000 --- a/asdf-plugin-collection/plugins/surrealdb/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# SURREALDB ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/surrealdb.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libsurrealdb.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -surrealdb/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── surrealdb.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── surrealdb.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/surrealdb.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "surrealdb.h" - -int main() { - void* handle = surrealdb_init(); - if (!handle) return 1; - - int result = surrealdb_process(handle, 42); - if (result != 0) { - const char* err = surrealdb_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - surrealdb_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lsurrealdb -L./zig-out/lib -``` - -### From Idris2 - -```idris -import SURREALDB.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "surrealdb")] -extern "C" { - fn surrealdb_init() -> *mut std::ffi::c_void; - fn surrealdb_free(handle: *mut std::ffi::c_void); - fn surrealdb_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = surrealdb_init(); - assert!(!handle.is_null()); - - let result = surrealdb_process(handle, 42); - assert_eq!(result, 0); - - surrealdb_free(handle); - } -} -``` - -### From Julia - -```julia -const libsurrealdb = "libsurrealdb" - -function init() - handle = ccall((:surrealdb_init, libsurrealdb), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:surrealdb_process, libsurrealdb), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:surrealdb_free, libsurrealdb), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/surrealdb.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/surrealdb/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/surrealdb/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/surrealdb/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/surrealdb/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/surrealdb/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/surrealdb/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/surrealdb/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/surrealdb/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/surrealdb/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/surrealdb/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/surrealdb/CONTRIBUTING.md b/asdf-plugin-collection/plugins/surrealdb/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/surrealdb/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/surrealdb/README.adoc b/asdf-plugin-collection/plugins/surrealdb/README.adoc index d08e1dd2..c2f57df6 100644 --- a/asdf-plugin-collection/plugins/surrealdb/README.adoc +++ b/asdf-plugin-collection/plugins/surrealdb/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-surrealdb -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-surrealdb-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-surrealdb-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-surrealdb-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-surrealdb-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://surrealdb.com[SurrealDB]. -**All repos with foreign function interfaces MUST follow this standard:** +Multi-model database. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add surrealdb https://github.com/hyperpolymath/asdf-surrealdb-plugin.git +---- -=== Web Projects +surrealdb: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all surrealdb -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install surrealdb latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global surrealdb latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now surrealdb commands are available +surrealdb --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list surrealdb -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local surrealdb -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall surrealdb ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/surrealdb/README.md b/asdf-plugin-collection/plugins/surrealdb/README.md deleted file mode 100644 index 4f493d5e..00000000 --- a/asdf-plugin-collection/plugins/surrealdb/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-surrealdb - -[![Build](https://github.com/hyperpolymath/asdf-surrealdb-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-surrealdb-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-surrealdb-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-surrealdb-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [SurrealDB](https://surrealdb.com). - -Multi-model database. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add surrealdb https://github.com/hyperpolymath/asdf-surrealdb-plugin.git -``` - -surrealdb: - -```bash -# Show all installable versions -asdf list-all surrealdb - -# Install specific version -asdf install surrealdb latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global surrealdb latest - -# Now surrealdb commands are available -surrealdb --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list surrealdb - -# Set local version for current directory -asdf local surrealdb - -# Uninstall a version -asdf uninstall surrealdb -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/surrealdb/SECURITY.adoc b/asdf-plugin-collection/plugins/surrealdb/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/surrealdb/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/surrealdb/SECURITY.md b/asdf-plugin-collection/plugins/surrealdb/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/surrealdb/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/syft/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/syft/ABI-FFI-README.adoc new file mode 100644 index 00000000..4bb11341 --- /dev/null +++ b/asdf-plugin-collection/plugins/syft/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== SYFT ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/syft.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libsyft.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +syft/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── syft.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── syft.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/syft.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "syft.h" + +int main() { + void* handle = syft_init(); + if (!handle) return 1; + + int result = syft_process(handle, 42); + if (result != 0) { + const char* err = syft_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + syft_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lsyft -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import SYFT.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "syft")] +extern "C" { + fn syft_init() -> *mut std::ffi::c_void; + fn syft_free(handle: *mut std::ffi::c_void); + fn syft_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = syft_init(); + assert!(!handle.is_null()); + + let result = syft_process(handle, 42); + assert_eq!(result, 0); + + syft_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libsyft = "libsyft" + +function init() + handle = ccall((:syft_init, libsyft), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:syft_process, libsyft), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:syft_free, libsyft), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/syft.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/syft/ABI-FFI-README.md b/asdf-plugin-collection/plugins/syft/ABI-FFI-README.md deleted file mode 100644 index 8cebba02..00000000 --- a/asdf-plugin-collection/plugins/syft/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# SYFT ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/syft.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libsyft.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -syft/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── syft.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── syft.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/syft.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "syft.h" - -int main() { - void* handle = syft_init(); - if (!handle) return 1; - - int result = syft_process(handle, 42); - if (result != 0) { - const char* err = syft_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - syft_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lsyft -L./zig-out/lib -``` - -### From Idris2 - -```idris -import SYFT.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "syft")] -extern "C" { - fn syft_init() -> *mut std::ffi::c_void; - fn syft_free(handle: *mut std::ffi::c_void); - fn syft_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = syft_init(); - assert!(!handle.is_null()); - - let result = syft_process(handle, 42); - assert_eq!(result, 0); - - syft_free(handle); - } -} -``` - -### From Julia - -```julia -const libsyft = "libsyft" - -function init() - handle = ccall((:syft_init, libsyft), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:syft_process, libsyft), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:syft_free, libsyft), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/syft.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/syft/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/syft/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/syft/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/syft/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/syft/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/syft/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/syft/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/syft/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/syft/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/syft/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/syft/CONTRIBUTING.md b/asdf-plugin-collection/plugins/syft/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/syft/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/syft/README.adoc b/asdf-plugin-collection/plugins/syft/README.adoc index d08e1dd2..7be1d677 100644 --- a/asdf-plugin-collection/plugins/syft/README.adoc +++ b/asdf-plugin-collection/plugins/syft/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-syft -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-syft-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-syft-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-syft-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-syft-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://anchore.com/syft[Syft]. -**All repos with foreign function interfaces MUST follow this standard:** +SBOM generator. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add syft https://github.com/hyperpolymath/asdf-syft-plugin.git +---- -=== Web Projects +syft: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all syft -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install syft latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global syft latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now syft commands are available +syft --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list syft -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local syft -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall syft ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/syft/README.md b/asdf-plugin-collection/plugins/syft/README.md deleted file mode 100644 index 3edd1438..00000000 --- a/asdf-plugin-collection/plugins/syft/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-syft - -[![Build](https://github.com/hyperpolymath/asdf-syft-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-syft-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-syft-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-syft-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Syft](https://anchore.com/syft). - -SBOM generator. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add syft https://github.com/hyperpolymath/asdf-syft-plugin.git -``` - -syft: - -```bash -# Show all installable versions -asdf list-all syft - -# Install specific version -asdf install syft latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global syft latest - -# Now syft commands are available -syft --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list syft - -# Set local version for current directory -asdf local syft - -# Uninstall a version -asdf uninstall syft -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/syft/SECURITY.adoc b/asdf-plugin-collection/plugins/syft/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/syft/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/syft/SECURITY.md b/asdf-plugin-collection/plugins/syft/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/syft/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/taplo/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/taplo/ABI-FFI-README.adoc new file mode 100644 index 00000000..3c49729d --- /dev/null +++ b/asdf-plugin-collection/plugins/taplo/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== TAPLO ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/taplo.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libtaplo.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +taplo/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── taplo.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── taplo.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/taplo.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "taplo.h" + +int main() { + void* handle = taplo_init(); + if (!handle) return 1; + + int result = taplo_process(handle, 42); + if (result != 0) { + const char* err = taplo_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + taplo_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -ltaplo -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import TAPLO.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "taplo")] +extern "C" { + fn taplo_init() -> *mut std::ffi::c_void; + fn taplo_free(handle: *mut std::ffi::c_void); + fn taplo_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = taplo_init(); + assert!(!handle.is_null()); + + let result = taplo_process(handle, 42); + assert_eq!(result, 0); + + taplo_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libtaplo = "libtaplo" + +function init() + handle = ccall((:taplo_init, libtaplo), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:taplo_process, libtaplo), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:taplo_free, libtaplo), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/taplo.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/taplo/ABI-FFI-README.md b/asdf-plugin-collection/plugins/taplo/ABI-FFI-README.md deleted file mode 100644 index 121d0824..00000000 --- a/asdf-plugin-collection/plugins/taplo/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# TAPLO ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/taplo.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libtaplo.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -taplo/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── taplo.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── taplo.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/taplo.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "taplo.h" - -int main() { - void* handle = taplo_init(); - if (!handle) return 1; - - int result = taplo_process(handle, 42); - if (result != 0) { - const char* err = taplo_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - taplo_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -ltaplo -L./zig-out/lib -``` - -### From Idris2 - -```idris -import TAPLO.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "taplo")] -extern "C" { - fn taplo_init() -> *mut std::ffi::c_void; - fn taplo_free(handle: *mut std::ffi::c_void); - fn taplo_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = taplo_init(); - assert!(!handle.is_null()); - - let result = taplo_process(handle, 42); - assert_eq!(result, 0); - - taplo_free(handle); - } -} -``` - -### From Julia - -```julia -const libtaplo = "libtaplo" - -function init() - handle = ccall((:taplo_init, libtaplo), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:taplo_process, libtaplo), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:taplo_free, libtaplo), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/taplo.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/taplo/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/taplo/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/taplo/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/taplo/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/taplo/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/taplo/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/taplo/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/taplo/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/taplo/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/taplo/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/taplo/CONTRIBUTING.md b/asdf-plugin-collection/plugins/taplo/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/taplo/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/taplo/README.adoc b/asdf-plugin-collection/plugins/taplo/README.adoc index d08e1dd2..4eb4acb2 100644 --- a/asdf-plugin-collection/plugins/taplo/README.adoc +++ b/asdf-plugin-collection/plugins/taplo/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-taplo -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-taplo-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-taplo-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-taplo-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-taplo-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://taplo.tamasfe.dev[Taplo]. -**All repos with foreign function interfaces MUST follow this standard:** +TOML toolkit. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add taplo https://github.com/hyperpolymath/asdf-taplo-plugin.git +---- -=== Web Projects +taplo: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all taplo -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install taplo latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global taplo latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now taplo commands are available +taplo --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list taplo -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local taplo -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall taplo ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/taplo/README.md b/asdf-plugin-collection/plugins/taplo/README.md deleted file mode 100644 index 68239dab..00000000 --- a/asdf-plugin-collection/plugins/taplo/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-taplo - -[![Build](https://github.com/hyperpolymath/asdf-taplo-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-taplo-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-taplo-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-taplo-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Taplo](https://taplo.tamasfe.dev). - -TOML toolkit. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add taplo https://github.com/hyperpolymath/asdf-taplo-plugin.git -``` - -taplo: - -```bash -# Show all installable versions -asdf list-all taplo - -# Install specific version -asdf install taplo latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global taplo latest - -# Now taplo commands are available -taplo --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list taplo - -# Set local version for current directory -asdf local taplo - -# Uninstall a version -asdf uninstall taplo -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/taplo/SECURITY.adoc b/asdf-plugin-collection/plugins/taplo/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/taplo/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/taplo/SECURITY.md b/asdf-plugin-collection/plugins/taplo/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/taplo/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/trivy/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/trivy/ABI-FFI-README.adoc new file mode 100644 index 00000000..291621ba --- /dev/null +++ b/asdf-plugin-collection/plugins/trivy/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== TRIVY ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/trivy.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libtrivy.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +trivy/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── trivy.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── trivy.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/trivy.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "trivy.h" + +int main() { + void* handle = trivy_init(); + if (!handle) return 1; + + int result = trivy_process(handle, 42); + if (result != 0) { + const char* err = trivy_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + trivy_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -ltrivy -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import TRIVY.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "trivy")] +extern "C" { + fn trivy_init() -> *mut std::ffi::c_void; + fn trivy_free(handle: *mut std::ffi::c_void); + fn trivy_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = trivy_init(); + assert!(!handle.is_null()); + + let result = trivy_process(handle, 42); + assert_eq!(result, 0); + + trivy_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libtrivy = "libtrivy" + +function init() + handle = ccall((:trivy_init, libtrivy), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:trivy_process, libtrivy), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:trivy_free, libtrivy), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/trivy.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/trivy/ABI-FFI-README.md b/asdf-plugin-collection/plugins/trivy/ABI-FFI-README.md deleted file mode 100644 index 3c2bf6e4..00000000 --- a/asdf-plugin-collection/plugins/trivy/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# TRIVY ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/trivy.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libtrivy.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -trivy/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── trivy.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── trivy.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/trivy.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "trivy.h" - -int main() { - void* handle = trivy_init(); - if (!handle) return 1; - - int result = trivy_process(handle, 42); - if (result != 0) { - const char* err = trivy_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - trivy_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -ltrivy -L./zig-out/lib -``` - -### From Idris2 - -```idris -import TRIVY.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "trivy")] -extern "C" { - fn trivy_init() -> *mut std::ffi::c_void; - fn trivy_free(handle: *mut std::ffi::c_void); - fn trivy_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = trivy_init(); - assert!(!handle.is_null()); - - let result = trivy_process(handle, 42); - assert_eq!(result, 0); - - trivy_free(handle); - } -} -``` - -### From Julia - -```julia -const libtrivy = "libtrivy" - -function init() - handle = ccall((:trivy_init, libtrivy), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:trivy_process, libtrivy), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:trivy_free, libtrivy), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/trivy.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/trivy/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/trivy/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/trivy/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/trivy/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/trivy/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/trivy/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/trivy/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/trivy/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/trivy/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/trivy/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/trivy/CONTRIBUTING.md b/asdf-plugin-collection/plugins/trivy/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/trivy/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/trivy/README.adoc b/asdf-plugin-collection/plugins/trivy/README.adoc index d08e1dd2..ec6dab41 100644 --- a/asdf-plugin-collection/plugins/trivy/README.adoc +++ b/asdf-plugin-collection/plugins/trivy/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-trivy -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-trivy-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-trivy-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-trivy-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-trivy-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://trivy.dev[Trivy]. -**All repos with foreign function interfaces MUST follow this standard:** +Security scanner. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add trivy https://github.com/hyperpolymath/asdf-trivy-plugin.git +---- -=== Web Projects +trivy: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all trivy -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install trivy latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global trivy latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now trivy commands are available +trivy --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list trivy -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local trivy -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall trivy ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/trivy/README.md b/asdf-plugin-collection/plugins/trivy/README.md deleted file mode 100644 index 4084e013..00000000 --- a/asdf-plugin-collection/plugins/trivy/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-trivy - -[![Build](https://github.com/hyperpolymath/asdf-trivy-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-trivy-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-trivy-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-trivy-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Trivy](https://trivy.dev). - -Security scanner. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add trivy https://github.com/hyperpolymath/asdf-trivy-plugin.git -``` - -trivy: - -```bash -# Show all installable versions -asdf list-all trivy - -# Install specific version -asdf install trivy latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global trivy latest - -# Now trivy commands are available -trivy --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list trivy - -# Set local version for current directory -asdf local trivy - -# Uninstall a version -asdf uninstall trivy -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/trivy/SECURITY.adoc b/asdf-plugin-collection/plugins/trivy/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/trivy/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/trivy/SECURITY.md b/asdf-plugin-collection/plugins/trivy/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/trivy/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/ui/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/ui/ABI-FFI-README.adoc new file mode 100644 index 00000000..62673536 --- /dev/null +++ b/asdf-plugin-collection/plugins/ui/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== UI ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/ui.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libui.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +ui/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── ui.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── ui.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/ui.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "ui.h" + +int main() { + void* handle = ui_init(); + if (!handle) return 1; + + int result = ui_process(handle, 42); + if (result != 0) { + const char* err = ui_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + ui_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lui -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import UI.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "ui")] +extern "C" { + fn ui_init() -> *mut std::ffi::c_void; + fn ui_free(handle: *mut std::ffi::c_void); + fn ui_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = ui_init(); + assert!(!handle.is_null()); + + let result = ui_process(handle, 42); + assert_eq!(result, 0); + + ui_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libui = "libui" + +function init() + handle = ccall((:ui_init, libui), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:ui_process, libui), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:ui_free, libui), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/ui.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/ui/ABI-FFI-README.md b/asdf-plugin-collection/plugins/ui/ABI-FFI-README.md deleted file mode 100644 index 42a9d25c..00000000 --- a/asdf-plugin-collection/plugins/ui/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# UI ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/ui.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libui.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -ui/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── ui.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── ui.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/ui.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "ui.h" - -int main() { - void* handle = ui_init(); - if (!handle) return 1; - - int result = ui_process(handle, 42); - if (result != 0) { - const char* err = ui_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - ui_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lui -L./zig-out/lib -``` - -### From Idris2 - -```idris -import UI.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "ui")] -extern "C" { - fn ui_init() -> *mut std::ffi::c_void; - fn ui_free(handle: *mut std::ffi::c_void); - fn ui_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = ui_init(); - assert!(!handle.is_null()); - - let result = ui_process(handle, 42); - assert_eq!(result, 0); - - ui_free(handle); - } -} -``` - -### From Julia - -```julia -const libui = "libui" - -function init() - handle = ccall((:ui_init, libui), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:ui_process, libui), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:ui_free, libui), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/ui.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/ui/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/ui/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/ui/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/ui/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/ui/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/ui/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/ui/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/ui/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/ui/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/ui/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/ui/CONTRIBUTING.md b/asdf-plugin-collection/plugins/ui/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/ui/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/ui/README.adoc b/asdf-plugin-collection/plugins/ui/README.adoc index 8c19e39d..f52f4ce3 100644 --- a/asdf-plugin-collection/plugins/ui/README.adoc +++ b/asdf-plugin-collection/plugins/ui/README.adoc @@ -1,101 +1,53 @@ -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] -image:https://img.shields.io/badge/Philosophy-Palimpsest-indigo.svg[Palimpsest,link="https://github.com/hyperpolymath/palimpsest-license"] +== asdf-ui-plugin +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] +image:https://img.shields.io/badge/Philosophy-Palimpsest-indigo.svg[Palimpsest,link="`https://github.com/hyperpolymath/palimpsest-license`"] -// SPDX-License-Identifier: CC-BY-SA-4.0 -= asdf-ui-plugin +Visual user interface for the https://asdf-vm.com[asdf] version manager +ecosystem. -:toc: macro -:toc-title: Contents -:toclevels: 2 +=== Status -A fully functional **asdf plugin** providing a terminal user interface for managing asdf plugins and versions. +____ +*Note:* This repository is currently a placeholder. Implementation is +pending. +____ -== Status +=== Overview -[NOTE] -==== -**Implementation Complete** - Core plugin functionality is fully working. -==== +`+asdf-ui-plugin+` will provide a graphical interface for managing asdf +plugins and tool versions: -== Features +* *Plugin browser* - Visual discovery of available plugins +* *Version manager* - GUI for installing/switching versions +* *Status dashboard* - Overview of installed tools +* *Update notifications* - Track available updates -* **Version Management**: List, install, and switch between versions -* **Interactive TUI**: Terminal user interface for easy navigation -* **Dashboard View**: Overview of installed plugins and versions -* **Version Selector**: Interactive picker for version switching +=== Technology Stack -== Installation +* *UI Framework*: Tauri 2.0+ (Rust backend + web frontend) +* *Frontend*: AffineScript (type-safe JavaScript) +* *Styling*: TailwindCSS -[source,bash] ----- -asdf plugin add asdf-ui https://github.com/hyperpolymath/asdf-ui-plugin.git -asdf install asdf-ui 1.0.0 -asdf global asdf-ui 1.0.0 ----- +=== Related Projects -== Usage - -[source,bash] ----- -# Launch interactive TUI -asdf-ui - -# Show plugin dashboard -asdf-ui dashboard - -# Interactive version selector -asdf-ui versions - -# Display help -asdf-ui help ----- - -== Components - -[cols="1,3"] +[width="100%",cols="40%,60%",options="header",] |=== -| Component | Description - -| `bin/list-all` -| Lists all available versions - -| `bin/download` -| Downloads specified version +|Project |Relationship +|https://github.com/hyperpolymath/asdf-metaiconic-plugin[asdf-metaiconic-plugin] +|Metadata provider -| `bin/install` -| Installs version and creates asdf-ui binary - -| `lib/utils.bash` -| Core utility functions and TUI implementation - -| `.github/workflows/ci.yml` -| Continuous integration with ShellCheck - -| `.github/workflows/mirror.yml` -| Hub-and-spoke mirroring to GitLab, Codeberg, Bitbucket - -| `.github/workflows/instant-sync.yml` -| Automatic forge propagation on push/release - -| `.claude/CLAUDE.md` -| Hyperpolymath development standards (language policy) +|https://github.com/hyperpolymath/asdf-security-plugin[asdf-security-plugin] +|Security layer |=== -See link:ROADMAP.adoc[ROADMAP.adoc] for development history and future plans. - -== Development Standards - -This project follows the **Hyperpolymath Language Policy**: - -* *Primary*: AffineScript, Rust, Deno -* *Mobile*: Tauri 2.0+ or Dioxus (no Kotlin/Swift) -* *Backend*: Gleam (BEAM or JS target) -* *Config*: Nickel, Guile Scheme -* *Package Management*: Guix (primary), Guix (fallback) +=== License -See `.claude/CLAUDE.md` for full policy details. +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -== License +''''' -MPL-2.0 +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/ui/README.md b/asdf-plugin-collection/plugins/ui/README.md deleted file mode 100644 index 77018b32..00000000 --- a/asdf-plugin-collection/plugins/ui/README.md +++ /dev/null @@ -1,40 +0,0 @@ -# asdf-ui-plugin - -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] -image:https://img.shields.io/badge/Philosophy-Palimpsest-indigo.svg[Palimpsest,link="https://github.com/hyperpolymath/palimpsest-license"] - -Visual user interface for the [asdf](https://asdf-vm.com) version manager ecosystem. - -## Status - -> **Note:** This repository is currently a placeholder. Implementation is pending. - -## Overview - -`asdf-ui-plugin` will provide a graphical interface for managing asdf plugins and tool versions: - -- **Plugin browser** - Visual discovery of available plugins -- **Version manager** - GUI for installing/switching versions -- **Status dashboard** - Overview of installed tools -- **Update notifications** - Track available updates - -## Technology Stack - -- **UI Framework**: Tauri 2.0+ (Rust backend + web frontend) -- **Frontend**: AffineScript (type-safe JavaScript) -- **Styling**: TailwindCSS - -## Related Projects - -| Project | Relationship | -|---------|--------------| -| [asdf-metaiconic-plugin](https://github.com/hyperpolymath/asdf-metaiconic-plugin) | Metadata provider | -| [asdf-security-plugin](https://github.com/hyperpolymath/asdf-security-plugin) | Security layer | - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/ui/SECURITY.adoc b/asdf-plugin-collection/plugins/ui/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/ui/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/ui/SECURITY.md b/asdf-plugin-collection/plugins/ui/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/ui/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/varnish/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/varnish/ABI-FFI-README.adoc new file mode 100644 index 00000000..be2b48d7 --- /dev/null +++ b/asdf-plugin-collection/plugins/varnish/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== VARNISH ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/varnish.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libvarnish.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +varnish/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── varnish.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── varnish.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/varnish.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "varnish.h" + +int main() { + void* handle = varnish_init(); + if (!handle) return 1; + + int result = varnish_process(handle, 42); + if (result != 0) { + const char* err = varnish_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + varnish_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lvarnish -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import VARNISH.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "varnish")] +extern "C" { + fn varnish_init() -> *mut std::ffi::c_void; + fn varnish_free(handle: *mut std::ffi::c_void); + fn varnish_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = varnish_init(); + assert!(!handle.is_null()); + + let result = varnish_process(handle, 42); + assert_eq!(result, 0); + + varnish_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libvarnish = "libvarnish" + +function init() + handle = ccall((:varnish_init, libvarnish), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:varnish_process, libvarnish), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:varnish_free, libvarnish), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/varnish.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/varnish/ABI-FFI-README.md b/asdf-plugin-collection/plugins/varnish/ABI-FFI-README.md deleted file mode 100644 index db34442f..00000000 --- a/asdf-plugin-collection/plugins/varnish/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# VARNISH ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/varnish.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libvarnish.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -varnish/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── varnish.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── varnish.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/varnish.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "varnish.h" - -int main() { - void* handle = varnish_init(); - if (!handle) return 1; - - int result = varnish_process(handle, 42); - if (result != 0) { - const char* err = varnish_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - varnish_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lvarnish -L./zig-out/lib -``` - -### From Idris2 - -```idris -import VARNISH.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "varnish")] -extern "C" { - fn varnish_init() -> *mut std::ffi::c_void; - fn varnish_free(handle: *mut std::ffi::c_void); - fn varnish_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = varnish_init(); - assert!(!handle.is_null()); - - let result = varnish_process(handle, 42); - assert_eq!(result, 0); - - varnish_free(handle); - } -} -``` - -### From Julia - -```julia -const libvarnish = "libvarnish" - -function init() - handle = ccall((:varnish_init, libvarnish), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:varnish_process, libvarnish), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:varnish_free, libvarnish), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/varnish.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/varnish/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/varnish/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/varnish/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/varnish/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/varnish/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/varnish/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/varnish/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/varnish/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/varnish/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/varnish/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/varnish/CONTRIBUTING.md b/asdf-plugin-collection/plugins/varnish/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/varnish/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/varnish/README.adoc b/asdf-plugin-collection/plugins/varnish/README.adoc index d08e1dd2..b2d14bf4 100644 --- a/asdf-plugin-collection/plugins/varnish/README.adoc +++ b/asdf-plugin-collection/plugins/varnish/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-varnish -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-varnish-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-varnish-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-varnish-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-varnish-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://varnish-cache.org[Varnish +Cache]. -**All repos with foreign function interfaces MUST follow this standard:** +HTTP accelerator. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add varnish https://github.com/hyperpolymath/asdf-varnish-plugin.git +---- -=== Web Projects +varnish: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all varnish -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install varnish latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global varnish latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now varnish commands are available +varnish --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list varnish -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local varnish -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall varnish ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/varnish/README.md b/asdf-plugin-collection/plugins/varnish/README.md deleted file mode 100644 index 4ee2b09b..00000000 --- a/asdf-plugin-collection/plugins/varnish/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-varnish - -[![Build](https://github.com/hyperpolymath/asdf-varnish-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-varnish-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-varnish-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-varnish-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Varnish Cache](https://varnish-cache.org). - -HTTP accelerator. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add varnish https://github.com/hyperpolymath/asdf-varnish-plugin.git -``` - -varnish: - -```bash -# Show all installable versions -asdf list-all varnish - -# Install specific version -asdf install varnish latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global varnish latest - -# Now varnish commands are available -varnish --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list varnish - -# Set local version for current directory -asdf local varnish - -# Uninstall a version -asdf uninstall varnish -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/varnish/SECURITY.adoc b/asdf-plugin-collection/plugins/varnish/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/varnish/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/varnish/SECURITY.md b/asdf-plugin-collection/plugins/varnish/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/varnish/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/virtuoso/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/virtuoso/ABI-FFI-README.adoc new file mode 100644 index 00000000..c71acab7 --- /dev/null +++ b/asdf-plugin-collection/plugins/virtuoso/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== VIRTUOSO ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/virtuoso.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libvirtuoso.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +virtuoso/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── virtuoso.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── virtuoso.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/virtuoso.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "virtuoso.h" + +int main() { + void* handle = virtuoso_init(); + if (!handle) return 1; + + int result = virtuoso_process(handle, 42); + if (result != 0) { + const char* err = virtuoso_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + virtuoso_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lvirtuoso -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import VIRTUOSO.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "virtuoso")] +extern "C" { + fn virtuoso_init() -> *mut std::ffi::c_void; + fn virtuoso_free(handle: *mut std::ffi::c_void); + fn virtuoso_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = virtuoso_init(); + assert!(!handle.is_null()); + + let result = virtuoso_process(handle, 42); + assert_eq!(result, 0); + + virtuoso_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libvirtuoso = "libvirtuoso" + +function init() + handle = ccall((:virtuoso_init, libvirtuoso), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:virtuoso_process, libvirtuoso), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:virtuoso_free, libvirtuoso), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/virtuoso.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/virtuoso/ABI-FFI-README.md b/asdf-plugin-collection/plugins/virtuoso/ABI-FFI-README.md deleted file mode 100644 index 4753369a..00000000 --- a/asdf-plugin-collection/plugins/virtuoso/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# VIRTUOSO ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/virtuoso.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libvirtuoso.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -virtuoso/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── virtuoso.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── virtuoso.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/virtuoso.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "virtuoso.h" - -int main() { - void* handle = virtuoso_init(); - if (!handle) return 1; - - int result = virtuoso_process(handle, 42); - if (result != 0) { - const char* err = virtuoso_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - virtuoso_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lvirtuoso -L./zig-out/lib -``` - -### From Idris2 - -```idris -import VIRTUOSO.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "virtuoso")] -extern "C" { - fn virtuoso_init() -> *mut std::ffi::c_void; - fn virtuoso_free(handle: *mut std::ffi::c_void); - fn virtuoso_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = virtuoso_init(); - assert!(!handle.is_null()); - - let result = virtuoso_process(handle, 42); - assert_eq!(result, 0); - - virtuoso_free(handle); - } -} -``` - -### From Julia - -```julia -const libvirtuoso = "libvirtuoso" - -function init() - handle = ccall((:virtuoso_init, libvirtuoso), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:virtuoso_process, libvirtuoso), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:virtuoso_free, libvirtuoso), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/virtuoso.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/virtuoso/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/virtuoso/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/virtuoso/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/virtuoso/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/virtuoso/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/virtuoso/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/virtuoso/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/virtuoso/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/virtuoso/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/virtuoso/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/virtuoso/CONTRIBUTING.md b/asdf-plugin-collection/plugins/virtuoso/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/virtuoso/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/virtuoso/README.adoc b/asdf-plugin-collection/plugins/virtuoso/README.adoc index d08e1dd2..4644e8f3 100644 --- a/asdf-plugin-collection/plugins/virtuoso/README.adoc +++ b/asdf-plugin-collection/plugins/virtuoso/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-virtuoso -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-virtuoso-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-virtuoso-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-virtuoso-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-virtuoso-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://virtuoso.openlinksw.com[Virtuoso]. -**All repos with foreign function interfaces MUST follow this standard:** +RDF triple store. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add virtuoso https://github.com/hyperpolymath/asdf-virtuoso-plugin.git +---- -=== Web Projects +virtuoso: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all virtuoso -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install virtuoso latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global virtuoso latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now virtuoso commands are available +virtuoso --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list virtuoso -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local virtuoso -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall virtuoso ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/virtuoso/README.md b/asdf-plugin-collection/plugins/virtuoso/README.md deleted file mode 100644 index 211e1f63..00000000 --- a/asdf-plugin-collection/plugins/virtuoso/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-virtuoso - -[![Build](https://github.com/hyperpolymath/asdf-virtuoso-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-virtuoso-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-virtuoso-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-virtuoso-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Virtuoso](https://virtuoso.openlinksw.com). - -RDF triple store. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add virtuoso https://github.com/hyperpolymath/asdf-virtuoso-plugin.git -``` - -virtuoso: - -```bash -# Show all installable versions -asdf list-all virtuoso - -# Install specific version -asdf install virtuoso latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global virtuoso latest - -# Now virtuoso commands are available -virtuoso --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list virtuoso - -# Set local version for current directory -asdf local virtuoso - -# Uninstall a version -asdf uninstall virtuoso -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/virtuoso/SECURITY.adoc b/asdf-plugin-collection/plugins/virtuoso/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/virtuoso/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/virtuoso/SECURITY.md b/asdf-plugin-collection/plugins/virtuoso/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/virtuoso/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/vlang/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/vlang/ABI-FFI-README.adoc new file mode 100644 index 00000000..a21b7a8b --- /dev/null +++ b/asdf-plugin-collection/plugins/vlang/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== VLANG ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/vlang.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libvlang.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +vlang/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── vlang.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── vlang.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/vlang.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "vlang.h" + +int main() { + void* handle = vlang_init(); + if (!handle) return 1; + + int result = vlang_process(handle, 42); + if (result != 0) { + const char* err = vlang_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + vlang_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lvlang -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import VLANG.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "vlang")] +extern "C" { + fn vlang_init() -> *mut std::ffi::c_void; + fn vlang_free(handle: *mut std::ffi::c_void); + fn vlang_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = vlang_init(); + assert!(!handle.is_null()); + + let result = vlang_process(handle, 42); + assert_eq!(result, 0); + + vlang_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libvlang = "libvlang" + +function init() + handle = ccall((:vlang_init, libvlang), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:vlang_process, libvlang), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:vlang_free, libvlang), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/vlang.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/vlang/ABI-FFI-README.md b/asdf-plugin-collection/plugins/vlang/ABI-FFI-README.md deleted file mode 100644 index 2ce05e85..00000000 --- a/asdf-plugin-collection/plugins/vlang/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# VLANG ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/vlang.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libvlang.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -vlang/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── vlang.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── vlang.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/vlang.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "vlang.h" - -int main() { - void* handle = vlang_init(); - if (!handle) return 1; - - int result = vlang_process(handle, 42); - if (result != 0) { - const char* err = vlang_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - vlang_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lvlang -L./zig-out/lib -``` - -### From Idris2 - -```idris -import VLANG.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "vlang")] -extern "C" { - fn vlang_init() -> *mut std::ffi::c_void; - fn vlang_free(handle: *mut std::ffi::c_void); - fn vlang_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = vlang_init(); - assert!(!handle.is_null()); - - let result = vlang_process(handle, 42); - assert_eq!(result, 0); - - vlang_free(handle); - } -} -``` - -### From Julia - -```julia -const libvlang = "libvlang" - -function init() - handle = ccall((:vlang_init, libvlang), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:vlang_process, libvlang), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:vlang_free, libvlang), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/vlang.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/vlang/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/vlang/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/vlang/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/vlang/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/vlang/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/vlang/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/vlang/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/vlang/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/vlang/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/vlang/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/vlang/CONTRIBUTING.md b/asdf-plugin-collection/plugins/vlang/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/vlang/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/vlang/README.adoc b/asdf-plugin-collection/plugins/vlang/README.adoc index d08e1dd2..e0d2a18f 100644 --- a/asdf-plugin-collection/plugins/vlang/README.adoc +++ b/asdf-plugin-collection/plugins/vlang/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-vlang -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-vlang-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-vlang-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-vlang-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-vlang-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://vlang.io[V]. -**All repos with foreign function interfaces MUST follow this standard:** +Simple fast language. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add vlang https://github.com/hyperpolymath/asdf-vlang-plugin.git +---- -=== Web Projects +vlang: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all vlang -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install vlang latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global vlang latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now vlang commands are available +vlang --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list vlang -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local vlang -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall vlang ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/vlang/README.md b/asdf-plugin-collection/plugins/vlang/README.md deleted file mode 100644 index 06f2397c..00000000 --- a/asdf-plugin-collection/plugins/vlang/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-vlang - -[![Build](https://github.com/hyperpolymath/asdf-vlang-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-vlang-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-vlang-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-vlang-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [V](https://vlang.io). - -Simple fast language. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add vlang https://github.com/hyperpolymath/asdf-vlang-plugin.git -``` - -vlang: - -```bash -# Show all installable versions -asdf list-all vlang - -# Install specific version -asdf install vlang latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global vlang latest - -# Now vlang commands are available -vlang --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list vlang - -# Set local version for current directory -asdf local vlang - -# Uninstall a version -asdf uninstall vlang -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/vlang/SECURITY.adoc b/asdf-plugin-collection/plugins/vlang/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/vlang/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/vlang/SECURITY.md b/asdf-plugin-collection/plugins/vlang/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/vlang/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/yj/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/yj/ABI-FFI-README.adoc new file mode 100644 index 00000000..af3fca8a --- /dev/null +++ b/asdf-plugin-collection/plugins/yj/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== YJ ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/yj.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libyj.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +yj/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── yj.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── yj.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/yj.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "yj.h" + +int main() { + void* handle = yj_init(); + if (!handle) return 1; + + int result = yj_process(handle, 42); + if (result != 0) { + const char* err = yj_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + yj_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lyj -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import YJ.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "yj")] +extern "C" { + fn yj_init() -> *mut std::ffi::c_void; + fn yj_free(handle: *mut std::ffi::c_void); + fn yj_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = yj_init(); + assert!(!handle.is_null()); + + let result = yj_process(handle, 42); + assert_eq!(result, 0); + + yj_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libyj = "libyj" + +function init() + handle = ccall((:yj_init, libyj), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:yj_process, libyj), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:yj_free, libyj), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/yj.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/yj/ABI-FFI-README.md b/asdf-plugin-collection/plugins/yj/ABI-FFI-README.md deleted file mode 100644 index bd5df5c7..00000000 --- a/asdf-plugin-collection/plugins/yj/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# YJ ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/yj.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libyj.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -yj/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── yj.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── yj.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/yj.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "yj.h" - -int main() { - void* handle = yj_init(); - if (!handle) return 1; - - int result = yj_process(handle, 42); - if (result != 0) { - const char* err = yj_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - yj_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lyj -L./zig-out/lib -``` - -### From Idris2 - -```idris -import YJ.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "yj")] -extern "C" { - fn yj_init() -> *mut std::ffi::c_void; - fn yj_free(handle: *mut std::ffi::c_void); - fn yj_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = yj_init(); - assert!(!handle.is_null()); - - let result = yj_process(handle, 42); - assert_eq!(result, 0); - - yj_free(handle); - } -} -``` - -### From Julia - -```julia -const libyj = "libyj" - -function init() - handle = ccall((:yj_init, libyj), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:yj_process, libyj), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:yj_free, libyj), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/yj.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/yj/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/yj/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/yj/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/yj/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/yj/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/yj/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/yj/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/yj/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/yj/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/yj/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/yj/CONTRIBUTING.md b/asdf-plugin-collection/plugins/yj/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/yj/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/yj/README.adoc b/asdf-plugin-collection/plugins/yj/README.adoc index d08e1dd2..692d1bf4 100644 --- a/asdf-plugin-collection/plugins/yj/README.adoc +++ b/asdf-plugin-collection/plugins/yj/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-yj -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-yj-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-yj-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-yj-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-yj-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://github.com/sclevine/yj[yj]. -**All repos with foreign function interfaces MUST follow this standard:** +YAML/JSON/TOML converter. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add yj https://github.com/hyperpolymath/asdf-yj-plugin.git +---- -=== Web Projects +yj: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all yj -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install yj latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global yj latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now yj commands are available +yj --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list yj -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local yj -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall yj ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/yj/README.md b/asdf-plugin-collection/plugins/yj/README.md deleted file mode 100644 index a99453a7..00000000 --- a/asdf-plugin-collection/plugins/yj/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-yj - -[![Build](https://github.com/hyperpolymath/asdf-yj-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-yj-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-yj-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-yj-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [yj](https://github.com/sclevine/yj). - -YAML/JSON/TOML converter. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add yj https://github.com/hyperpolymath/asdf-yj-plugin.git -``` - -yj: - -```bash -# Show all installable versions -asdf list-all yj - -# Install specific version -asdf install yj latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global yj latest - -# Now yj commands are available -yj --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list yj - -# Set local version for current directory -asdf local yj - -# Uninstall a version -asdf uninstall yj -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/yj/SECURITY.adoc b/asdf-plugin-collection/plugins/yj/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/yj/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/yj/SECURITY.md b/asdf-plugin-collection/plugins/yj/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/yj/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/yq/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/yq/ABI-FFI-README.adoc new file mode 100644 index 00000000..3aec672a --- /dev/null +++ b/asdf-plugin-collection/plugins/yq/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== YQ ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/yq.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libyq.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +yq/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── yq.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── yq.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/yq.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "yq.h" + +int main() { + void* handle = yq_init(); + if (!handle) return 1; + + int result = yq_process(handle, 42); + if (result != 0) { + const char* err = yq_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + yq_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lyq -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import YQ.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "yq")] +extern "C" { + fn yq_init() -> *mut std::ffi::c_void; + fn yq_free(handle: *mut std::ffi::c_void); + fn yq_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = yq_init(); + assert!(!handle.is_null()); + + let result = yq_process(handle, 42); + assert_eq!(result, 0); + + yq_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libyq = "libyq" + +function init() + handle = ccall((:yq_init, libyq), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:yq_process, libyq), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:yq_free, libyq), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/yq.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/yq/ABI-FFI-README.md b/asdf-plugin-collection/plugins/yq/ABI-FFI-README.md deleted file mode 100644 index 1789a0ea..00000000 --- a/asdf-plugin-collection/plugins/yq/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# YQ ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/yq.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libyq.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -yq/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── yq.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── yq.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/yq.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "yq.h" - -int main() { - void* handle = yq_init(); - if (!handle) return 1; - - int result = yq_process(handle, 42); - if (result != 0) { - const char* err = yq_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - yq_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lyq -L./zig-out/lib -``` - -### From Idris2 - -```idris -import YQ.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "yq")] -extern "C" { - fn yq_init() -> *mut std::ffi::c_void; - fn yq_free(handle: *mut std::ffi::c_void); - fn yq_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = yq_init(); - assert!(!handle.is_null()); - - let result = yq_process(handle, 42); - assert_eq!(result, 0); - - yq_free(handle); - } -} -``` - -### From Julia - -```julia -const libyq = "libyq" - -function init() - handle = ccall((:yq_init, libyq), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:yq_process, libyq), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:yq_free, libyq), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/yq.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/yq/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/yq/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/yq/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/yq/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/yq/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/yq/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/yq/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/yq/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/yq/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/yq/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/yq/CONTRIBUTING.md b/asdf-plugin-collection/plugins/yq/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/yq/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/yq/README.adoc b/asdf-plugin-collection/plugins/yq/README.adoc index d08e1dd2..0cc876bf 100644 --- a/asdf-plugin-collection/plugins/yq/README.adoc +++ b/asdf-plugin-collection/plugins/yq/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-yq -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-yq-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-yq-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-yq-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-yq-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://mikefarah.gitbook.io/yq[yq]. -**All repos with foreign function interfaces MUST follow this standard:** +YAML processor. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add yq https://github.com/hyperpolymath/asdf-yq-plugin.git +---- -=== Web Projects +yq: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all yq -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install yq latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global yq latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now yq commands are available +yq --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list yq -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local yq -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall yq ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/yq/README.md b/asdf-plugin-collection/plugins/yq/README.md deleted file mode 100644 index 32b85db9..00000000 --- a/asdf-plugin-collection/plugins/yq/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-yq - -[![Build](https://github.com/hyperpolymath/asdf-yq-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-yq-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-yq-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-yq-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [yq](https://mikefarah.gitbook.io/yq). - -YAML processor. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add yq https://github.com/hyperpolymath/asdf-yq-plugin.git -``` - -yq: - -```bash -# Show all installable versions -asdf list-all yq - -# Install specific version -asdf install yq latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global yq latest - -# Now yq commands are available -yq --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list yq - -# Set local version for current directory -asdf local yq - -# Uninstall a version -asdf uninstall yq -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/yq/SECURITY.adoc b/asdf-plugin-collection/plugins/yq/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/yq/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/yq/SECURITY.md b/asdf-plugin-collection/plugins/yq/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/yq/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/zig/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/zig/ABI-FFI-README.adoc new file mode 100644 index 00000000..a3b3b061 --- /dev/null +++ b/asdf-plugin-collection/plugins/zig/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== ZIG ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/zig.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libzig.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +zig/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── zig.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── zig.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/zig.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "zig.h" + +int main() { + void* handle = zig_init(); + if (!handle) return 1; + + int result = zig_process(handle, 42); + if (result != 0) { + const char* err = zig_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + zig_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lzig -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import ZIG.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "zig")] +extern "C" { + fn zig_init() -> *mut std::ffi::c_void; + fn zig_free(handle: *mut std::ffi::c_void); + fn zig_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = zig_init(); + assert!(!handle.is_null()); + + let result = zig_process(handle, 42); + assert_eq!(result, 0); + + zig_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libzig = "libzig" + +function init() + handle = ccall((:zig_init, libzig), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:zig_process, libzig), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:zig_free, libzig), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/zig.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/zig/ABI-FFI-README.md b/asdf-plugin-collection/plugins/zig/ABI-FFI-README.md deleted file mode 100644 index 32bf6cd4..00000000 --- a/asdf-plugin-collection/plugins/zig/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# ZIG ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/zig.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libzig.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -zig/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── zig.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── zig.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/zig.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "zig.h" - -int main() { - void* handle = zig_init(); - if (!handle) return 1; - - int result = zig_process(handle, 42); - if (result != 0) { - const char* err = zig_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - zig_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lzig -L./zig-out/lib -``` - -### From Idris2 - -```idris -import ZIG.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "zig")] -extern "C" { - fn zig_init() -> *mut std::ffi::c_void; - fn zig_free(handle: *mut std::ffi::c_void); - fn zig_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = zig_init(); - assert!(!handle.is_null()); - - let result = zig_process(handle, 42); - assert_eq!(result, 0); - - zig_free(handle); - } -} -``` - -### From Julia - -```julia -const libzig = "libzig" - -function init() - handle = ccall((:zig_init, libzig), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:zig_process, libzig), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:zig_free, libzig), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/zig.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/zig/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/zig/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..be3a3fca --- /dev/null +++ b/asdf-plugin-collection/plugins/zig/CODE_OF_CONDUCT.adoc @@ -0,0 +1,23 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We as members, contributors, and leaders pledge to make participation in +our community a harassment-free experience for everyone. + +=== Our Standards + +Examples of behavior that contributes to a positive environment: * Using +welcoming and inclusive language * Being respectful of differing +viewpoints and experiences * Gracefully accepting constructive criticism +* Focusing on what is best for the community + +=== Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may +be reported to the project maintainers. + +=== Attribution + +This Code of Conduct is adapted from the Contributor Covenant, version +2.1. diff --git a/asdf-plugin-collection/plugins/zig/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/zig/CODE_OF_CONDUCT.md deleted file mode 100644 index 7d02d33d..00000000 --- a/asdf-plugin-collection/plugins/zig/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,23 +0,0 @@ -# Contributor Covenant Code of Conduct - -## Our Pledge - -We as members, contributors, and leaders pledge to make participation in our -community a harassment-free experience for everyone. - -## Our Standards - -Examples of behavior that contributes to a positive environment: -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community - -## Enforcement - -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported to the project maintainers. - -## Attribution - -This Code of Conduct is adapted from the Contributor Covenant, version 2.1. diff --git a/asdf-plugin-collection/plugins/zig/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/zig/CONTRIBUTING.adoc index 5b225c9b..084ee525 100644 --- a/asdf-plugin-collection/plugins/zig/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/zig/CONTRIBUTING.adoc @@ -1,30 +1,109 @@ -= Contributing +== Clone the repository -Thank you for your interest in contributing! +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -== Quick Start +== Using Guix (recommended for reproducibility) -1. Fork the repository -2. Create a feature branch -3. Make your changes -4. Run tests: `asdf plugin test zig .` -5. Submit a pull request +guix develop -== Code Style +== Or using toolbox/distrobox -* Use ShellCheck for linting -* Follow existing code patterns -* Add SPDX headers to new files +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -== Testing +== Verify setup -Test your changes with: +just check # or: cargo check / mix compile / etc. just test # Run test +suite -[source,bash] ----- -asdf plugin test zig . --asdf-tool-version latest ----- +.... -== License +### Repository Structure +.... -Contributions are licensed under MPL-2.0. +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/zig/CONTRIBUTING.md b/asdf-plugin-collection/plugins/zig/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/zig/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/zig/SECURITY.adoc b/asdf-plugin-collection/plugins/zig/SECURITY.adoc new file mode 100644 index 00000000..7f2e3358 --- /dev/null +++ b/asdf-plugin-collection/plugins/zig/SECURITY.adoc @@ -0,0 +1,20 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|latest |:white_check_mark: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities via GitHub Security Advisories. + +[arabic] +. Go to the Security tab of this repository +. Click "`Report a vulnerability`" +. Provide details of the vulnerability + +We will respond within 48 hours and work with you to address the issue. diff --git a/asdf-plugin-collection/plugins/zig/SECURITY.md b/asdf-plugin-collection/plugins/zig/SECURITY.md deleted file mode 100644 index a791a890..00000000 --- a/asdf-plugin-collection/plugins/zig/SECURITY.md +++ /dev/null @@ -1,17 +0,0 @@ -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| latest | :white_check_mark: | - -## Reporting a Vulnerability - -Please report security vulnerabilities via GitHub Security Advisories. - -1. Go to the Security tab of this repository -2. Click "Report a vulnerability" -3. Provide details of the vulnerability - -We will respond within 48 hours and work with you to address the issue. diff --git a/asdf-plugin-collection/plugins/zola/ABI-FFI-README.adoc b/asdf-plugin-collection/plugins/zola/ABI-FFI-README.adoc new file mode 100644 index 00000000..f87c41f3 --- /dev/null +++ b/asdf-plugin-collection/plugins/zola/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== ZOLA ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/zola.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libzola.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +zola/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── zola.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── zola.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/zola.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "zola.h" + +int main() { + void* handle = zola_init(); + if (!handle) return 1; + + int result = zola_process(handle, 42); + if (result != 0) { + const char* err = zola_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + zola_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lzola -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import ZOLA.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "zola")] +extern "C" { + fn zola_init() -> *mut std::ffi::c_void; + fn zola_free(handle: *mut std::ffi::c_void); + fn zola_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = zola_init(); + assert!(!handle.is_null()); + + let result = zola_process(handle, 42); + assert_eq!(result, 0); + + zola_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libzola = "libzola" + +function init() + handle = ccall((:zola_init, libzola), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:zola_process, libzola), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:zola_free, libzola), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/zola.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-collection/plugins/zola/ABI-FFI-README.md b/asdf-plugin-collection/plugins/zola/ABI-FFI-README.md deleted file mode 100644 index 18a76fd1..00000000 --- a/asdf-plugin-collection/plugins/zola/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# ZOLA ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/zola.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libzola.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -zola/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── zola.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── zola.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/zola.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "zola.h" - -int main() { - void* handle = zola_init(); - if (!handle) return 1; - - int result = zola_process(handle, 42); - if (result != 0) { - const char* err = zola_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - zola_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lzola -L./zig-out/lib -``` - -### From Idris2 - -```idris -import ZOLA.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "zola")] -extern "C" { - fn zola_init() -> *mut std::ffi::c_void; - fn zola_free(handle: *mut std::ffi::c_void); - fn zola_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = zola_init(); - assert!(!handle.is_null()); - - let result = zola_process(handle, 42); - assert_eq!(result, 0); - - zola_free(handle); - } -} -``` - -### From Julia - -```julia -const libzola = "libzola" - -function init() - handle = ccall((:zola_init, libzola), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:zola_process, libzola), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:zola_free, libzola), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/zola.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-collection/plugins/zola/CODE_OF_CONDUCT.adoc b/asdf-plugin-collection/plugins/zola/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-collection/plugins/zola/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-collection/plugins/zola/CODE_OF_CONDUCT.md b/asdf-plugin-collection/plugins/zola/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-plugin-collection/plugins/zola/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-plugin-collection/plugins/zola/CONTRIBUTING.adoc b/asdf-plugin-collection/plugins/zola/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-plugin-collection/plugins/zola/CONTRIBUTING.adoc +++ b/asdf-plugin-collection/plugins/zola/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-collection/plugins/zola/CONTRIBUTING.md b/asdf-plugin-collection/plugins/zola/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-collection/plugins/zola/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-collection/plugins/zola/README.adoc b/asdf-plugin-collection/plugins/zola/README.adoc index d08e1dd2..f0cbbf45 100644 --- a/asdf-plugin-collection/plugins/zola/README.adoc +++ b/asdf-plugin-collection/plugins/zola/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-zola -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-zola-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-zola-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-zola-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-zola-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://www.getzola.org[Zola]. -**All repos with foreign function interfaces MUST follow this standard:** +Fast static site generator. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add zola https://github.com/hyperpolymath/asdf-zola-plugin.git +---- -=== Web Projects +zola: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all zola -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install zola latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global zola latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now zola commands are available +zola --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list zola -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local zola -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall zola ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-plugin-collection/plugins/zola/README.md b/asdf-plugin-collection/plugins/zola/README.md deleted file mode 100644 index eb94b490..00000000 --- a/asdf-plugin-collection/plugins/zola/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-zola - -[![Build](https://github.com/hyperpolymath/asdf-zola-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-zola-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-zola-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-zola-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Zola](https://www.getzola.org). - -Fast static site generator. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add zola https://github.com/hyperpolymath/asdf-zola-plugin.git -``` - -zola: - -```bash -# Show all installable versions -asdf list-all zola - -# Install specific version -asdf install zola latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global zola latest - -# Now zola commands are available -zola --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list zola - -# Set local version for current directory -asdf local zola - -# Uninstall a version -asdf uninstall zola -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-plugin-collection/plugins/zola/SECURITY.adoc b/asdf-plugin-collection/plugins/zola/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-collection/plugins/zola/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-collection/plugins/zola/SECURITY.md b/asdf-plugin-collection/plugins/zola/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-plugin-collection/plugins/zola/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-plugin-configurator/ABI-FFI-README.adoc b/asdf-plugin-configurator/ABI-FFI-README.adoc new file mode 100644 index 00000000..ba1d2157 --- /dev/null +++ b/asdf-plugin-configurator/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== PLUGIN_CONFIGURATOR ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/plugin-configurator.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libplugin-configurator.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +plugin-configurator/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── plugin-configurator.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── plugin-configurator.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/plugin-configurator.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "plugin-configurator.h" + +int main() { + void* handle = plugin-configurator_init(); + if (!handle) return 1; + + int result = plugin-configurator_process(handle, 42); + if (result != 0) { + const char* err = plugin-configurator_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + plugin-configurator_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lplugin-configurator -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import PLUGIN_CONFIGURATOR.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "plugin-configurator")] +extern "C" { + fn plugin-configurator_init() -> *mut std::ffi::c_void; + fn plugin-configurator_free(handle: *mut std::ffi::c_void); + fn plugin-configurator_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = plugin-configurator_init(); + assert!(!handle.is_null()); + + let result = plugin-configurator_process(handle, 42); + assert_eq!(result, 0); + + plugin-configurator_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libplugin-configurator = "libplugin-configurator" + +function init() + handle = ccall((:plugin-configurator_init, libplugin-configurator), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:plugin-configurator_process, libplugin-configurator), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:plugin-configurator_free, libplugin-configurator), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/plugin-configurator.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-plugin-configurator/ABI-FFI-README.md b/asdf-plugin-configurator/ABI-FFI-README.md deleted file mode 100644 index af878353..00000000 --- a/asdf-plugin-configurator/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# PLUGIN_CONFIGURATOR ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/plugin-configurator.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libplugin-configurator.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -plugin-configurator/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── plugin-configurator.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── plugin-configurator.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/plugin-configurator.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "plugin-configurator.h" - -int main() { - void* handle = plugin-configurator_init(); - if (!handle) return 1; - - int result = plugin-configurator_process(handle, 42); - if (result != 0) { - const char* err = plugin-configurator_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - plugin-configurator_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lplugin-configurator -L./zig-out/lib -``` - -### From Idris2 - -```idris -import PLUGIN_CONFIGURATOR.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "plugin-configurator")] -extern "C" { - fn plugin-configurator_init() -> *mut std::ffi::c_void; - fn plugin-configurator_free(handle: *mut std::ffi::c_void); - fn plugin-configurator_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = plugin-configurator_init(); - assert!(!handle.is_null()); - - let result = plugin-configurator_process(handle, 42); - assert_eq!(result, 0); - - plugin-configurator_free(handle); - } -} -``` - -### From Julia - -```julia -const libplugin-configurator = "libplugin-configurator" - -function init() - handle = ccall((:plugin-configurator_init, libplugin-configurator), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:plugin-configurator_process, libplugin-configurator), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:plugin-configurator_free, libplugin-configurator), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/plugin-configurator.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-plugin-configurator/CODE_OF_CONDUCT.adoc b/asdf-plugin-configurator/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-plugin-configurator/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-plugin-configurator/CODE_OF_CONDUCT.md b/asdf-plugin-configurator/CODE_OF_CONDUCT.md deleted file mode 100644 index caeda1c6..00000000 --- a/asdf-plugin-configurator/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,27 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. - diff --git a/asdf-plugin-configurator/CONTRIBUTING.adoc b/asdf-plugin-configurator/CONTRIBUTING.adoc index eb045d61..084ee525 100644 --- a/asdf-plugin-configurator/CONTRIBUTING.adoc +++ b/asdf-plugin-configurator/CONTRIBUTING.adoc @@ -1,20 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-plugin-configurator/CONTRIBUTING.md b/asdf-plugin-configurator/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-plugin-configurator/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-plugin-configurator/SECURITY.adoc b/asdf-plugin-configurator/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-plugin-configurator/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-plugin-configurator/SECURITY.md b/asdf-plugin-configurator/SECURITY.md deleted file mode 100644 index 159a0b7a..00000000 --- a/asdf-plugin-configurator/SECURITY.md +++ /dev/null @@ -1,25 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection - diff --git a/asdf-pollen-plugin/ABI-FFI-README.adoc b/asdf-pollen-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..b966efbf --- /dev/null +++ b/asdf-pollen-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== POLLEN ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/pollen.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libpollen.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +pollen/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── pollen.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── pollen.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/pollen.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "pollen.h" + +int main() { + void* handle = pollen_init(); + if (!handle) return 1; + + int result = pollen_process(handle, 42); + if (result != 0) { + const char* err = pollen_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + pollen_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lpollen -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import POLLEN.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "pollen")] +extern "C" { + fn pollen_init() -> *mut std::ffi::c_void; + fn pollen_free(handle: *mut std::ffi::c_void); + fn pollen_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = pollen_init(); + assert!(!handle.is_null()); + + let result = pollen_process(handle, 42); + assert_eq!(result, 0); + + pollen_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libpollen = "libpollen" + +function init() + handle = ccall((:pollen_init, libpollen), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:pollen_process, libpollen), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:pollen_free, libpollen), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/pollen.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-pollen-plugin/ABI-FFI-README.md b/asdf-pollen-plugin/ABI-FFI-README.md deleted file mode 100644 index bb2648b1..00000000 --- a/asdf-pollen-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# POLLEN ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/pollen.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libpollen.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -pollen/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── pollen.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── pollen.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/pollen.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "pollen.h" - -int main() { - void* handle = pollen_init(); - if (!handle) return 1; - - int result = pollen_process(handle, 42); - if (result != 0) { - const char* err = pollen_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - pollen_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lpollen -L./zig-out/lib -``` - -### From Idris2 - -```idris -import POLLEN.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "pollen")] -extern "C" { - fn pollen_init() -> *mut std::ffi::c_void; - fn pollen_free(handle: *mut std::ffi::c_void); - fn pollen_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = pollen_init(); - assert!(!handle.is_null()); - - let result = pollen_process(handle, 42); - assert_eq!(result, 0); - - pollen_free(handle); - } -} -``` - -### From Julia - -```julia -const libpollen = "libpollen" - -function init() - handle = ccall((:pollen_init, libpollen), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:pollen_process, libpollen), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:pollen_free, libpollen), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/pollen.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-pollen-plugin/CODE_OF_CONDUCT.adoc b/asdf-pollen-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-pollen-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-pollen-plugin/CODE_OF_CONDUCT.md b/asdf-pollen-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-pollen-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-pollen-plugin/CONTRIBUTING.adoc b/asdf-pollen-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-pollen-plugin/CONTRIBUTING.adoc +++ b/asdf-pollen-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-pollen-plugin/CONTRIBUTING.md b/asdf-pollen-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-pollen-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-pollen-plugin/README.adoc b/asdf-pollen-plugin/README.adoc index d08e1dd2..bdea8c0c 100644 --- a/asdf-pollen-plugin/README.adoc +++ b/asdf-pollen-plugin/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-pollen -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-pollen-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-pollen-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-pollen-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-pollen-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://docs.racket-lang.org/pollen[Pollen]. -**All repos with foreign function interfaces MUST follow this standard:** +Racket publishing system. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add pollen https://github.com/hyperpolymath/asdf-pollen-plugin.git +---- -=== Web Projects +pollen: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all pollen -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install pollen latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global pollen latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now pollen commands are available +pollen --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list pollen -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local pollen -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall pollen ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-pollen-plugin/README.md b/asdf-pollen-plugin/README.md deleted file mode 100644 index 3c872089..00000000 --- a/asdf-pollen-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-pollen - -[![Build](https://github.com/hyperpolymath/asdf-pollen-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-pollen-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-pollen-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-pollen-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Pollen](https://docs.racket-lang.org/pollen). - -Racket publishing system. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add pollen https://github.com/hyperpolymath/asdf-pollen-plugin.git -``` - -pollen: - -```bash -# Show all installable versions -asdf list-all pollen - -# Install specific version -asdf install pollen latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global pollen latest - -# Now pollen commands are available -pollen --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list pollen - -# Set local version for current directory -asdf local pollen - -# Uninstall a version -asdf uninstall pollen -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-pollen-plugin/SECURITY.adoc b/asdf-pollen-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-pollen-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-pollen-plugin/SECURITY.md b/asdf-pollen-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-pollen-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-pomerium-plugin/ABI-FFI-README.adoc b/asdf-pomerium-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..9a11b87e --- /dev/null +++ b/asdf-pomerium-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== POMERIUM ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/pomerium.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libpomerium.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +pomerium/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── pomerium.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── pomerium.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/pomerium.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "pomerium.h" + +int main() { + void* handle = pomerium_init(); + if (!handle) return 1; + + int result = pomerium_process(handle, 42); + if (result != 0) { + const char* err = pomerium_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + pomerium_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lpomerium -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import POMERIUM.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "pomerium")] +extern "C" { + fn pomerium_init() -> *mut std::ffi::c_void; + fn pomerium_free(handle: *mut std::ffi::c_void); + fn pomerium_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = pomerium_init(); + assert!(!handle.is_null()); + + let result = pomerium_process(handle, 42); + assert_eq!(result, 0); + + pomerium_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libpomerium = "libpomerium" + +function init() + handle = ccall((:pomerium_init, libpomerium), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:pomerium_process, libpomerium), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:pomerium_free, libpomerium), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/pomerium.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-pomerium-plugin/ABI-FFI-README.md b/asdf-pomerium-plugin/ABI-FFI-README.md deleted file mode 100644 index 4cc404ec..00000000 --- a/asdf-pomerium-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# POMERIUM ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/pomerium.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libpomerium.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -pomerium/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── pomerium.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── pomerium.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/pomerium.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "pomerium.h" - -int main() { - void* handle = pomerium_init(); - if (!handle) return 1; - - int result = pomerium_process(handle, 42); - if (result != 0) { - const char* err = pomerium_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - pomerium_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lpomerium -L./zig-out/lib -``` - -### From Idris2 - -```idris -import POMERIUM.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "pomerium")] -extern "C" { - fn pomerium_init() -> *mut std::ffi::c_void; - fn pomerium_free(handle: *mut std::ffi::c_void); - fn pomerium_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = pomerium_init(); - assert!(!handle.is_null()); - - let result = pomerium_process(handle, 42); - assert_eq!(result, 0); - - pomerium_free(handle); - } -} -``` - -### From Julia - -```julia -const libpomerium = "libpomerium" - -function init() - handle = ccall((:pomerium_init, libpomerium), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:pomerium_process, libpomerium), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:pomerium_free, libpomerium), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/pomerium.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-pomerium-plugin/CODE_OF_CONDUCT.adoc b/asdf-pomerium-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-pomerium-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-pomerium-plugin/CODE_OF_CONDUCT.md b/asdf-pomerium-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-pomerium-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-pomerium-plugin/CONTRIBUTING.adoc b/asdf-pomerium-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-pomerium-plugin/CONTRIBUTING.adoc +++ b/asdf-pomerium-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-pomerium-plugin/CONTRIBUTING.md b/asdf-pomerium-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-pomerium-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-pomerium-plugin/README.adoc b/asdf-pomerium-plugin/README.adoc index d08e1dd2..31f3305d 100644 --- a/asdf-pomerium-plugin/README.adoc +++ b/asdf-pomerium-plugin/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-pomerium -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-pomerium-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-pomerium-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-pomerium-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-pomerium-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://www.pomerium.com[Pomerium]. -**All repos with foreign function interfaces MUST follow this standard:** +Identity-aware proxy. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add pomerium https://github.com/hyperpolymath/asdf-pomerium-plugin.git +---- -=== Web Projects +pomerium: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all pomerium -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install pomerium latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global pomerium latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now pomerium commands are available +pomerium --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list pomerium -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local pomerium -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall pomerium ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-pomerium-plugin/README.md b/asdf-pomerium-plugin/README.md deleted file mode 100644 index 2da9d408..00000000 --- a/asdf-pomerium-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-pomerium - -[![Build](https://github.com/hyperpolymath/asdf-pomerium-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-pomerium-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-pomerium-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-pomerium-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Pomerium](https://www.pomerium.com). - -Identity-aware proxy. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add pomerium https://github.com/hyperpolymath/asdf-pomerium-plugin.git -``` - -pomerium: - -```bash -# Show all installable versions -asdf list-all pomerium - -# Install specific version -asdf install pomerium latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global pomerium latest - -# Now pomerium commands are available -pomerium --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list pomerium - -# Set local version for current directory -asdf local pomerium - -# Uninstall a version -asdf uninstall pomerium -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-pomerium-plugin/SECURITY.adoc b/asdf-pomerium-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-pomerium-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-pomerium-plugin/SECURITY.md b/asdf-pomerium-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-pomerium-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-rekor-plugin/ABI-FFI-README.adoc b/asdf-rekor-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..55ffa8ff --- /dev/null +++ b/asdf-rekor-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== REKOR ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/rekor.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to librekor.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +rekor/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── rekor.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── rekor.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/rekor.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "rekor.h" + +int main() { + void* handle = rekor_init(); + if (!handle) return 1; + + int result = rekor_process(handle, 42); + if (result != 0) { + const char* err = rekor_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + rekor_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lrekor -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import REKOR.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "rekor")] +extern "C" { + fn rekor_init() -> *mut std::ffi::c_void; + fn rekor_free(handle: *mut std::ffi::c_void); + fn rekor_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = rekor_init(); + assert!(!handle.is_null()); + + let result = rekor_process(handle, 42); + assert_eq!(result, 0); + + rekor_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const librekor = "librekor" + +function init() + handle = ccall((:rekor_init, librekor), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:rekor_process, librekor), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:rekor_free, librekor), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/rekor.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-rekor-plugin/ABI-FFI-README.md b/asdf-rekor-plugin/ABI-FFI-README.md deleted file mode 100644 index 0722435d..00000000 --- a/asdf-rekor-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# REKOR ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/rekor.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to librekor.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -rekor/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── rekor.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── rekor.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/rekor.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "rekor.h" - -int main() { - void* handle = rekor_init(); - if (!handle) return 1; - - int result = rekor_process(handle, 42); - if (result != 0) { - const char* err = rekor_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - rekor_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lrekor -L./zig-out/lib -``` - -### From Idris2 - -```idris -import REKOR.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "rekor")] -extern "C" { - fn rekor_init() -> *mut std::ffi::c_void; - fn rekor_free(handle: *mut std::ffi::c_void); - fn rekor_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = rekor_init(); - assert!(!handle.is_null()); - - let result = rekor_process(handle, 42); - assert_eq!(result, 0); - - rekor_free(handle); - } -} -``` - -### From Julia - -```julia -const librekor = "librekor" - -function init() - handle = ccall((:rekor_init, librekor), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:rekor_process, librekor), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:rekor_free, librekor), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/rekor.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-rekor-plugin/CODE_OF_CONDUCT.adoc b/asdf-rekor-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-rekor-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-rekor-plugin/CODE_OF_CONDUCT.md b/asdf-rekor-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-rekor-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-rekor-plugin/CONTRIBUTING.adoc b/asdf-rekor-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-rekor-plugin/CONTRIBUTING.adoc +++ b/asdf-rekor-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-rekor-plugin/CONTRIBUTING.md b/asdf-rekor-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-rekor-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-rekor-plugin/README.adoc b/asdf-rekor-plugin/README.adoc index d08e1dd2..512c1faf 100644 --- a/asdf-rekor-plugin/README.adoc +++ b/asdf-rekor-plugin/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-rekor -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-rekor-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-rekor-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-rekor-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-rekor-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://sigstore.dev[Rekor]. -**All repos with foreign function interfaces MUST follow this standard:** +Sigstore transparency log. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add rekor https://github.com/hyperpolymath/asdf-rekor-plugin.git +---- -=== Web Projects +rekor: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all rekor -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install rekor latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global rekor latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now rekor commands are available +rekor --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list rekor -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local rekor -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall rekor ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-rekor-plugin/README.md b/asdf-rekor-plugin/README.md deleted file mode 100644 index b031657a..00000000 --- a/asdf-rekor-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-rekor - -[![Build](https://github.com/hyperpolymath/asdf-rekor-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-rekor-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-rekor-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-rekor-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Rekor](https://sigstore.dev). - -Sigstore transparency log. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add rekor https://github.com/hyperpolymath/asdf-rekor-plugin.git -``` - -rekor: - -```bash -# Show all installable versions -asdf list-all rekor - -# Install specific version -asdf install rekor latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global rekor latest - -# Now rekor commands are available -rekor --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list rekor - -# Set local version for current directory -asdf local rekor - -# Uninstall a version -asdf uninstall rekor -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-rekor-plugin/SECURITY.adoc b/asdf-rekor-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-rekor-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-rekor-plugin/SECURITY.md b/asdf-rekor-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-rekor-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-rescript-plugin/ABI-FFI-README.adoc b/asdf-rescript-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..d31a905e --- /dev/null +++ b/asdf-rescript-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== AFFINESCRIPT ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/affinescript.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to librescript.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +affinescript/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── affinescript.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── affinescript.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/affinescript.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "affinescript.h" + +int main() { + void* handle = rescript_init(); + if (!handle) return 1; + + int result = rescript_process(handle, 42); + if (result != 0) { + const char* err = rescript_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + rescript_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lrescript -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import AFFINESCRIPT.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "affinescript")] +extern "C" { + fn rescript_init() -> *mut std::ffi::c_void; + fn rescript_free(handle: *mut std::ffi::c_void); + fn rescript_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = rescript_init(); + assert!(!handle.is_null()); + + let result = rescript_process(handle, 42); + assert_eq!(result, 0); + + rescript_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const librescript = "librescript" + +function init() + handle = ccall((:rescript_init, librescript), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:rescript_process, librescript), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:rescript_free, librescript), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/affinescript.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-rescript-plugin/ABI-FFI-README.md b/asdf-rescript-plugin/ABI-FFI-README.md deleted file mode 100644 index 358c9ee2..00000000 --- a/asdf-rescript-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# AFFINESCRIPT ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/affinescript.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to librescript.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -affinescript/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── affinescript.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── affinescript.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/affinescript.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "affinescript.h" - -int main() { - void* handle = rescript_init(); - if (!handle) return 1; - - int result = rescript_process(handle, 42); - if (result != 0) { - const char* err = rescript_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - rescript_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lrescript -L./zig-out/lib -``` - -### From Idris2 - -```idris -import AFFINESCRIPT.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "affinescript")] -extern "C" { - fn rescript_init() -> *mut std::ffi::c_void; - fn rescript_free(handle: *mut std::ffi::c_void); - fn rescript_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = rescript_init(); - assert!(!handle.is_null()); - - let result = rescript_process(handle, 42); - assert_eq!(result, 0); - - rescript_free(handle); - } -} -``` - -### From Julia - -```julia -const librescript = "librescript" - -function init() - handle = ccall((:rescript_init, librescript), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:rescript_process, librescript), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:rescript_free, librescript), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/affinescript.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-rescript-plugin/CODE_OF_CONDUCT.adoc b/asdf-rescript-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-rescript-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-rescript-plugin/CODE_OF_CONDUCT.md b/asdf-rescript-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-rescript-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-rescript-plugin/CONTRIBUTING.adoc b/asdf-rescript-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-rescript-plugin/CONTRIBUTING.adoc +++ b/asdf-rescript-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-rescript-plugin/CONTRIBUTING.md b/asdf-rescript-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-rescript-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-rescript-plugin/README.adoc b/asdf-rescript-plugin/README.adoc index d08e1dd2..d0389faa 100644 --- a/asdf-rescript-plugin/README.adoc +++ b/asdf-rescript-plugin/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-affinescript -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-affinescript-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-affinescript-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-affinescript-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-affinescript-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://affinescript-lang.org[AffineScript]. -**All repos with foreign function interfaces MUST follow this standard:** +Type-safe JavaScript. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add affinescript https://github.com/hyperpolymath/asdf-affinescript-plugin.git +---- -=== Web Projects +affinescript: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all affinescript -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install affinescript latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global affinescript latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now affinescript commands are available +affinescript --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list affinescript -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local affinescript -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall affinescript ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-rescript-plugin/README.md b/asdf-rescript-plugin/README.md deleted file mode 100644 index 11d13ace..00000000 --- a/asdf-rescript-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-affinescript - -[![Build](https://github.com/hyperpolymath/asdf-affinescript-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-affinescript-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-affinescript-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-affinescript-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [AffineScript](https://affinescript-lang.org). - -Type-safe JavaScript. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add affinescript https://github.com/hyperpolymath/asdf-affinescript-plugin.git -``` - -affinescript: - -```bash -# Show all installable versions -asdf list-all affinescript - -# Install specific version -asdf install affinescript latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global affinescript latest - -# Now affinescript commands are available -affinescript --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list affinescript - -# Set local version for current directory -asdf local affinescript - -# Uninstall a version -asdf uninstall affinescript -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-rescript-plugin/SECURITY.adoc b/asdf-rescript-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-rescript-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-rescript-plugin/SECURITY.md b/asdf-rescript-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-rescript-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-restic-plugin/ABI-FFI-README.adoc b/asdf-restic-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..f8a06f74 --- /dev/null +++ b/asdf-restic-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== RESTIC ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/restic.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to librestic.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +restic/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── restic.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── restic.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/restic.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "restic.h" + +int main() { + void* handle = restic_init(); + if (!handle) return 1; + + int result = restic_process(handle, 42); + if (result != 0) { + const char* err = restic_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + restic_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lrestic -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import RESTIC.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "restic")] +extern "C" { + fn restic_init() -> *mut std::ffi::c_void; + fn restic_free(handle: *mut std::ffi::c_void); + fn restic_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = restic_init(); + assert!(!handle.is_null()); + + let result = restic_process(handle, 42); + assert_eq!(result, 0); + + restic_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const librestic = "librestic" + +function init() + handle = ccall((:restic_init, librestic), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:restic_process, librestic), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:restic_free, librestic), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/restic.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-restic-plugin/ABI-FFI-README.md b/asdf-restic-plugin/ABI-FFI-README.md deleted file mode 100644 index df6de0ef..00000000 --- a/asdf-restic-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# RESTIC ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/restic.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to librestic.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -restic/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── restic.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── restic.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/restic.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "restic.h" - -int main() { - void* handle = restic_init(); - if (!handle) return 1; - - int result = restic_process(handle, 42); - if (result != 0) { - const char* err = restic_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - restic_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lrestic -L./zig-out/lib -``` - -### From Idris2 - -```idris -import RESTIC.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "restic")] -extern "C" { - fn restic_init() -> *mut std::ffi::c_void; - fn restic_free(handle: *mut std::ffi::c_void); - fn restic_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = restic_init(); - assert!(!handle.is_null()); - - let result = restic_process(handle, 42); - assert_eq!(result, 0); - - restic_free(handle); - } -} -``` - -### From Julia - -```julia -const librestic = "librestic" - -function init() - handle = ccall((:restic_init, librestic), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:restic_process, librestic), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:restic_free, librestic), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/restic.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-restic-plugin/CODE_OF_CONDUCT.adoc b/asdf-restic-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-restic-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-restic-plugin/CODE_OF_CONDUCT.md b/asdf-restic-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-restic-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-restic-plugin/CONTRIBUTING.adoc b/asdf-restic-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-restic-plugin/CONTRIBUTING.adoc +++ b/asdf-restic-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-restic-plugin/CONTRIBUTING.md b/asdf-restic-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-restic-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-restic-plugin/README.adoc b/asdf-restic-plugin/README.adoc index d08e1dd2..23d77c86 100644 --- a/asdf-restic-plugin/README.adoc +++ b/asdf-restic-plugin/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-restic -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-restic-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-restic-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-restic-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-restic-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://restic.net[Restic]. -**All repos with foreign function interfaces MUST follow this standard:** +Fast secure backup. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add restic https://github.com/hyperpolymath/asdf-restic-plugin.git +---- -=== Web Projects +restic: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all restic -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install restic latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global restic latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now restic commands are available +restic --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list restic -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local restic -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall restic ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-restic-plugin/README.md b/asdf-restic-plugin/README.md deleted file mode 100644 index 442f2bd1..00000000 --- a/asdf-restic-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-restic - -[![Build](https://github.com/hyperpolymath/asdf-restic-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-restic-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-restic-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-restic-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Restic](https://restic.net). - -Fast secure backup. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add restic https://github.com/hyperpolymath/asdf-restic-plugin.git -``` - -restic: - -```bash -# Show all installable versions -asdf list-all restic - -# Install specific version -asdf install restic latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global restic latest - -# Now restic commands are available -restic --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list restic - -# Set local version for current directory -asdf local restic - -# Uninstall a version -asdf uninstall restic -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-restic-plugin/SECURITY.adoc b/asdf-restic-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-restic-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-restic-plugin/SECURITY.md b/asdf-restic-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-restic-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-rethinkdb-plugin/ABI-FFI-README.adoc b/asdf-rethinkdb-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..75445ff6 --- /dev/null +++ b/asdf-rethinkdb-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== RETHINKDB ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/rethinkdb.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to librethinkdb.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +rethinkdb/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── rethinkdb.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── rethinkdb.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/rethinkdb.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "rethinkdb.h" + +int main() { + void* handle = rethinkdb_init(); + if (!handle) return 1; + + int result = rethinkdb_process(handle, 42); + if (result != 0) { + const char* err = rethinkdb_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + rethinkdb_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lrethinkdb -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import RETHINKDB.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "rethinkdb")] +extern "C" { + fn rethinkdb_init() -> *mut std::ffi::c_void; + fn rethinkdb_free(handle: *mut std::ffi::c_void); + fn rethinkdb_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = rethinkdb_init(); + assert!(!handle.is_null()); + + let result = rethinkdb_process(handle, 42); + assert_eq!(result, 0); + + rethinkdb_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const librethinkdb = "librethinkdb" + +function init() + handle = ccall((:rethinkdb_init, librethinkdb), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:rethinkdb_process, librethinkdb), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:rethinkdb_free, librethinkdb), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/rethinkdb.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-rethinkdb-plugin/ABI-FFI-README.md b/asdf-rethinkdb-plugin/ABI-FFI-README.md deleted file mode 100644 index 3e1dca88..00000000 --- a/asdf-rethinkdb-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# RETHINKDB ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/rethinkdb.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to librethinkdb.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -rethinkdb/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── rethinkdb.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── rethinkdb.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/rethinkdb.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "rethinkdb.h" - -int main() { - void* handle = rethinkdb_init(); - if (!handle) return 1; - - int result = rethinkdb_process(handle, 42); - if (result != 0) { - const char* err = rethinkdb_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - rethinkdb_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lrethinkdb -L./zig-out/lib -``` - -### From Idris2 - -```idris -import RETHINKDB.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "rethinkdb")] -extern "C" { - fn rethinkdb_init() -> *mut std::ffi::c_void; - fn rethinkdb_free(handle: *mut std::ffi::c_void); - fn rethinkdb_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = rethinkdb_init(); - assert!(!handle.is_null()); - - let result = rethinkdb_process(handle, 42); - assert_eq!(result, 0); - - rethinkdb_free(handle); - } -} -``` - -### From Julia - -```julia -const librethinkdb = "librethinkdb" - -function init() - handle = ccall((:rethinkdb_init, librethinkdb), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:rethinkdb_process, librethinkdb), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:rethinkdb_free, librethinkdb), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/rethinkdb.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-rethinkdb-plugin/CODE_OF_CONDUCT.adoc b/asdf-rethinkdb-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-rethinkdb-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-rethinkdb-plugin/CODE_OF_CONDUCT.md b/asdf-rethinkdb-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-rethinkdb-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-rethinkdb-plugin/CONTRIBUTING.adoc b/asdf-rethinkdb-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-rethinkdb-plugin/CONTRIBUTING.adoc +++ b/asdf-rethinkdb-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-rethinkdb-plugin/CONTRIBUTING.md b/asdf-rethinkdb-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-rethinkdb-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-rethinkdb-plugin/README.adoc b/asdf-rethinkdb-plugin/README.adoc index d08e1dd2..b110a454 100644 --- a/asdf-rethinkdb-plugin/README.adoc +++ b/asdf-rethinkdb-plugin/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-rethinkdb -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-rethinkdb-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-rethinkdb-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-rethinkdb-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-rethinkdb-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://rethinkdb.com[RethinkDB]. -**All repos with foreign function interfaces MUST follow this standard:** +Real-time document database. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add rethinkdb https://github.com/hyperpolymath/asdf-rethinkdb-plugin.git +---- -=== Web Projects +rethinkdb: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all rethinkdb -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install rethinkdb latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global rethinkdb latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now rethinkdb commands are available +rethinkdb --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list rethinkdb -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local rethinkdb -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall rethinkdb ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-rethinkdb-plugin/README.md b/asdf-rethinkdb-plugin/README.md deleted file mode 100644 index b2ad7d5d..00000000 --- a/asdf-rethinkdb-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-rethinkdb - -[![Build](https://github.com/hyperpolymath/asdf-rethinkdb-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-rethinkdb-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-rethinkdb-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-rethinkdb-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [RethinkDB](https://rethinkdb.com). - -Real-time document database. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add rethinkdb https://github.com/hyperpolymath/asdf-rethinkdb-plugin.git -``` - -rethinkdb: - -```bash -# Show all installable versions -asdf list-all rethinkdb - -# Install specific version -asdf install rethinkdb latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global rethinkdb latest - -# Now rethinkdb commands are available -rethinkdb --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list rethinkdb - -# Set local version for current directory -asdf local rethinkdb - -# Uninstall a version -asdf uninstall rethinkdb -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-rethinkdb-plugin/SECURITY.adoc b/asdf-rethinkdb-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-rethinkdb-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-rethinkdb-plugin/SECURITY.md b/asdf-rethinkdb-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-rethinkdb-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-security-plugin/ABI-FFI-README.adoc b/asdf-security-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..a80ffdfd --- /dev/null +++ b/asdf-security-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== SECURITY ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/security.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libsecurity.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +security/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── security.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── security.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/security.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "security.h" + +int main() { + void* handle = security_init(); + if (!handle) return 1; + + int result = security_process(handle, 42); + if (result != 0) { + const char* err = security_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + security_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lsecurity -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import SECURITY.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "security")] +extern "C" { + fn security_init() -> *mut std::ffi::c_void; + fn security_free(handle: *mut std::ffi::c_void); + fn security_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = security_init(); + assert!(!handle.is_null()); + + let result = security_process(handle, 42); + assert_eq!(result, 0); + + security_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libsecurity = "libsecurity" + +function init() + handle = ccall((:security_init, libsecurity), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:security_process, libsecurity), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:security_free, libsecurity), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/security.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-security-plugin/ABI-FFI-README.md b/asdf-security-plugin/ABI-FFI-README.md deleted file mode 100644 index 28dfe6f4..00000000 --- a/asdf-security-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# SECURITY ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/security.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libsecurity.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -security/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── security.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── security.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/security.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "security.h" - -int main() { - void* handle = security_init(); - if (!handle) return 1; - - int result = security_process(handle, 42); - if (result != 0) { - const char* err = security_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - security_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lsecurity -L./zig-out/lib -``` - -### From Idris2 - -```idris -import SECURITY.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "security")] -extern "C" { - fn security_init() -> *mut std::ffi::c_void; - fn security_free(handle: *mut std::ffi::c_void); - fn security_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = security_init(); - assert!(!handle.is_null()); - - let result = security_process(handle, 42); - assert_eq!(result, 0); - - security_free(handle); - } -} -``` - -### From Julia - -```julia -const libsecurity = "libsecurity" - -function init() - handle = ccall((:security_init, libsecurity), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:security_process, libsecurity), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:security_free, libsecurity), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/security.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-security-plugin/CODE_OF_CONDUCT.adoc b/asdf-security-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-security-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-security-plugin/CODE_OF_CONDUCT.md b/asdf-security-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index caeda1c6..00000000 --- a/asdf-security-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,27 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. - diff --git a/asdf-security-plugin/CONTRIBUTING.adoc b/asdf-security-plugin/CONTRIBUTING.adoc index eb045d61..084ee525 100644 --- a/asdf-security-plugin/CONTRIBUTING.adoc +++ b/asdf-security-plugin/CONTRIBUTING.adoc @@ -1,20 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-security-plugin/CONTRIBUTING.md b/asdf-security-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-security-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-security-plugin/README.adoc b/asdf-security-plugin/README.adoc index acbc80f7..92df847a 100644 --- a/asdf-security-plugin/README.adoc +++ b/asdf-security-plugin/README.adoc @@ -1,122 +1,54 @@ -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] -image:https://img.shields.io/badge/Philosophy-Palimpsest-indigo.svg[Palimpsest,link="https://github.com/hyperpolymath/palimpsest-license"] +== asdf-security-plugin +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] +image:https://img.shields.io/badge/Philosophy-Palimpsest-indigo.svg[Palimpsest,link="`https://github.com/hyperpolymath/palimpsest-license`"] -// SPDX-License-Identifier: CC-BY-SA-4.0 -= asdf-security-plugin +Security-focused extensions and policies for the +https://asdf-vm.com[asdf] version manager ecosystem. -:toc: macro -:toc-title: Contents -:toclevels: 2 +=== Status -**Security scanning plugin for asdf version manager** +____ +*Note:* This repository is currently a project skeleton. Implementation +is pending. +____ -toc::[] +=== Overview -== Status +`+asdf-security-plugin+` provides security tooling and policies for the +asdf plugin ecosystem: -[NOTE] -==== -This plugin is *fully functional* at version 1.0.0. -==== +* *Security scanning* - Vulnerability detection for installed tools +* *Policy enforcement* - Ensure only approved versions are installed +* *Audit logging* - Track version changes and installations +* *Signature verification* - Validate tool authenticity -== Overview +=== Planned Features -`asdf-security-plugin` is a security-focused plugin for the https://asdf-vm.com/[asdf version manager]. It provides security scanning capabilities for asdf installations, including plugin auditing, signature verification, and vulnerability reporting. +* Integration with Trivy, Grype, and Syft for scanning +* Policy-as-code support via OPA/Rego +* SBOM generation for installed tool chains +* Supply chain attestation via Sigstore -== Installation +=== Related Projects -[source,bash] ----- -asdf plugin add asdf-security https://github.com/hyperpolymath/asdf-security-plugin.git -asdf install asdf-security 1.0.0 -asdf global asdf-security 1.0.0 ----- - -== Usage - -[source,bash] ----- -asdf-security [args...] ----- - -=== Commands - -[cols="2,3",options="header"] +[width="100%",cols="40%,60%",options="header",] |=== -| Command | Description - -| `audit` -| Audit all installed asdf plugins for known vulnerabilities - -| `verify ` -| Verify GPG signatures and SHA256 checksums of a plugin - -| `report` -| Generate a comprehensive security report of all plugins +|Project |Relationship +|https://github.com/hyperpolymath/asdf-metaiconic-plugin[asdf-metaiconic-plugin] +|Metadata registry -| `update-db` -| Update the local vulnerability database +|https://github.com/hyperpolymath/asdf-ui-plugin[asdf-ui-plugin] |Visual +interface |=== -=== Examples - -[source,bash] ----- -# Audit all plugins -asdf-security audit - -# Verify a specific plugin -asdf-security verify nodejs - -# Generate security report -asdf-security report - -# Update vulnerability database -asdf-security update-db ----- - -== Components - -[cols="2,3",options="header"] -|=== -| Component | Description - -| `bin/list-all` -| Lists available versions of asdf-security - -| `bin/download` -| Downloads the specified version - -| `bin/install` -| Installs asdf-security to the specified path - -| `lib/utils.bash` -| Shared utility functions - -| `.github/workflows/` -| CI/CD infrastructure including security scanning - -| `hooks/` -| Pre-commit validation hooks for security standards -|=== - -== Security Features - -* *Plugin Auditing*: Scans installed plugins against known vulnerability databases -* *Signature Verification*: Validates GPG signatures on plugin releases -* *Checksum Validation*: SHA256 integrity verification for downloads -* *Security Reports*: Comprehensive JSON/text reports of security posture - -== Development Standards - -Per the Hyperpolymath Language Policy: +=== License -* **Primary languages**: Bash/POSIX Shell (for asdf plugin scripts) -* **Package management**: Guix (primary), Guix (fallback) -* **Security**: SHA256+ hashing, HTTPS only, no hardcoded secrets, SHA-pinned dependencies -* **Code quality**: ShellCheck linting, SPDX license headers +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -== License +''''' -MPL-2.0 +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-security-plugin/README.md b/asdf-security-plugin/README.md deleted file mode 100644 index 9ee2db44..00000000 --- a/asdf-security-plugin/README.md +++ /dev/null @@ -1,41 +0,0 @@ -# asdf-security-plugin - -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] -image:https://img.shields.io/badge/Philosophy-Palimpsest-indigo.svg[Palimpsest,link="https://github.com/hyperpolymath/palimpsest-license"] - -Security-focused extensions and policies for the [asdf](https://asdf-vm.com) version manager ecosystem. - -## Status - -> **Note:** This repository is currently a project skeleton. Implementation is pending. - -## Overview - -`asdf-security-plugin` provides security tooling and policies for the asdf plugin ecosystem: - -- **Security scanning** - Vulnerability detection for installed tools -- **Policy enforcement** - Ensure only approved versions are installed -- **Audit logging** - Track version changes and installations -- **Signature verification** - Validate tool authenticity - -## Planned Features - -- Integration with Trivy, Grype, and Syft for scanning -- Policy-as-code support via OPA/Rego -- SBOM generation for installed tool chains -- Supply chain attestation via Sigstore - -## Related Projects - -| Project | Relationship | -|---------|--------------| -| [asdf-metaiconic-plugin](https://github.com/hyperpolymath/asdf-metaiconic-plugin) | Metadata registry | -| [asdf-ui-plugin](https://github.com/hyperpolymath/asdf-ui-plugin) | Visual interface | - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-security-plugin/SECURITY.adoc b/asdf-security-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-security-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-security-plugin/SECURITY.md b/asdf-security-plugin/SECURITY.md deleted file mode 100644 index 159a0b7a..00000000 --- a/asdf-security-plugin/SECURITY.md +++ /dev/null @@ -1,25 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection - diff --git a/asdf-serum-plugin/ABI-FFI-README.adoc b/asdf-serum-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..324cdd6c --- /dev/null +++ b/asdf-serum-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== SERUM ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/serum.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libserum.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +serum/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── serum.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── serum.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/serum.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "serum.h" + +int main() { + void* handle = serum_init(); + if (!handle) return 1; + + int result = serum_process(handle, 42); + if (result != 0) { + const char* err = serum_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + serum_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lserum -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import SERUM.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "serum")] +extern "C" { + fn serum_init() -> *mut std::ffi::c_void; + fn serum_free(handle: *mut std::ffi::c_void); + fn serum_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = serum_init(); + assert!(!handle.is_null()); + + let result = serum_process(handle, 42); + assert_eq!(result, 0); + + serum_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libserum = "libserum" + +function init() + handle = ccall((:serum_init, libserum), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:serum_process, libserum), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:serum_free, libserum), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/serum.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-serum-plugin/ABI-FFI-README.md b/asdf-serum-plugin/ABI-FFI-README.md deleted file mode 100644 index 55ed6746..00000000 --- a/asdf-serum-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# SERUM ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/serum.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libserum.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -serum/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── serum.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── serum.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/serum.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "serum.h" - -int main() { - void* handle = serum_init(); - if (!handle) return 1; - - int result = serum_process(handle, 42); - if (result != 0) { - const char* err = serum_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - serum_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lserum -L./zig-out/lib -``` - -### From Idris2 - -```idris -import SERUM.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "serum")] -extern "C" { - fn serum_init() -> *mut std::ffi::c_void; - fn serum_free(handle: *mut std::ffi::c_void); - fn serum_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = serum_init(); - assert!(!handle.is_null()); - - let result = serum_process(handle, 42); - assert_eq!(result, 0); - - serum_free(handle); - } -} -``` - -### From Julia - -```julia -const libserum = "libserum" - -function init() - handle = ccall((:serum_init, libserum), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:serum_process, libserum), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:serum_free, libserum), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/serum.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-serum-plugin/CODE_OF_CONDUCT.adoc b/asdf-serum-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-serum-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-serum-plugin/CODE_OF_CONDUCT.md b/asdf-serum-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-serum-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-serum-plugin/CONTRIBUTING.adoc b/asdf-serum-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-serum-plugin/CONTRIBUTING.adoc +++ b/asdf-serum-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-serum-plugin/CONTRIBUTING.md b/asdf-serum-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-serum-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-serum-plugin/README.adoc b/asdf-serum-plugin/README.adoc index d08e1dd2..8de14fa8 100644 --- a/asdf-serum-plugin/README.adoc +++ b/asdf-serum-plugin/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-serum -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-serum-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-serum-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-serum-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-serum-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://dalgona.github.io/Serum[Serum]. -**All repos with foreign function interfaces MUST follow this standard:** +Elixir static site generator. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add serum https://github.com/hyperpolymath/asdf-serum-plugin.git +---- -=== Web Projects +serum: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all serum -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install serum latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global serum latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now serum commands are available +serum --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list serum -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local serum -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall serum ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-serum-plugin/README.md b/asdf-serum-plugin/README.md deleted file mode 100644 index f325d7f4..00000000 --- a/asdf-serum-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-serum - -[![Build](https://github.com/hyperpolymath/asdf-serum-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-serum-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-serum-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-serum-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Serum](https://dalgona.github.io/Serum). - -Elixir static site generator. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add serum https://github.com/hyperpolymath/asdf-serum-plugin.git -``` - -serum: - -```bash -# Show all installable versions -asdf list-all serum - -# Install specific version -asdf install serum latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global serum latest - -# Now serum commands are available -serum --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list serum - -# Set local version for current directory -asdf local serum - -# Uninstall a version -asdf uninstall serum -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-serum-plugin/SECURITY.adoc b/asdf-serum-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-serum-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-serum-plugin/SECURITY.md b/asdf-serum-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-serum-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-sops-plugin/ABI-FFI-README.adoc b/asdf-sops-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..172c85b4 --- /dev/null +++ b/asdf-sops-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== SOPS ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/sops.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libsops.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +sops/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── sops.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── sops.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/sops.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "sops.h" + +int main() { + void* handle = sops_init(); + if (!handle) return 1; + + int result = sops_process(handle, 42); + if (result != 0) { + const char* err = sops_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + sops_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lsops -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import SOPS.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "sops")] +extern "C" { + fn sops_init() -> *mut std::ffi::c_void; + fn sops_free(handle: *mut std::ffi::c_void); + fn sops_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = sops_init(); + assert!(!handle.is_null()); + + let result = sops_process(handle, 42); + assert_eq!(result, 0); + + sops_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libsops = "libsops" + +function init() + handle = ccall((:sops_init, libsops), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:sops_process, libsops), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:sops_free, libsops), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/sops.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-sops-plugin/ABI-FFI-README.md b/asdf-sops-plugin/ABI-FFI-README.md deleted file mode 100644 index 94692b76..00000000 --- a/asdf-sops-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# SOPS ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/sops.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libsops.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -sops/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── sops.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── sops.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/sops.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "sops.h" - -int main() { - void* handle = sops_init(); - if (!handle) return 1; - - int result = sops_process(handle, 42); - if (result != 0) { - const char* err = sops_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - sops_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lsops -L./zig-out/lib -``` - -### From Idris2 - -```idris -import SOPS.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "sops")] -extern "C" { - fn sops_init() -> *mut std::ffi::c_void; - fn sops_free(handle: *mut std::ffi::c_void); - fn sops_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = sops_init(); - assert!(!handle.is_null()); - - let result = sops_process(handle, 42); - assert_eq!(result, 0); - - sops_free(handle); - } -} -``` - -### From Julia - -```julia -const libsops = "libsops" - -function init() - handle = ccall((:sops_init, libsops), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:sops_process, libsops), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:sops_free, libsops), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/sops.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-sops-plugin/CODE_OF_CONDUCT.adoc b/asdf-sops-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-sops-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-sops-plugin/CODE_OF_CONDUCT.md b/asdf-sops-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-sops-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-sops-plugin/CONTRIBUTING.adoc b/asdf-sops-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-sops-plugin/CONTRIBUTING.adoc +++ b/asdf-sops-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-sops-plugin/CONTRIBUTING.md b/asdf-sops-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-sops-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-sops-plugin/README.adoc b/asdf-sops-plugin/README.adoc index 72f888e1..59bf0404 100644 --- a/asdf-sops-plugin/README.adoc +++ b/asdf-sops-plugin/README.adoc @@ -1,26 +1,83 @@ -= asdf-sops +== asdf-sops -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] -:url-asdf: https://asdf-vm.com +https://github.com/hyperpolymath/asdf-sops-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-sops-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-sops-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-sops-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -An {url-asdf}[asdf] plugin for https://github.com/getsops/sops[SOPS] - Secrets OPerationS. +https://asdf-vm.com[asdf] plugin for +https://github.com/getsops/sops[SOPS]. -== Installation +Secrets editor. + +=== Contents + +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] + +=== Dependencies + +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] + +=== Install + +Plugin: [source,bash] ---- asdf plugin add sops https://github.com/hyperpolymath/asdf-sops-plugin.git ---- -== Usage +sops: [source,bash] ---- -asdf list all sops +# Show all installable versions +asdf list-all sops + +# Install specific version asdf install sops latest + +# Set a version globally (in your ~/.tool-versions file) asdf global sops latest + +# Now sops commands are available +sops --version ---- -== License +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. + +=== Usage + +[source,bash] +---- +# List installed versions +asdf list sops + +# Set local version for current directory +asdf local sops + +# Uninstall a version +asdf uninstall sops +---- + +=== Contributing + +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License + +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. + +''''' -SPDX-License-Identifier: CC-BY-SA-4.0 +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-sops-plugin/README.md b/asdf-sops-plugin/README.md deleted file mode 100644 index 64c9008d..00000000 --- a/asdf-sops-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-sops - -[![Build](https://github.com/hyperpolymath/asdf-sops-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-sops-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-sops-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-sops-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [SOPS](https://github.com/getsops/sops). - -Secrets editor. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add sops https://github.com/hyperpolymath/asdf-sops-plugin.git -``` - -sops: - -```bash -# Show all installable versions -asdf list-all sops - -# Install specific version -asdf install sops latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global sops latest - -# Now sops commands are available -sops --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list sops - -# Set local version for current directory -asdf local sops - -# Uninstall a version -asdf uninstall sops -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-sops-plugin/SECURITY.adoc b/asdf-sops-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-sops-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-sops-plugin/SECURITY.md b/asdf-sops-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-sops-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-step-ca-plugin/ABI-FFI-README.adoc b/asdf-step-ca-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..48e73b27 --- /dev/null +++ b/asdf-step-ca-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== STEP_CA ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/step-ca.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libstep-ca.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +step-ca/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── step-ca.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── step-ca.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/step-ca.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "step-ca.h" + +int main() { + void* handle = step-ca_init(); + if (!handle) return 1; + + int result = step-ca_process(handle, 42); + if (result != 0) { + const char* err = step-ca_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + step-ca_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lstep-ca -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import STEP_CA.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "step-ca")] +extern "C" { + fn step-ca_init() -> *mut std::ffi::c_void; + fn step-ca_free(handle: *mut std::ffi::c_void); + fn step-ca_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = step-ca_init(); + assert!(!handle.is_null()); + + let result = step-ca_process(handle, 42); + assert_eq!(result, 0); + + step-ca_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libstep-ca = "libstep-ca" + +function init() + handle = ccall((:step-ca_init, libstep-ca), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:step-ca_process, libstep-ca), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:step-ca_free, libstep-ca), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/step-ca.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-step-ca-plugin/ABI-FFI-README.md b/asdf-step-ca-plugin/ABI-FFI-README.md deleted file mode 100644 index 3a8993d5..00000000 --- a/asdf-step-ca-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# STEP_CA ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/step-ca.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libstep-ca.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -step-ca/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── step-ca.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── step-ca.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/step-ca.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "step-ca.h" - -int main() { - void* handle = step-ca_init(); - if (!handle) return 1; - - int result = step-ca_process(handle, 42); - if (result != 0) { - const char* err = step-ca_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - step-ca_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lstep-ca -L./zig-out/lib -``` - -### From Idris2 - -```idris -import STEP_CA.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "step-ca")] -extern "C" { - fn step-ca_init() -> *mut std::ffi::c_void; - fn step-ca_free(handle: *mut std::ffi::c_void); - fn step-ca_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = step-ca_init(); - assert!(!handle.is_null()); - - let result = step-ca_process(handle, 42); - assert_eq!(result, 0); - - step-ca_free(handle); - } -} -``` - -### From Julia - -```julia -const libstep-ca = "libstep-ca" - -function init() - handle = ccall((:step-ca_init, libstep-ca), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:step-ca_process, libstep-ca), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:step-ca_free, libstep-ca), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/step-ca.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-step-ca-plugin/CODE_OF_CONDUCT.adoc b/asdf-step-ca-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-step-ca-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-step-ca-plugin/CODE_OF_CONDUCT.md b/asdf-step-ca-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-step-ca-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-step-ca-plugin/CONTRIBUTING.adoc b/asdf-step-ca-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-step-ca-plugin/CONTRIBUTING.adoc +++ b/asdf-step-ca-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-step-ca-plugin/CONTRIBUTING.md b/asdf-step-ca-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-step-ca-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-step-ca-plugin/README.adoc b/asdf-step-ca-plugin/README.adoc index d08e1dd2..6fe8354d 100644 --- a/asdf-step-ca-plugin/README.adoc +++ b/asdf-step-ca-plugin/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-step-ca -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-step-ca-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-step-ca-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-step-ca-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-step-ca-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://smallstep.com/certificates[step-ca]. -**All repos with foreign function interfaces MUST follow this standard:** +Private CA. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add step-ca https://github.com/hyperpolymath/asdf-step-ca-plugin.git +---- -=== Web Projects +step-ca: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all step-ca -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install step-ca latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global step-ca latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now step-ca commands are available +step-ca --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list step-ca -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local step-ca -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall step-ca ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-step-ca-plugin/README.md b/asdf-step-ca-plugin/README.md deleted file mode 100644 index b7069748..00000000 --- a/asdf-step-ca-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-step-ca - -[![Build](https://github.com/hyperpolymath/asdf-step-ca-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-step-ca-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-step-ca-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-step-ca-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [step-ca](https://smallstep.com/certificates). - -Private CA. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add step-ca https://github.com/hyperpolymath/asdf-step-ca-plugin.git -``` - -step-ca: - -```bash -# Show all installable versions -asdf list-all step-ca - -# Install specific version -asdf install step-ca latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global step-ca latest - -# Now step-ca commands are available -step-ca --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list step-ca - -# Set local version for current directory -asdf local step-ca - -# Uninstall a version -asdf uninstall step-ca -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-step-ca-plugin/SECURITY.adoc b/asdf-step-ca-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-step-ca-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-step-ca-plugin/SECURITY.md b/asdf-step-ca-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-step-ca-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-surrealdb-plugin/ABI-FFI-README.adoc b/asdf-surrealdb-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..193bfa2a --- /dev/null +++ b/asdf-surrealdb-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== SURREALDB ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/surrealdb.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libsurrealdb.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +surrealdb/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── surrealdb.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── surrealdb.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/surrealdb.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "surrealdb.h" + +int main() { + void* handle = surrealdb_init(); + if (!handle) return 1; + + int result = surrealdb_process(handle, 42); + if (result != 0) { + const char* err = surrealdb_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + surrealdb_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lsurrealdb -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import SURREALDB.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "surrealdb")] +extern "C" { + fn surrealdb_init() -> *mut std::ffi::c_void; + fn surrealdb_free(handle: *mut std::ffi::c_void); + fn surrealdb_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = surrealdb_init(); + assert!(!handle.is_null()); + + let result = surrealdb_process(handle, 42); + assert_eq!(result, 0); + + surrealdb_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libsurrealdb = "libsurrealdb" + +function init() + handle = ccall((:surrealdb_init, libsurrealdb), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:surrealdb_process, libsurrealdb), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:surrealdb_free, libsurrealdb), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/surrealdb.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-surrealdb-plugin/ABI-FFI-README.md b/asdf-surrealdb-plugin/ABI-FFI-README.md deleted file mode 100644 index 49f768ff..00000000 --- a/asdf-surrealdb-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# SURREALDB ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/surrealdb.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libsurrealdb.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -surrealdb/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── surrealdb.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── surrealdb.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/surrealdb.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "surrealdb.h" - -int main() { - void* handle = surrealdb_init(); - if (!handle) return 1; - - int result = surrealdb_process(handle, 42); - if (result != 0) { - const char* err = surrealdb_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - surrealdb_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lsurrealdb -L./zig-out/lib -``` - -### From Idris2 - -```idris -import SURREALDB.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "surrealdb")] -extern "C" { - fn surrealdb_init() -> *mut std::ffi::c_void; - fn surrealdb_free(handle: *mut std::ffi::c_void); - fn surrealdb_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = surrealdb_init(); - assert!(!handle.is_null()); - - let result = surrealdb_process(handle, 42); - assert_eq!(result, 0); - - surrealdb_free(handle); - } -} -``` - -### From Julia - -```julia -const libsurrealdb = "libsurrealdb" - -function init() - handle = ccall((:surrealdb_init, libsurrealdb), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:surrealdb_process, libsurrealdb), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:surrealdb_free, libsurrealdb), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/surrealdb.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-surrealdb-plugin/CODE_OF_CONDUCT.adoc b/asdf-surrealdb-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-surrealdb-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-surrealdb-plugin/CODE_OF_CONDUCT.md b/asdf-surrealdb-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-surrealdb-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-surrealdb-plugin/CONTRIBUTING.adoc b/asdf-surrealdb-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-surrealdb-plugin/CONTRIBUTING.adoc +++ b/asdf-surrealdb-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-surrealdb-plugin/CONTRIBUTING.md b/asdf-surrealdb-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-surrealdb-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-surrealdb-plugin/README.adoc b/asdf-surrealdb-plugin/README.adoc index d08e1dd2..c2f57df6 100644 --- a/asdf-surrealdb-plugin/README.adoc +++ b/asdf-surrealdb-plugin/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-surrealdb -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-surrealdb-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-surrealdb-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-surrealdb-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-surrealdb-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://surrealdb.com[SurrealDB]. -**All repos with foreign function interfaces MUST follow this standard:** +Multi-model database. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add surrealdb https://github.com/hyperpolymath/asdf-surrealdb-plugin.git +---- -=== Web Projects +surrealdb: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all surrealdb -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install surrealdb latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global surrealdb latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now surrealdb commands are available +surrealdb --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list surrealdb -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local surrealdb -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall surrealdb ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-surrealdb-plugin/README.md b/asdf-surrealdb-plugin/README.md deleted file mode 100644 index 4f493d5e..00000000 --- a/asdf-surrealdb-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-surrealdb - -[![Build](https://github.com/hyperpolymath/asdf-surrealdb-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-surrealdb-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-surrealdb-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-surrealdb-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [SurrealDB](https://surrealdb.com). - -Multi-model database. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add surrealdb https://github.com/hyperpolymath/asdf-surrealdb-plugin.git -``` - -surrealdb: - -```bash -# Show all installable versions -asdf list-all surrealdb - -# Install specific version -asdf install surrealdb latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global surrealdb latest - -# Now surrealdb commands are available -surrealdb --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list surrealdb - -# Set local version for current directory -asdf local surrealdb - -# Uninstall a version -asdf uninstall surrealdb -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-surrealdb-plugin/SECURITY.adoc b/asdf-surrealdb-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-surrealdb-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-surrealdb-plugin/SECURITY.md b/asdf-surrealdb-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-surrealdb-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-syft-plugin/ABI-FFI-README.adoc b/asdf-syft-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..4bb11341 --- /dev/null +++ b/asdf-syft-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== SYFT ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/syft.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libsyft.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +syft/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── syft.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── syft.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/syft.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "syft.h" + +int main() { + void* handle = syft_init(); + if (!handle) return 1; + + int result = syft_process(handle, 42); + if (result != 0) { + const char* err = syft_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + syft_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lsyft -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import SYFT.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "syft")] +extern "C" { + fn syft_init() -> *mut std::ffi::c_void; + fn syft_free(handle: *mut std::ffi::c_void); + fn syft_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = syft_init(); + assert!(!handle.is_null()); + + let result = syft_process(handle, 42); + assert_eq!(result, 0); + + syft_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libsyft = "libsyft" + +function init() + handle = ccall((:syft_init, libsyft), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:syft_process, libsyft), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:syft_free, libsyft), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/syft.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-syft-plugin/ABI-FFI-README.md b/asdf-syft-plugin/ABI-FFI-README.md deleted file mode 100644 index 8cebba02..00000000 --- a/asdf-syft-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# SYFT ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/syft.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libsyft.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -syft/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── syft.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── syft.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/syft.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "syft.h" - -int main() { - void* handle = syft_init(); - if (!handle) return 1; - - int result = syft_process(handle, 42); - if (result != 0) { - const char* err = syft_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - syft_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lsyft -L./zig-out/lib -``` - -### From Idris2 - -```idris -import SYFT.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "syft")] -extern "C" { - fn syft_init() -> *mut std::ffi::c_void; - fn syft_free(handle: *mut std::ffi::c_void); - fn syft_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = syft_init(); - assert!(!handle.is_null()); - - let result = syft_process(handle, 42); - assert_eq!(result, 0); - - syft_free(handle); - } -} -``` - -### From Julia - -```julia -const libsyft = "libsyft" - -function init() - handle = ccall((:syft_init, libsyft), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:syft_process, libsyft), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:syft_free, libsyft), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/syft.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-syft-plugin/CODE_OF_CONDUCT.adoc b/asdf-syft-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-syft-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-syft-plugin/CODE_OF_CONDUCT.md b/asdf-syft-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-syft-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-syft-plugin/CONTRIBUTING.adoc b/asdf-syft-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-syft-plugin/CONTRIBUTING.adoc +++ b/asdf-syft-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-syft-plugin/CONTRIBUTING.md b/asdf-syft-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-syft-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-syft-plugin/README.adoc b/asdf-syft-plugin/README.adoc index d08e1dd2..7be1d677 100644 --- a/asdf-syft-plugin/README.adoc +++ b/asdf-syft-plugin/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-syft -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-syft-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-syft-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-syft-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-syft-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://anchore.com/syft[Syft]. -**All repos with foreign function interfaces MUST follow this standard:** +SBOM generator. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add syft https://github.com/hyperpolymath/asdf-syft-plugin.git +---- -=== Web Projects +syft: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all syft -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install syft latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global syft latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now syft commands are available +syft --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list syft -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local syft -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall syft ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-syft-plugin/README.md b/asdf-syft-plugin/README.md deleted file mode 100644 index 3edd1438..00000000 --- a/asdf-syft-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-syft - -[![Build](https://github.com/hyperpolymath/asdf-syft-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-syft-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-syft-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-syft-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Syft](https://anchore.com/syft). - -SBOM generator. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add syft https://github.com/hyperpolymath/asdf-syft-plugin.git -``` - -syft: - -```bash -# Show all installable versions -asdf list-all syft - -# Install specific version -asdf install syft latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global syft latest - -# Now syft commands are available -syft --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list syft - -# Set local version for current directory -asdf local syft - -# Uninstall a version -asdf uninstall syft -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-syft-plugin/SECURITY.adoc b/asdf-syft-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-syft-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-syft-plugin/SECURITY.md b/asdf-syft-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-syft-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-taplo-plugin/ABI-FFI-README.adoc b/asdf-taplo-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..3c49729d --- /dev/null +++ b/asdf-taplo-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== TAPLO ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/taplo.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libtaplo.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +taplo/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── taplo.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── taplo.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/taplo.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "taplo.h" + +int main() { + void* handle = taplo_init(); + if (!handle) return 1; + + int result = taplo_process(handle, 42); + if (result != 0) { + const char* err = taplo_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + taplo_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -ltaplo -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import TAPLO.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "taplo")] +extern "C" { + fn taplo_init() -> *mut std::ffi::c_void; + fn taplo_free(handle: *mut std::ffi::c_void); + fn taplo_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = taplo_init(); + assert!(!handle.is_null()); + + let result = taplo_process(handle, 42); + assert_eq!(result, 0); + + taplo_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libtaplo = "libtaplo" + +function init() + handle = ccall((:taplo_init, libtaplo), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:taplo_process, libtaplo), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:taplo_free, libtaplo), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/taplo.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-taplo-plugin/ABI-FFI-README.md b/asdf-taplo-plugin/ABI-FFI-README.md deleted file mode 100644 index 121d0824..00000000 --- a/asdf-taplo-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# TAPLO ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/taplo.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libtaplo.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -taplo/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── taplo.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── taplo.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/taplo.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "taplo.h" - -int main() { - void* handle = taplo_init(); - if (!handle) return 1; - - int result = taplo_process(handle, 42); - if (result != 0) { - const char* err = taplo_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - taplo_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -ltaplo -L./zig-out/lib -``` - -### From Idris2 - -```idris -import TAPLO.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "taplo")] -extern "C" { - fn taplo_init() -> *mut std::ffi::c_void; - fn taplo_free(handle: *mut std::ffi::c_void); - fn taplo_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = taplo_init(); - assert!(!handle.is_null()); - - let result = taplo_process(handle, 42); - assert_eq!(result, 0); - - taplo_free(handle); - } -} -``` - -### From Julia - -```julia -const libtaplo = "libtaplo" - -function init() - handle = ccall((:taplo_init, libtaplo), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:taplo_process, libtaplo), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:taplo_free, libtaplo), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/taplo.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-taplo-plugin/CODE_OF_CONDUCT.adoc b/asdf-taplo-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-taplo-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-taplo-plugin/CODE_OF_CONDUCT.md b/asdf-taplo-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-taplo-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-taplo-plugin/CONTRIBUTING.adoc b/asdf-taplo-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-taplo-plugin/CONTRIBUTING.adoc +++ b/asdf-taplo-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-taplo-plugin/CONTRIBUTING.md b/asdf-taplo-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-taplo-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-taplo-plugin/README.adoc b/asdf-taplo-plugin/README.adoc index d08e1dd2..4eb4acb2 100644 --- a/asdf-taplo-plugin/README.adoc +++ b/asdf-taplo-plugin/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-taplo -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-taplo-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-taplo-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-taplo-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-taplo-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://taplo.tamasfe.dev[Taplo]. -**All repos with foreign function interfaces MUST follow this standard:** +TOML toolkit. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add taplo https://github.com/hyperpolymath/asdf-taplo-plugin.git +---- -=== Web Projects +taplo: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all taplo -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install taplo latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global taplo latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now taplo commands are available +taplo --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list taplo -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local taplo -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall taplo ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-taplo-plugin/README.md b/asdf-taplo-plugin/README.md deleted file mode 100644 index 68239dab..00000000 --- a/asdf-taplo-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-taplo - -[![Build](https://github.com/hyperpolymath/asdf-taplo-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-taplo-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-taplo-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-taplo-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Taplo](https://taplo.tamasfe.dev). - -TOML toolkit. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add taplo https://github.com/hyperpolymath/asdf-taplo-plugin.git -``` - -taplo: - -```bash -# Show all installable versions -asdf list-all taplo - -# Install specific version -asdf install taplo latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global taplo latest - -# Now taplo commands are available -taplo --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list taplo - -# Set local version for current directory -asdf local taplo - -# Uninstall a version -asdf uninstall taplo -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-taplo-plugin/SECURITY.adoc b/asdf-taplo-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-taplo-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-taplo-plugin/SECURITY.md b/asdf-taplo-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-taplo-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-trivy-plugin/ABI-FFI-README.adoc b/asdf-trivy-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..291621ba --- /dev/null +++ b/asdf-trivy-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== TRIVY ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/trivy.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libtrivy.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +trivy/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── trivy.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── trivy.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/trivy.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "trivy.h" + +int main() { + void* handle = trivy_init(); + if (!handle) return 1; + + int result = trivy_process(handle, 42); + if (result != 0) { + const char* err = trivy_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + trivy_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -ltrivy -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import TRIVY.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "trivy")] +extern "C" { + fn trivy_init() -> *mut std::ffi::c_void; + fn trivy_free(handle: *mut std::ffi::c_void); + fn trivy_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = trivy_init(); + assert!(!handle.is_null()); + + let result = trivy_process(handle, 42); + assert_eq!(result, 0); + + trivy_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libtrivy = "libtrivy" + +function init() + handle = ccall((:trivy_init, libtrivy), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:trivy_process, libtrivy), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:trivy_free, libtrivy), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/trivy.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-trivy-plugin/ABI-FFI-README.md b/asdf-trivy-plugin/ABI-FFI-README.md deleted file mode 100644 index 3c2bf6e4..00000000 --- a/asdf-trivy-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# TRIVY ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/trivy.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libtrivy.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -trivy/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── trivy.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── trivy.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/trivy.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "trivy.h" - -int main() { - void* handle = trivy_init(); - if (!handle) return 1; - - int result = trivy_process(handle, 42); - if (result != 0) { - const char* err = trivy_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - trivy_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -ltrivy -L./zig-out/lib -``` - -### From Idris2 - -```idris -import TRIVY.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "trivy")] -extern "C" { - fn trivy_init() -> *mut std::ffi::c_void; - fn trivy_free(handle: *mut std::ffi::c_void); - fn trivy_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = trivy_init(); - assert!(!handle.is_null()); - - let result = trivy_process(handle, 42); - assert_eq!(result, 0); - - trivy_free(handle); - } -} -``` - -### From Julia - -```julia -const libtrivy = "libtrivy" - -function init() - handle = ccall((:trivy_init, libtrivy), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:trivy_process, libtrivy), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:trivy_free, libtrivy), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/trivy.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-trivy-plugin/CODE_OF_CONDUCT.adoc b/asdf-trivy-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-trivy-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-trivy-plugin/CODE_OF_CONDUCT.md b/asdf-trivy-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-trivy-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-trivy-plugin/CONTRIBUTING.adoc b/asdf-trivy-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-trivy-plugin/CONTRIBUTING.adoc +++ b/asdf-trivy-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-trivy-plugin/CONTRIBUTING.md b/asdf-trivy-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-trivy-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-trivy-plugin/README.adoc b/asdf-trivy-plugin/README.adoc index d08e1dd2..ec6dab41 100644 --- a/asdf-trivy-plugin/README.adoc +++ b/asdf-trivy-plugin/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-trivy -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-trivy-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-trivy-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-trivy-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-trivy-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://trivy.dev[Trivy]. -**All repos with foreign function interfaces MUST follow this standard:** +Security scanner. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add trivy https://github.com/hyperpolymath/asdf-trivy-plugin.git +---- -=== Web Projects +trivy: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all trivy -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install trivy latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global trivy latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now trivy commands are available +trivy --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list trivy -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local trivy -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall trivy ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-trivy-plugin/README.md b/asdf-trivy-plugin/README.md deleted file mode 100644 index 4084e013..00000000 --- a/asdf-trivy-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-trivy - -[![Build](https://github.com/hyperpolymath/asdf-trivy-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-trivy-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-trivy-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-trivy-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Trivy](https://trivy.dev). - -Security scanner. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add trivy https://github.com/hyperpolymath/asdf-trivy-plugin.git -``` - -trivy: - -```bash -# Show all installable versions -asdf list-all trivy - -# Install specific version -asdf install trivy latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global trivy latest - -# Now trivy commands are available -trivy --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list trivy - -# Set local version for current directory -asdf local trivy - -# Uninstall a version -asdf uninstall trivy -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-trivy-plugin/SECURITY.adoc b/asdf-trivy-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-trivy-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-trivy-plugin/SECURITY.md b/asdf-trivy-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-trivy-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-ui-plugin/ABI-FFI-README.adoc b/asdf-ui-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..62673536 --- /dev/null +++ b/asdf-ui-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== UI ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/ui.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libui.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +ui/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── ui.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── ui.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/ui.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "ui.h" + +int main() { + void* handle = ui_init(); + if (!handle) return 1; + + int result = ui_process(handle, 42); + if (result != 0) { + const char* err = ui_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + ui_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lui -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import UI.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "ui")] +extern "C" { + fn ui_init() -> *mut std::ffi::c_void; + fn ui_free(handle: *mut std::ffi::c_void); + fn ui_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = ui_init(); + assert!(!handle.is_null()); + + let result = ui_process(handle, 42); + assert_eq!(result, 0); + + ui_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libui = "libui" + +function init() + handle = ccall((:ui_init, libui), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:ui_process, libui), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:ui_free, libui), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/ui.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-ui-plugin/ABI-FFI-README.md b/asdf-ui-plugin/ABI-FFI-README.md deleted file mode 100644 index 42a9d25c..00000000 --- a/asdf-ui-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# UI ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/ui.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libui.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -ui/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── ui.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── ui.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/ui.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "ui.h" - -int main() { - void* handle = ui_init(); - if (!handle) return 1; - - int result = ui_process(handle, 42); - if (result != 0) { - const char* err = ui_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - ui_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lui -L./zig-out/lib -``` - -### From Idris2 - -```idris -import UI.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "ui")] -extern "C" { - fn ui_init() -> *mut std::ffi::c_void; - fn ui_free(handle: *mut std::ffi::c_void); - fn ui_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = ui_init(); - assert!(!handle.is_null()); - - let result = ui_process(handle, 42); - assert_eq!(result, 0); - - ui_free(handle); - } -} -``` - -### From Julia - -```julia -const libui = "libui" - -function init() - handle = ccall((:ui_init, libui), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:ui_process, libui), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:ui_free, libui), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/ui.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-ui-plugin/CODE_OF_CONDUCT.adoc b/asdf-ui-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-ui-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-ui-plugin/CODE_OF_CONDUCT.md b/asdf-ui-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-ui-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-ui-plugin/CONTRIBUTING.adoc b/asdf-ui-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-ui-plugin/CONTRIBUTING.adoc +++ b/asdf-ui-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-ui-plugin/CONTRIBUTING.md b/asdf-ui-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-ui-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-ui-plugin/README.adoc b/asdf-ui-plugin/README.adoc index 8c19e39d..f52f4ce3 100644 --- a/asdf-ui-plugin/README.adoc +++ b/asdf-ui-plugin/README.adoc @@ -1,101 +1,53 @@ -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] -image:https://img.shields.io/badge/Philosophy-Palimpsest-indigo.svg[Palimpsest,link="https://github.com/hyperpolymath/palimpsest-license"] +== asdf-ui-plugin +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] +image:https://img.shields.io/badge/Philosophy-Palimpsest-indigo.svg[Palimpsest,link="`https://github.com/hyperpolymath/palimpsest-license`"] -// SPDX-License-Identifier: CC-BY-SA-4.0 -= asdf-ui-plugin +Visual user interface for the https://asdf-vm.com[asdf] version manager +ecosystem. -:toc: macro -:toc-title: Contents -:toclevels: 2 +=== Status -A fully functional **asdf plugin** providing a terminal user interface for managing asdf plugins and versions. +____ +*Note:* This repository is currently a placeholder. Implementation is +pending. +____ -== Status +=== Overview -[NOTE] -==== -**Implementation Complete** - Core plugin functionality is fully working. -==== +`+asdf-ui-plugin+` will provide a graphical interface for managing asdf +plugins and tool versions: -== Features +* *Plugin browser* - Visual discovery of available plugins +* *Version manager* - GUI for installing/switching versions +* *Status dashboard* - Overview of installed tools +* *Update notifications* - Track available updates -* **Version Management**: List, install, and switch between versions -* **Interactive TUI**: Terminal user interface for easy navigation -* **Dashboard View**: Overview of installed plugins and versions -* **Version Selector**: Interactive picker for version switching +=== Technology Stack -== Installation +* *UI Framework*: Tauri 2.0+ (Rust backend + web frontend) +* *Frontend*: AffineScript (type-safe JavaScript) +* *Styling*: TailwindCSS -[source,bash] ----- -asdf plugin add asdf-ui https://github.com/hyperpolymath/asdf-ui-plugin.git -asdf install asdf-ui 1.0.0 -asdf global asdf-ui 1.0.0 ----- +=== Related Projects -== Usage - -[source,bash] ----- -# Launch interactive TUI -asdf-ui - -# Show plugin dashboard -asdf-ui dashboard - -# Interactive version selector -asdf-ui versions - -# Display help -asdf-ui help ----- - -== Components - -[cols="1,3"] +[width="100%",cols="40%,60%",options="header",] |=== -| Component | Description - -| `bin/list-all` -| Lists all available versions - -| `bin/download` -| Downloads specified version +|Project |Relationship +|https://github.com/hyperpolymath/asdf-metaiconic-plugin[asdf-metaiconic-plugin] +|Metadata provider -| `bin/install` -| Installs version and creates asdf-ui binary - -| `lib/utils.bash` -| Core utility functions and TUI implementation - -| `.github/workflows/ci.yml` -| Continuous integration with ShellCheck - -| `.github/workflows/mirror.yml` -| Hub-and-spoke mirroring to GitLab, Codeberg, Bitbucket - -| `.github/workflows/instant-sync.yml` -| Automatic forge propagation on push/release - -| `.claude/CLAUDE.md` -| Hyperpolymath development standards (language policy) +|https://github.com/hyperpolymath/asdf-security-plugin[asdf-security-plugin] +|Security layer |=== -See link:ROADMAP.adoc[ROADMAP.adoc] for development history and future plans. - -== Development Standards - -This project follows the **Hyperpolymath Language Policy**: - -* *Primary*: AffineScript, Rust, Deno -* *Mobile*: Tauri 2.0+ or Dioxus (no Kotlin/Swift) -* *Backend*: Gleam (BEAM or JS target) -* *Config*: Nickel, Guile Scheme -* *Package Management*: Guix (primary), Guix (fallback) +=== License -See `.claude/CLAUDE.md` for full policy details. +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -== License +''''' -MPL-2.0 +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-ui-plugin/README.md b/asdf-ui-plugin/README.md deleted file mode 100644 index 77018b32..00000000 --- a/asdf-ui-plugin/README.md +++ /dev/null @@ -1,40 +0,0 @@ -# asdf-ui-plugin - -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] -image:https://img.shields.io/badge/Philosophy-Palimpsest-indigo.svg[Palimpsest,link="https://github.com/hyperpolymath/palimpsest-license"] - -Visual user interface for the [asdf](https://asdf-vm.com) version manager ecosystem. - -## Status - -> **Note:** This repository is currently a placeholder. Implementation is pending. - -## Overview - -`asdf-ui-plugin` will provide a graphical interface for managing asdf plugins and tool versions: - -- **Plugin browser** - Visual discovery of available plugins -- **Version manager** - GUI for installing/switching versions -- **Status dashboard** - Overview of installed tools -- **Update notifications** - Track available updates - -## Technology Stack - -- **UI Framework**: Tauri 2.0+ (Rust backend + web frontend) -- **Frontend**: AffineScript (type-safe JavaScript) -- **Styling**: TailwindCSS - -## Related Projects - -| Project | Relationship | -|---------|--------------| -| [asdf-metaiconic-plugin](https://github.com/hyperpolymath/asdf-metaiconic-plugin) | Metadata provider | -| [asdf-security-plugin](https://github.com/hyperpolymath/asdf-security-plugin) | Security layer | - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-ui-plugin/SECURITY.adoc b/asdf-ui-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-ui-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-ui-plugin/SECURITY.md b/asdf-ui-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-ui-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-varnish-plugin/ABI-FFI-README.adoc b/asdf-varnish-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..be2b48d7 --- /dev/null +++ b/asdf-varnish-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== VARNISH ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/varnish.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libvarnish.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +varnish/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── varnish.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── varnish.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/varnish.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "varnish.h" + +int main() { + void* handle = varnish_init(); + if (!handle) return 1; + + int result = varnish_process(handle, 42); + if (result != 0) { + const char* err = varnish_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + varnish_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lvarnish -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import VARNISH.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "varnish")] +extern "C" { + fn varnish_init() -> *mut std::ffi::c_void; + fn varnish_free(handle: *mut std::ffi::c_void); + fn varnish_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = varnish_init(); + assert!(!handle.is_null()); + + let result = varnish_process(handle, 42); + assert_eq!(result, 0); + + varnish_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libvarnish = "libvarnish" + +function init() + handle = ccall((:varnish_init, libvarnish), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:varnish_process, libvarnish), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:varnish_free, libvarnish), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/varnish.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-varnish-plugin/ABI-FFI-README.md b/asdf-varnish-plugin/ABI-FFI-README.md deleted file mode 100644 index db34442f..00000000 --- a/asdf-varnish-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# VARNISH ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/varnish.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libvarnish.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -varnish/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── varnish.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── varnish.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/varnish.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "varnish.h" - -int main() { - void* handle = varnish_init(); - if (!handle) return 1; - - int result = varnish_process(handle, 42); - if (result != 0) { - const char* err = varnish_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - varnish_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lvarnish -L./zig-out/lib -``` - -### From Idris2 - -```idris -import VARNISH.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "varnish")] -extern "C" { - fn varnish_init() -> *mut std::ffi::c_void; - fn varnish_free(handle: *mut std::ffi::c_void); - fn varnish_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = varnish_init(); - assert!(!handle.is_null()); - - let result = varnish_process(handle, 42); - assert_eq!(result, 0); - - varnish_free(handle); - } -} -``` - -### From Julia - -```julia -const libvarnish = "libvarnish" - -function init() - handle = ccall((:varnish_init, libvarnish), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:varnish_process, libvarnish), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:varnish_free, libvarnish), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/varnish.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-varnish-plugin/CODE_OF_CONDUCT.adoc b/asdf-varnish-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-varnish-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-varnish-plugin/CODE_OF_CONDUCT.md b/asdf-varnish-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-varnish-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-varnish-plugin/CONTRIBUTING.adoc b/asdf-varnish-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-varnish-plugin/CONTRIBUTING.adoc +++ b/asdf-varnish-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-varnish-plugin/CONTRIBUTING.md b/asdf-varnish-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-varnish-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-varnish-plugin/README.adoc b/asdf-varnish-plugin/README.adoc index d08e1dd2..b2d14bf4 100644 --- a/asdf-varnish-plugin/README.adoc +++ b/asdf-varnish-plugin/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-varnish -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-varnish-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-varnish-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-varnish-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-varnish-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://varnish-cache.org[Varnish +Cache]. -**All repos with foreign function interfaces MUST follow this standard:** +HTTP accelerator. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add varnish https://github.com/hyperpolymath/asdf-varnish-plugin.git +---- -=== Web Projects +varnish: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all varnish -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install varnish latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global varnish latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now varnish commands are available +varnish --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list varnish -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local varnish -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall varnish ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-varnish-plugin/README.md b/asdf-varnish-plugin/README.md deleted file mode 100644 index 4ee2b09b..00000000 --- a/asdf-varnish-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-varnish - -[![Build](https://github.com/hyperpolymath/asdf-varnish-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-varnish-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-varnish-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-varnish-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Varnish Cache](https://varnish-cache.org). - -HTTP accelerator. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add varnish https://github.com/hyperpolymath/asdf-varnish-plugin.git -``` - -varnish: - -```bash -# Show all installable versions -asdf list-all varnish - -# Install specific version -asdf install varnish latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global varnish latest - -# Now varnish commands are available -varnish --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list varnish - -# Set local version for current directory -asdf local varnish - -# Uninstall a version -asdf uninstall varnish -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-varnish-plugin/SECURITY.adoc b/asdf-varnish-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-varnish-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-varnish-plugin/SECURITY.md b/asdf-varnish-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-varnish-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-virtuoso-plugin/ABI-FFI-README.adoc b/asdf-virtuoso-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..c71acab7 --- /dev/null +++ b/asdf-virtuoso-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== VIRTUOSO ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/virtuoso.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libvirtuoso.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +virtuoso/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── virtuoso.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── virtuoso.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/virtuoso.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "virtuoso.h" + +int main() { + void* handle = virtuoso_init(); + if (!handle) return 1; + + int result = virtuoso_process(handle, 42); + if (result != 0) { + const char* err = virtuoso_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + virtuoso_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lvirtuoso -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import VIRTUOSO.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "virtuoso")] +extern "C" { + fn virtuoso_init() -> *mut std::ffi::c_void; + fn virtuoso_free(handle: *mut std::ffi::c_void); + fn virtuoso_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = virtuoso_init(); + assert!(!handle.is_null()); + + let result = virtuoso_process(handle, 42); + assert_eq!(result, 0); + + virtuoso_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libvirtuoso = "libvirtuoso" + +function init() + handle = ccall((:virtuoso_init, libvirtuoso), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:virtuoso_process, libvirtuoso), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:virtuoso_free, libvirtuoso), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/virtuoso.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-virtuoso-plugin/ABI-FFI-README.md b/asdf-virtuoso-plugin/ABI-FFI-README.md deleted file mode 100644 index 4753369a..00000000 --- a/asdf-virtuoso-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# VIRTUOSO ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/virtuoso.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libvirtuoso.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -virtuoso/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── virtuoso.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── virtuoso.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/virtuoso.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "virtuoso.h" - -int main() { - void* handle = virtuoso_init(); - if (!handle) return 1; - - int result = virtuoso_process(handle, 42); - if (result != 0) { - const char* err = virtuoso_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - virtuoso_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lvirtuoso -L./zig-out/lib -``` - -### From Idris2 - -```idris -import VIRTUOSO.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "virtuoso")] -extern "C" { - fn virtuoso_init() -> *mut std::ffi::c_void; - fn virtuoso_free(handle: *mut std::ffi::c_void); - fn virtuoso_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = virtuoso_init(); - assert!(!handle.is_null()); - - let result = virtuoso_process(handle, 42); - assert_eq!(result, 0); - - virtuoso_free(handle); - } -} -``` - -### From Julia - -```julia -const libvirtuoso = "libvirtuoso" - -function init() - handle = ccall((:virtuoso_init, libvirtuoso), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:virtuoso_process, libvirtuoso), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:virtuoso_free, libvirtuoso), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/virtuoso.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-virtuoso-plugin/CODE_OF_CONDUCT.adoc b/asdf-virtuoso-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-virtuoso-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-virtuoso-plugin/CODE_OF_CONDUCT.md b/asdf-virtuoso-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-virtuoso-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-virtuoso-plugin/CONTRIBUTING.adoc b/asdf-virtuoso-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-virtuoso-plugin/CONTRIBUTING.adoc +++ b/asdf-virtuoso-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-virtuoso-plugin/CONTRIBUTING.md b/asdf-virtuoso-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-virtuoso-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-virtuoso-plugin/README.adoc b/asdf-virtuoso-plugin/README.adoc index d08e1dd2..4644e8f3 100644 --- a/asdf-virtuoso-plugin/README.adoc +++ b/asdf-virtuoso-plugin/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-virtuoso -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-virtuoso-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-virtuoso-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-virtuoso-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-virtuoso-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://virtuoso.openlinksw.com[Virtuoso]. -**All repos with foreign function interfaces MUST follow this standard:** +RDF triple store. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add virtuoso https://github.com/hyperpolymath/asdf-virtuoso-plugin.git +---- -=== Web Projects +virtuoso: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all virtuoso -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install virtuoso latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global virtuoso latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now virtuoso commands are available +virtuoso --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list virtuoso -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local virtuoso -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall virtuoso ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-virtuoso-plugin/README.md b/asdf-virtuoso-plugin/README.md deleted file mode 100644 index 211e1f63..00000000 --- a/asdf-virtuoso-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-virtuoso - -[![Build](https://github.com/hyperpolymath/asdf-virtuoso-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-virtuoso-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-virtuoso-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-virtuoso-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Virtuoso](https://virtuoso.openlinksw.com). - -RDF triple store. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add virtuoso https://github.com/hyperpolymath/asdf-virtuoso-plugin.git -``` - -virtuoso: - -```bash -# Show all installable versions -asdf list-all virtuoso - -# Install specific version -asdf install virtuoso latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global virtuoso latest - -# Now virtuoso commands are available -virtuoso --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list virtuoso - -# Set local version for current directory -asdf local virtuoso - -# Uninstall a version -asdf uninstall virtuoso -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-virtuoso-plugin/SECURITY.adoc b/asdf-virtuoso-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-virtuoso-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-virtuoso-plugin/SECURITY.md b/asdf-virtuoso-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-virtuoso-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-vlang-plugin/ABI-FFI-README.adoc b/asdf-vlang-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..a21b7a8b --- /dev/null +++ b/asdf-vlang-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== VLANG ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/vlang.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libvlang.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +vlang/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── vlang.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── vlang.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/vlang.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "vlang.h" + +int main() { + void* handle = vlang_init(); + if (!handle) return 1; + + int result = vlang_process(handle, 42); + if (result != 0) { + const char* err = vlang_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + vlang_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lvlang -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import VLANG.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "vlang")] +extern "C" { + fn vlang_init() -> *mut std::ffi::c_void; + fn vlang_free(handle: *mut std::ffi::c_void); + fn vlang_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = vlang_init(); + assert!(!handle.is_null()); + + let result = vlang_process(handle, 42); + assert_eq!(result, 0); + + vlang_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libvlang = "libvlang" + +function init() + handle = ccall((:vlang_init, libvlang), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:vlang_process, libvlang), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:vlang_free, libvlang), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/vlang.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-vlang-plugin/ABI-FFI-README.md b/asdf-vlang-plugin/ABI-FFI-README.md deleted file mode 100644 index 2ce05e85..00000000 --- a/asdf-vlang-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# VLANG ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/vlang.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libvlang.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -vlang/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── vlang.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── vlang.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/vlang.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "vlang.h" - -int main() { - void* handle = vlang_init(); - if (!handle) return 1; - - int result = vlang_process(handle, 42); - if (result != 0) { - const char* err = vlang_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - vlang_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lvlang -L./zig-out/lib -``` - -### From Idris2 - -```idris -import VLANG.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "vlang")] -extern "C" { - fn vlang_init() -> *mut std::ffi::c_void; - fn vlang_free(handle: *mut std::ffi::c_void); - fn vlang_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = vlang_init(); - assert!(!handle.is_null()); - - let result = vlang_process(handle, 42); - assert_eq!(result, 0); - - vlang_free(handle); - } -} -``` - -### From Julia - -```julia -const libvlang = "libvlang" - -function init() - handle = ccall((:vlang_init, libvlang), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:vlang_process, libvlang), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:vlang_free, libvlang), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/vlang.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-vlang-plugin/CODE_OF_CONDUCT.adoc b/asdf-vlang-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-vlang-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-vlang-plugin/CODE_OF_CONDUCT.md b/asdf-vlang-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-vlang-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-vlang-plugin/CONTRIBUTING.adoc b/asdf-vlang-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-vlang-plugin/CONTRIBUTING.adoc +++ b/asdf-vlang-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-vlang-plugin/CONTRIBUTING.md b/asdf-vlang-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-vlang-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-vlang-plugin/README.adoc b/asdf-vlang-plugin/README.adoc index d08e1dd2..e0d2a18f 100644 --- a/asdf-vlang-plugin/README.adoc +++ b/asdf-vlang-plugin/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-vlang -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-vlang-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-vlang-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-vlang-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-vlang-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://vlang.io[V]. -**All repos with foreign function interfaces MUST follow this standard:** +Simple fast language. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add vlang https://github.com/hyperpolymath/asdf-vlang-plugin.git +---- -=== Web Projects +vlang: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all vlang -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install vlang latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global vlang latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now vlang commands are available +vlang --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list vlang -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local vlang -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall vlang ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-vlang-plugin/README.md b/asdf-vlang-plugin/README.md deleted file mode 100644 index 06f2397c..00000000 --- a/asdf-vlang-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-vlang - -[![Build](https://github.com/hyperpolymath/asdf-vlang-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-vlang-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-vlang-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-vlang-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [V](https://vlang.io). - -Simple fast language. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add vlang https://github.com/hyperpolymath/asdf-vlang-plugin.git -``` - -vlang: - -```bash -# Show all installable versions -asdf list-all vlang - -# Install specific version -asdf install vlang latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global vlang latest - -# Now vlang commands are available -vlang --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list vlang - -# Set local version for current directory -asdf local vlang - -# Uninstall a version -asdf uninstall vlang -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-vlang-plugin/SECURITY.adoc b/asdf-vlang-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-vlang-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-vlang-plugin/SECURITY.md b/asdf-vlang-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-vlang-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-yj-plugin/ABI-FFI-README.adoc b/asdf-yj-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..af3fca8a --- /dev/null +++ b/asdf-yj-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== YJ ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/yj.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libyj.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +yj/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── yj.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── yj.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/yj.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "yj.h" + +int main() { + void* handle = yj_init(); + if (!handle) return 1; + + int result = yj_process(handle, 42); + if (result != 0) { + const char* err = yj_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + yj_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lyj -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import YJ.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "yj")] +extern "C" { + fn yj_init() -> *mut std::ffi::c_void; + fn yj_free(handle: *mut std::ffi::c_void); + fn yj_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = yj_init(); + assert!(!handle.is_null()); + + let result = yj_process(handle, 42); + assert_eq!(result, 0); + + yj_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libyj = "libyj" + +function init() + handle = ccall((:yj_init, libyj), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:yj_process, libyj), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:yj_free, libyj), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/yj.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-yj-plugin/ABI-FFI-README.md b/asdf-yj-plugin/ABI-FFI-README.md deleted file mode 100644 index bd5df5c7..00000000 --- a/asdf-yj-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# YJ ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/yj.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libyj.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -yj/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── yj.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── yj.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/yj.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "yj.h" - -int main() { - void* handle = yj_init(); - if (!handle) return 1; - - int result = yj_process(handle, 42); - if (result != 0) { - const char* err = yj_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - yj_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lyj -L./zig-out/lib -``` - -### From Idris2 - -```idris -import YJ.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "yj")] -extern "C" { - fn yj_init() -> *mut std::ffi::c_void; - fn yj_free(handle: *mut std::ffi::c_void); - fn yj_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = yj_init(); - assert!(!handle.is_null()); - - let result = yj_process(handle, 42); - assert_eq!(result, 0); - - yj_free(handle); - } -} -``` - -### From Julia - -```julia -const libyj = "libyj" - -function init() - handle = ccall((:yj_init, libyj), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:yj_process, libyj), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:yj_free, libyj), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/yj.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-yj-plugin/CODE_OF_CONDUCT.adoc b/asdf-yj-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-yj-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-yj-plugin/CODE_OF_CONDUCT.md b/asdf-yj-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-yj-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-yj-plugin/CONTRIBUTING.adoc b/asdf-yj-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-yj-plugin/CONTRIBUTING.adoc +++ b/asdf-yj-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-yj-plugin/CONTRIBUTING.md b/asdf-yj-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-yj-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-yj-plugin/README.adoc b/asdf-yj-plugin/README.adoc index d08e1dd2..692d1bf4 100644 --- a/asdf-yj-plugin/README.adoc +++ b/asdf-yj-plugin/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-yj -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-yj-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-yj-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-yj-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-yj-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://github.com/sclevine/yj[yj]. -**All repos with foreign function interfaces MUST follow this standard:** +YAML/JSON/TOML converter. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add yj https://github.com/hyperpolymath/asdf-yj-plugin.git +---- -=== Web Projects +yj: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all yj -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install yj latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global yj latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now yj commands are available +yj --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list yj -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local yj -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall yj ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-yj-plugin/README.md b/asdf-yj-plugin/README.md deleted file mode 100644 index a99453a7..00000000 --- a/asdf-yj-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-yj - -[![Build](https://github.com/hyperpolymath/asdf-yj-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-yj-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-yj-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-yj-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [yj](https://github.com/sclevine/yj). - -YAML/JSON/TOML converter. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add yj https://github.com/hyperpolymath/asdf-yj-plugin.git -``` - -yj: - -```bash -# Show all installable versions -asdf list-all yj - -# Install specific version -asdf install yj latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global yj latest - -# Now yj commands are available -yj --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list yj - -# Set local version for current directory -asdf local yj - -# Uninstall a version -asdf uninstall yj -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-yj-plugin/SECURITY.adoc b/asdf-yj-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-yj-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-yj-plugin/SECURITY.md b/asdf-yj-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-yj-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-yq-plugin/ABI-FFI-README.adoc b/asdf-yq-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..3aec672a --- /dev/null +++ b/asdf-yq-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== YQ ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/yq.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libyq.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +yq/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── yq.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── yq.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/yq.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "yq.h" + +int main() { + void* handle = yq_init(); + if (!handle) return 1; + + int result = yq_process(handle, 42); + if (result != 0) { + const char* err = yq_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + yq_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lyq -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import YQ.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "yq")] +extern "C" { + fn yq_init() -> *mut std::ffi::c_void; + fn yq_free(handle: *mut std::ffi::c_void); + fn yq_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = yq_init(); + assert!(!handle.is_null()); + + let result = yq_process(handle, 42); + assert_eq!(result, 0); + + yq_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libyq = "libyq" + +function init() + handle = ccall((:yq_init, libyq), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:yq_process, libyq), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:yq_free, libyq), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/yq.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-yq-plugin/ABI-FFI-README.md b/asdf-yq-plugin/ABI-FFI-README.md deleted file mode 100644 index 1789a0ea..00000000 --- a/asdf-yq-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# YQ ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/yq.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libyq.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -yq/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── yq.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── yq.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/yq.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "yq.h" - -int main() { - void* handle = yq_init(); - if (!handle) return 1; - - int result = yq_process(handle, 42); - if (result != 0) { - const char* err = yq_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - yq_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lyq -L./zig-out/lib -``` - -### From Idris2 - -```idris -import YQ.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "yq")] -extern "C" { - fn yq_init() -> *mut std::ffi::c_void; - fn yq_free(handle: *mut std::ffi::c_void); - fn yq_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = yq_init(); - assert!(!handle.is_null()); - - let result = yq_process(handle, 42); - assert_eq!(result, 0); - - yq_free(handle); - } -} -``` - -### From Julia - -```julia -const libyq = "libyq" - -function init() - handle = ccall((:yq_init, libyq), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:yq_process, libyq), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:yq_free, libyq), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/yq.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-yq-plugin/CODE_OF_CONDUCT.adoc b/asdf-yq-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-yq-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-yq-plugin/CODE_OF_CONDUCT.md b/asdf-yq-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-yq-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-yq-plugin/CONTRIBUTING.adoc b/asdf-yq-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-yq-plugin/CONTRIBUTING.adoc +++ b/asdf-yq-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-yq-plugin/CONTRIBUTING.md b/asdf-yq-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-yq-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-yq-plugin/README.adoc b/asdf-yq-plugin/README.adoc index d08e1dd2..0cc876bf 100644 --- a/asdf-yq-plugin/README.adoc +++ b/asdf-yq-plugin/README.adoc @@ -1,101 +1,83 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-yq -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-yq-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-yq-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-yq-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-yq-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for +https://mikefarah.gitbook.io/yq[yq]. -**All repos with foreign function interfaces MUST follow this standard:** +YAML processor. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add yq https://github.com/hyperpolymath/asdf-yq-plugin.git +---- -=== Web Projects +yq: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all yq -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install yq latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global yq latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now yq commands are available +yq --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list yq -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local yq -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall yq ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-yq-plugin/README.md b/asdf-yq-plugin/README.md deleted file mode 100644 index 32b85db9..00000000 --- a/asdf-yq-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-yq - -[![Build](https://github.com/hyperpolymath/asdf-yq-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-yq-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-yq-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-yq-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [yq](https://mikefarah.gitbook.io/yq). - -YAML processor. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add yq https://github.com/hyperpolymath/asdf-yq-plugin.git -``` - -yq: - -```bash -# Show all installable versions -asdf list-all yq - -# Install specific version -asdf install yq latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global yq latest - -# Now yq commands are available -yq --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list yq - -# Set local version for current directory -asdf local yq - -# Uninstall a version -asdf uninstall yq -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-yq-plugin/SECURITY.adoc b/asdf-yq-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-yq-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-yq-plugin/SECURITY.md b/asdf-yq-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-yq-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/asdf-zig-plugin/ABI-FFI-README.adoc b/asdf-zig-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..a3b3b061 --- /dev/null +++ b/asdf-zig-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== ZIG ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/zig.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libzig.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +zig/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── zig.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── zig.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/zig.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "zig.h" + +int main() { + void* handle = zig_init(); + if (!handle) return 1; + + int result = zig_process(handle, 42); + if (result != 0) { + const char* err = zig_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + zig_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lzig -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import ZIG.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "zig")] +extern "C" { + fn zig_init() -> *mut std::ffi::c_void; + fn zig_free(handle: *mut std::ffi::c_void); + fn zig_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = zig_init(); + assert!(!handle.is_null()); + + let result = zig_process(handle, 42); + assert_eq!(result, 0); + + zig_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libzig = "libzig" + +function init() + handle = ccall((:zig_init, libzig), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:zig_process, libzig), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:zig_free, libzig), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/zig.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-zig-plugin/ABI-FFI-README.md b/asdf-zig-plugin/ABI-FFI-README.md deleted file mode 100644 index 32bf6cd4..00000000 --- a/asdf-zig-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# ZIG ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/zig.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libzig.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -zig/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── zig.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── zig.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/zig.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "zig.h" - -int main() { - void* handle = zig_init(); - if (!handle) return 1; - - int result = zig_process(handle, 42); - if (result != 0) { - const char* err = zig_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - zig_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lzig -L./zig-out/lib -``` - -### From Idris2 - -```idris -import ZIG.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "zig")] -extern "C" { - fn zig_init() -> *mut std::ffi::c_void; - fn zig_free(handle: *mut std::ffi::c_void); - fn zig_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = zig_init(); - assert!(!handle.is_null()); - - let result = zig_process(handle, 42); - assert_eq!(result, 0); - - zig_free(handle); - } -} -``` - -### From Julia - -```julia -const libzig = "libzig" - -function init() - handle = ccall((:zig_init, libzig), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:zig_process, libzig), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:zig_free, libzig), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/zig.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-zig-plugin/CODE_OF_CONDUCT.adoc b/asdf-zig-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..be3a3fca --- /dev/null +++ b/asdf-zig-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,23 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We as members, contributors, and leaders pledge to make participation in +our community a harassment-free experience for everyone. + +=== Our Standards + +Examples of behavior that contributes to a positive environment: * Using +welcoming and inclusive language * Being respectful of differing +viewpoints and experiences * Gracefully accepting constructive criticism +* Focusing on what is best for the community + +=== Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may +be reported to the project maintainers. + +=== Attribution + +This Code of Conduct is adapted from the Contributor Covenant, version +2.1. diff --git a/asdf-zig-plugin/CODE_OF_CONDUCT.md b/asdf-zig-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index 7d02d33d..00000000 --- a/asdf-zig-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,23 +0,0 @@ -# Contributor Covenant Code of Conduct - -## Our Pledge - -We as members, contributors, and leaders pledge to make participation in our -community a harassment-free experience for everyone. - -## Our Standards - -Examples of behavior that contributes to a positive environment: -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community - -## Enforcement - -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported to the project maintainers. - -## Attribution - -This Code of Conduct is adapted from the Contributor Covenant, version 2.1. diff --git a/asdf-zig-plugin/CONTRIBUTING.adoc b/asdf-zig-plugin/CONTRIBUTING.adoc index 5b225c9b..084ee525 100644 --- a/asdf-zig-plugin/CONTRIBUTING.adoc +++ b/asdf-zig-plugin/CONTRIBUTING.adoc @@ -1,30 +1,109 @@ -= Contributing +== Clone the repository -Thank you for your interest in contributing! +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -== Quick Start +== Using Guix (recommended for reproducibility) -1. Fork the repository -2. Create a feature branch -3. Make your changes -4. Run tests: `asdf plugin test zig .` -5. Submit a pull request +guix develop -== Code Style +== Or using toolbox/distrobox -* Use ShellCheck for linting -* Follow existing code patterns -* Add SPDX headers to new files +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -== Testing +== Verify setup -Test your changes with: +just check # or: cargo check / mix compile / etc. just test # Run test +suite -[source,bash] ----- -asdf plugin test zig . --asdf-tool-version latest ----- +.... -== License +### Repository Structure +.... -Contributions are licensed under MPL-2.0. +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-zig-plugin/CONTRIBUTING.md b/asdf-zig-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-zig-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-zig-plugin/SECURITY.adoc b/asdf-zig-plugin/SECURITY.adoc new file mode 100644 index 00000000..7f2e3358 --- /dev/null +++ b/asdf-zig-plugin/SECURITY.adoc @@ -0,0 +1,20 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|latest |:white_check_mark: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities via GitHub Security Advisories. + +[arabic] +. Go to the Security tab of this repository +. Click "`Report a vulnerability`" +. Provide details of the vulnerability + +We will respond within 48 hours and work with you to address the issue. diff --git a/asdf-zig-plugin/SECURITY.md b/asdf-zig-plugin/SECURITY.md deleted file mode 100644 index a791a890..00000000 --- a/asdf-zig-plugin/SECURITY.md +++ /dev/null @@ -1,17 +0,0 @@ -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| latest | :white_check_mark: | - -## Reporting a Vulnerability - -Please report security vulnerabilities via GitHub Security Advisories. - -1. Go to the Security tab of this repository -2. Click "Report a vulnerability" -3. Provide details of the vulnerability - -We will respond within 48 hours and work with you to address the issue. diff --git a/asdf-zola-plugin/ABI-FFI-README.adoc b/asdf-zola-plugin/ABI-FFI-README.adoc new file mode 100644 index 00000000..f87c41f3 --- /dev/null +++ b/asdf-zola-plugin/ABI-FFI-README.adoc @@ -0,0 +1,407 @@ +== ZOLA ABI/FFI Documentation + +=== Overview + +This library follows the *Hyperpolymath RSR Standard* for ABI and FFI +design: + +* *ABI (Application Binary Interface)* defined in *Idris2* with formal +proofs +* *FFI (Foreign Function Interface)* implemented in *Zig* for C +compatibility +* *Generated C headers* bridge Idris2 ABI to Zig FFI +* *Any language* can call through standard C ABI + +=== Architecture + +.... +┌─────────────────────────────────────────────┐ +│ ABI Definitions (Idris2) │ +│ src/abi/ │ +│ - Types.idr (Type definitions) │ +│ - Layout.idr (Memory layout proofs) │ +│ - Foreign.idr (FFI declarations) │ +└─────────────────┬───────────────────────────┘ + │ + │ generates (at compile time) + ▼ +┌─────────────────────────────────────────────┐ +│ C Headers (auto-generated) │ +│ generated/abi/zola.h │ +└─────────────────┬───────────────────────────┘ + │ + │ imported by + ▼ +┌─────────────────────────────────────────────┐ +│ FFI Implementation (Zig) │ +│ ffi/zig/src/main.zig │ +│ - Implements C-compatible functions │ +│ - Zero-cost abstractions │ +│ - Memory-safe by default │ +└─────────────────┬───────────────────────────┘ + │ + │ compiled to libzola.so/.a + ▼ +┌─────────────────────────────────────────────┐ +│ Any Language via C ABI │ +│ - Rust, AffineScript, Julia, Python, etc. │ +└─────────────────────────────────────────────┘ +.... + +=== Directory Structure + +.... +zola/ +├── src/ +│ ├── abi/ # ABI definitions (Idris2) +│ │ ├── Types.idr # Core type definitions with proofs +│ │ ├── Layout.idr # Memory layout verification +│ │ └── Foreign.idr # FFI function declarations +│ └── lib/ # Core library (any language) +│ +├── ffi/ +│ └── zig/ # FFI implementation (Zig) +│ ├── build.zig # Build configuration +│ ├── build.zig.zon # Dependencies +│ ├── src/ +│ │ └── main.zig # C-compatible FFI implementation +│ ├── test/ +│ │ └── integration_test.zig +│ └── include/ +│ └── zola.h # C header (optional, can be generated) +│ +├── generated/ # Auto-generated files +│ └── abi/ +│ └── zola.h # Generated from Idris2 ABI +│ +└── bindings/ # Language-specific wrappers (optional) + ├── rust/ + ├── affinescript/ + └── julia/ +.... + +=== Why Idris2 for ABI? + +==== 1. *Formal Verification* + +Idris2’s dependent types allow proving properties about the ABI at +compile-time: + +[source,idris] +---- +-- Prove struct size is correct +public export +exampleStructSize : HasSize ExampleStruct 16 + +-- Prove field alignment is correct +public export +fieldAligned : Divides 8 (offsetOf ExampleStruct.field) + +-- Prove ABI is platform-compatible +public export +abiCompatible : Compatible (ABI 1) (ABI 2) +---- + +==== 2. *Type Safety* + +Encode invariants that C/Zig cannot express: + +[source,idris] +---- +-- Non-null pointer guaranteed at type level +data Handle : Type where + MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle + +-- Array with length proof +data Buffer : (n : Nat) -> Type where + MkBuffer : Vect n Byte -> Buffer n +---- + +==== 3. *Platform Abstraction* + +Platform-specific types with compile-time selection: + +[source,idris] +---- +CInt : Platform -> Type +CInt Linux = Bits32 +CInt Windows = Bits32 + +CSize : Platform -> Type +CSize Linux = Bits64 +CSize Windows = Bits64 +---- + +==== 4. *Safe Evolution* + +Prove that new ABI versions are backward-compatible: + +[source,idris] +---- +-- Compiler enforces compatibility +abiUpgrade : ABI 1 -> ABI 2 +abiUpgrade old = MkABI2 { + -- Must preserve all v1 fields + v1_compat = old, + -- Can add new fields + new_features = defaults +} +---- + +=== Why Zig for FFI? + +==== 1. *C ABI Compatibility* + +Zig exports C-compatible functions naturally: + +[source,zig] +---- +export fn library_function(param: i32) i32 { + return param * 2; +} +---- + +==== 2. *Memory Safety* + +Compile-time safety without runtime overhead: + +[source,zig] +---- +// Null check enforced at compile time +const handle = init() orelse return error.InitFailed; +defer free(handle); +---- + +==== 3. *Cross-Compilation* + +Built-in cross-compilation to any platform: + +[source,bash] +---- +zig build -Dtarget=x86_64-linux +zig build -Dtarget=aarch64-macos +zig build -Dtarget=x86_64-windows +---- + +==== 4. *Zero Dependencies* + +No runtime, no libc required (unless explicitly needed): + +[source,zig] +---- +// Minimal binary size +pub const lib = @import("std"); +// Only includes what you use +---- + +=== Building + +==== Build FFI Library + +[source,bash] +---- +cd ffi/zig +zig build # Build debug +zig build -Doptimize=ReleaseFast # Build optimized +zig build test # Run tests +---- + +==== Generate C Header from Idris2 ABI + +[source,bash] +---- +cd src/abi +idris2 --cg c-header Types.idr -o ../../generated/abi/zola.h +---- + +==== Cross-Compile + +[source,bash] +---- +cd ffi/zig + +# Linux x86_64 +zig build -Dtarget=x86_64-linux + +# macOS ARM64 +zig build -Dtarget=aarch64-macos + +# Windows x86_64 +zig build -Dtarget=x86_64-windows +---- + +=== Usage + +==== From C + +[source,c] +---- +#include "zola.h" + +int main() { + void* handle = zola_init(); + if (!handle) return 1; + + int result = zola_process(handle, 42); + if (result != 0) { + const char* err = zola_last_error(); + fprintf(stderr, "Error: %s\n", err); + } + + zola_free(handle); + return 0; +} +---- + +Compile with: + +[source,bash] +---- +gcc -o example example.c -lzola -L./zig-out/lib +---- + +==== From Idris2 + +[source,idris] +---- +import ZOLA.ABI.Foreign + +main : IO () +main = do + Just handle <- init + | Nothing => putStrLn "Failed to initialize" + + Right result <- process handle 42 + | Left err => putStrLn $ "Error: " ++ errorDescription err + + free handle + putStrLn "Success" +---- + +==== From Rust + +[source,rust] +---- +#[link(name = "zola")] +extern "C" { + fn zola_init() -> *mut std::ffi::c_void; + fn zola_free(handle: *mut std::ffi::c_void); + fn zola_process(handle: *mut std::ffi::c_void, input: u32) -> i32; +} + +fn main() { + unsafe { + let handle = zola_init(); + assert!(!handle.is_null()); + + let result = zola_process(handle, 42); + assert_eq!(result, 0); + + zola_free(handle); + } +} +---- + +==== From Julia + +[source,julia] +---- +const libzola = "libzola" + +function init() + handle = ccall((:zola_init, libzola), Ptr{Cvoid}, ()) + handle == C_NULL && error("Failed to initialize") + handle +end + +function process(handle, input) + result = ccall((:zola_process, libzola), Cint, (Ptr{Cvoid}, UInt32), handle, input) + result +end + +function cleanup(handle) + ccall((:zola_free, libzola), Cvoid, (Ptr{Cvoid},), handle) +end + +# Usage +handle = init() +try + result = process(handle, 42) + println("Result: $result") +finally + cleanup(handle) +end +---- + +=== Testing + +==== Unit Tests (Zig) + +[source,bash] +---- +cd ffi/zig +zig build test +---- + +==== Integration Tests + +[source,bash] +---- +cd ffi/zig +zig build test-integration +---- + +==== ABI Verification (Idris2) + +[source,idris] +---- +-- Compile-time verification +%runElab verifyABI + +-- Runtime checks +main : IO () +main = do + verifyLayoutsCorrect + verifyAlignmentsCorrect + putStrLn "ABI verification passed" +---- + +=== Contributing + +When modifying the ABI/FFI: + +[arabic] +. *Update ABI first* (`+src/abi/*.idr+`) +* Modify type definitions +* Update proofs +* Ensure backward compatibility +. *Generate C header* ++ +[source,bash] +---- +idris2 --cg c-header src/abi/Types.idr -o generated/abi/zola.h +---- +. *Update FFI implementation* (`+ffi/zig/src/main.zig+`) +* Implement new functions +* Match ABI types exactly +. *Add tests* +* Unit tests in Zig +* Integration tests +* ABI verification tests +. *Update documentation* +* Function signatures +* Usage examples +* Migration guide (if breaking changes) + +=== License + +MPL-2.0 + +=== See Also + +* https://idris2.readthedocs.io[Idris2 Documentation] +* https://ziglang.org/documentation/master/[Zig Documentation] +* https://github.com/hyperpolymath/rhodium-standard-repositories[Rhodium +Standard Repositories] +* link:../ffi-migration-guide.md[FFI Migration Guide] +* link:../abi-migration-guide.md[ABI Migration Guide] diff --git a/asdf-zola-plugin/ABI-FFI-README.md b/asdf-zola-plugin/ABI-FFI-README.md deleted file mode 100644 index 18a76fd1..00000000 --- a/asdf-zola-plugin/ABI-FFI-README.md +++ /dev/null @@ -1,384 +0,0 @@ - -# ZOLA ABI/FFI Documentation - -## Overview - -This library follows the **Hyperpolymath RSR Standard** for ABI and FFI design: - -- **ABI (Application Binary Interface)** defined in **Idris2** with formal proofs -- **FFI (Foreign Function Interface)** implemented in **Zig** for C compatibility -- **Generated C headers** bridge Idris2 ABI to Zig FFI -- **Any language** can call through standard C ABI - -## Architecture - -``` -┌─────────────────────────────────────────────┐ -│ ABI Definitions (Idris2) │ -│ src/abi/ │ -│ - Types.idr (Type definitions) │ -│ - Layout.idr (Memory layout proofs) │ -│ - Foreign.idr (FFI declarations) │ -└─────────────────┬───────────────────────────┘ - │ - │ generates (at compile time) - ▼ -┌─────────────────────────────────────────────┐ -│ C Headers (auto-generated) │ -│ generated/abi/zola.h │ -└─────────────────┬───────────────────────────┘ - │ - │ imported by - ▼ -┌─────────────────────────────────────────────┐ -│ FFI Implementation (Zig) │ -│ ffi/zig/src/main.zig │ -│ - Implements C-compatible functions │ -│ - Zero-cost abstractions │ -│ - Memory-safe by default │ -└─────────────────┬───────────────────────────┘ - │ - │ compiled to libzola.so/.a - ▼ -┌─────────────────────────────────────────────┐ -│ Any Language via C ABI │ -│ - Rust, AffineScript, Julia, Python, etc. │ -└─────────────────────────────────────────────┘ -``` - -## Directory Structure - -``` -zola/ -├── src/ -│ ├── abi/ # ABI definitions (Idris2) -│ │ ├── Types.idr # Core type definitions with proofs -│ │ ├── Layout.idr # Memory layout verification -│ │ └── Foreign.idr # FFI function declarations -│ └── lib/ # Core library (any language) -│ -├── ffi/ -│ └── zig/ # FFI implementation (Zig) -│ ├── build.zig # Build configuration -│ ├── build.zig.zon # Dependencies -│ ├── src/ -│ │ └── main.zig # C-compatible FFI implementation -│ ├── test/ -│ │ └── integration_test.zig -│ └── include/ -│ └── zola.h # C header (optional, can be generated) -│ -├── generated/ # Auto-generated files -│ └── abi/ -│ └── zola.h # Generated from Idris2 ABI -│ -└── bindings/ # Language-specific wrappers (optional) - ├── rust/ - ├── affinescript/ - └── julia/ -``` - -## Why Idris2 for ABI? - -### 1. **Formal Verification** - -Idris2's dependent types allow proving properties about the ABI at compile-time: - -```idris --- Prove struct size is correct -public export -exampleStructSize : HasSize ExampleStruct 16 - --- Prove field alignment is correct -public export -fieldAligned : Divides 8 (offsetOf ExampleStruct.field) - --- Prove ABI is platform-compatible -public export -abiCompatible : Compatible (ABI 1) (ABI 2) -``` - -### 2. **Type Safety** - -Encode invariants that C/Zig cannot express: - -```idris --- Non-null pointer guaranteed at type level -data Handle : Type where - MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle - --- Array with length proof -data Buffer : (n : Nat) -> Type where - MkBuffer : Vect n Byte -> Buffer n -``` - -### 3. **Platform Abstraction** - -Platform-specific types with compile-time selection: - -```idris -CInt : Platform -> Type -CInt Linux = Bits32 -CInt Windows = Bits32 - -CSize : Platform -> Type -CSize Linux = Bits64 -CSize Windows = Bits64 -``` - -### 4. **Safe Evolution** - -Prove that new ABI versions are backward-compatible: - -```idris --- Compiler enforces compatibility -abiUpgrade : ABI 1 -> ABI 2 -abiUpgrade old = MkABI2 { - -- Must preserve all v1 fields - v1_compat = old, - -- Can add new fields - new_features = defaults -} -``` - -## Why Zig for FFI? - -### 1. **C ABI Compatibility** - -Zig exports C-compatible functions naturally: - -```zig -export fn library_function(param: i32) i32 { - return param * 2; -} -``` - -### 2. **Memory Safety** - -Compile-time safety without runtime overhead: - -```zig -// Null check enforced at compile time -const handle = init() orelse return error.InitFailed; -defer free(handle); -``` - -### 3. **Cross-Compilation** - -Built-in cross-compilation to any platform: - -```bash -zig build -Dtarget=x86_64-linux -zig build -Dtarget=aarch64-macos -zig build -Dtarget=x86_64-windows -``` - -### 4. **Zero Dependencies** - -No runtime, no libc required (unless explicitly needed): - -```zig -// Minimal binary size -pub const lib = @import("std"); -// Only includes what you use -``` - -## Building - -### Build FFI Library - -```bash -cd ffi/zig -zig build # Build debug -zig build -Doptimize=ReleaseFast # Build optimized -zig build test # Run tests -``` - -### Generate C Header from Idris2 ABI - -```bash -cd src/abi -idris2 --cg c-header Types.idr -o ../../generated/abi/zola.h -``` - -### Cross-Compile - -```bash -cd ffi/zig - -# Linux x86_64 -zig build -Dtarget=x86_64-linux - -# macOS ARM64 -zig build -Dtarget=aarch64-macos - -# Windows x86_64 -zig build -Dtarget=x86_64-windows -``` - -## Usage - -### From C - -```c -#include "zola.h" - -int main() { - void* handle = zola_init(); - if (!handle) return 1; - - int result = zola_process(handle, 42); - if (result != 0) { - const char* err = zola_last_error(); - fprintf(stderr, "Error: %s\n", err); - } - - zola_free(handle); - return 0; -} -``` - -Compile with: -```bash -gcc -o example example.c -lzola -L./zig-out/lib -``` - -### From Idris2 - -```idris -import ZOLA.ABI.Foreign - -main : IO () -main = do - Just handle <- init - | Nothing => putStrLn "Failed to initialize" - - Right result <- process handle 42 - | Left err => putStrLn $ "Error: " ++ errorDescription err - - free handle - putStrLn "Success" -``` - -### From Rust - -```rust -#[link(name = "zola")] -extern "C" { - fn zola_init() -> *mut std::ffi::c_void; - fn zola_free(handle: *mut std::ffi::c_void); - fn zola_process(handle: *mut std::ffi::c_void, input: u32) -> i32; -} - -fn main() { - unsafe { - let handle = zola_init(); - assert!(!handle.is_null()); - - let result = zola_process(handle, 42); - assert_eq!(result, 0); - - zola_free(handle); - } -} -``` - -### From Julia - -```julia -const libzola = "libzola" - -function init() - handle = ccall((:zola_init, libzola), Ptr{Cvoid}, ()) - handle == C_NULL && error("Failed to initialize") - handle -end - -function process(handle, input) - result = ccall((:zola_process, libzola), Cint, (Ptr{Cvoid}, UInt32), handle, input) - result -end - -function cleanup(handle) - ccall((:zola_free, libzola), Cvoid, (Ptr{Cvoid},), handle) -end - -# Usage -handle = init() -try - result = process(handle, 42) - println("Result: $result") -finally - cleanup(handle) -end -``` - -## Testing - -### Unit Tests (Zig) - -```bash -cd ffi/zig -zig build test -``` - -### Integration Tests - -```bash -cd ffi/zig -zig build test-integration -``` - -### ABI Verification (Idris2) - -```idris --- Compile-time verification -%runElab verifyABI - --- Runtime checks -main : IO () -main = do - verifyLayoutsCorrect - verifyAlignmentsCorrect - putStrLn "ABI verification passed" -``` - -## Contributing - -When modifying the ABI/FFI: - -1. **Update ABI first** (`src/abi/*.idr`) - - Modify type definitions - - Update proofs - - Ensure backward compatibility - -2. **Generate C header** - ```bash - idris2 --cg c-header src/abi/Types.idr -o generated/abi/zola.h - ``` - -3. **Update FFI implementation** (`ffi/zig/src/main.zig`) - - Implement new functions - - Match ABI types exactly - -4. **Add tests** - - Unit tests in Zig - - Integration tests - - ABI verification tests - -5. **Update documentation** - - Function signatures - - Usage examples - - Migration guide (if breaking changes) - -## License - -MPL-2.0 - -## See Also - -- [Idris2 Documentation](https://idris2.readthedocs.io) -- [Zig Documentation](https://ziglang.org/documentation/master/) -- [Rhodium Standard Repositories](https://github.com/hyperpolymath/rhodium-standard-repositories) -- [FFI Migration Guide](../ffi-migration-guide.md) -- [ABI Migration Guide](../abi-migration-guide.md) diff --git a/asdf-zola-plugin/CODE_OF_CONDUCT.adoc b/asdf-zola-plugin/CODE_OF_CONDUCT.adoc new file mode 100644 index 00000000..bd2a83cb --- /dev/null +++ b/asdf-zola-plugin/CODE_OF_CONDUCT.adoc @@ -0,0 +1,24 @@ +== Contributor Covenant Code of Conduct + +=== Our Pledge + +We pledge to make participation a harassment-free experience for +everyone. + +=== Our Standards + +*Positive behavior:* * Using welcoming language * Being respectful of +differing viewpoints * Accepting constructive criticism * Focusing on +what is best for the community + +*Unacceptable behavior:* * Harassment, trolling, or personal attacks * +Publishing private information without permission + +=== Enforcement + +Report issues to the maintainers. All complaints will be reviewed. + +=== Attribution + +Adapted from https://www.contributor-covenant.org/[Contributor Covenant] +v2.1. diff --git a/asdf-zola-plugin/CODE_OF_CONDUCT.md b/asdf-zola-plugin/CODE_OF_CONDUCT.md deleted file mode 100644 index fb43d833..00000000 --- a/asdf-zola-plugin/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,26 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We pledge to make participation a harassment-free experience for everyone. - -## Our Standards - -**Positive behavior:** -* Using welcoming language -* Being respectful of differing viewpoints -* Accepting constructive criticism -* Focusing on what is best for the community - -**Unacceptable behavior:** -* Harassment, trolling, or personal attacks -* Publishing private information without permission - -## Enforcement - -Report issues to the maintainers. All complaints will be reviewed. - -## Attribution - -Adapted from [Contributor Covenant](https://www.contributor-covenant.org/) v2.1. diff --git a/asdf-zola-plugin/CONTRIBUTING.adoc b/asdf-zola-plugin/CONTRIBUTING.adoc index d18532b5..084ee525 100644 --- a/asdf-zola-plugin/CONTRIBUTING.adoc +++ b/asdf-zola-plugin/CONTRIBUTING.adoc @@ -1,19 +1,109 @@ -// SPDX-License-Identifier: CC-BY-SA-4.0 -= Contributing Guide +== Clone the repository -== Getting Started +git clone https://github.com/hyperpolymath/asdf-tool-plugins.git cd +asdf-tool-plugins -1. Fork the repository -2. Create a feature branch from `main` -3. Sign off commits (`git commit -s`) -4. Submit a pull request +== Using Guix (recommended for reproducibility) -== Commit Guidelines +guix develop -* Conventional commits: `type(scope): description` -* Sign all commits (DCO required) -* Atomic, focused commits +== Or using toolbox/distrobox -== License +toolbox create asdf-tool-plugins-dev toolbox enter asdf-tool-plugins-dev +# Install dependencies manually -Contributions licensed under project license. +== Verify setup + +just check # or: cargo check / mix compile / etc. just test # Run test +suite + +.... + +### Repository Structure +.... + +asdf-tool-plugins/ ├── src/ # Source code (Perimeter 1-2) ├── lib/ # +Library code (Perimeter 1-2) ├── extensions/ # Extensions (Perimeter 2) +├── plugins/ # Plugins (Perimeter 2) ├── tools/ # Tooling (Perimeter 2) +├── docs/ # Documentation (Perimeter 3) │ ├── architecture/ # ADRs, +specs (Perimeter 2) │ └── proposals/ # RFCs (Perimeter 3) ├── examples/ +# Examples (Perimeter 3) ├── spec/ # Spec tests (Perimeter 3) ├── tests/ +# Test suite (Perimeter 2-3) ├── .well-known/ # Protocol files +(Perimeter 1-3) ├── .github/ # GitHub config (Perimeter 1) │ ├── +ISSUE_TEMPLATE/ │ └── workflows/ ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md # This file ├── GOVERNANCE.md ├── LICENSE ├── +MAINTAINERS.md ├── README.adoc ├── SECURITY.md ├── flake.guix # Guix +flake (Perimeter 1) └── Justfile # Task runner (Perimeter 1) + +.... + +--- + +## How to Contribute + +### Reporting Bugs + +**Before reporting**: +1. Search existing issues +2. Check if it's already fixed in `main` +3. Determine which perimeter the bug affects + +**When reporting**: + +Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: + +- Clear, descriptive title +- Environment details (OS, versions, toolchain) +- Steps to reproduce +- Expected vs actual behaviour +- Logs, screenshots, or minimal reproduction + +### Suggesting Features + +**Before suggesting**: +1. Check the [roadmap](ROADMAP.md) if available +2. Search existing issues and discussions +3. Consider which perimeter the feature belongs to + +**When suggesting**: + +Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: + +- Problem statement (what pain point does this solve?) +- Proposed solution +- Alternatives considered +- Which perimeter this affects + +### Your First Contribution + +Look for issues labelled: + +- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks +- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed +- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements +- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope + +--- + +## Development Workflow + +### Branch Naming +.... + +docs/short-description # Documentation (P3) test/what-added # Test +additions (P3) feat/short-description # New features (P2) +fix/issue-number-description # Bug fixes (P2) refactor/what-changed # +Code improvements (P2) security/what-fixed # Security fixes (P1-2) + +.... + +### Commit Messages + +We follow [Conventional Commits](https://www.conventionalcommits.org/): +.... + +(): + +{empty}[optional body] + +{empty}[optional footer] diff --git a/asdf-zola-plugin/CONTRIBUTING.md b/asdf-zola-plugin/CONTRIBUTING.md deleted file mode 100644 index f5c1963b..00000000 --- a/asdf-zola-plugin/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Clone the repository -git clone https://github.com/hyperpolymath/asdf-tool-plugins.git -cd asdf-tool-plugins - -# Using Guix (recommended for reproducibility) -guix develop - -# Or using toolbox/distrobox -toolbox create asdf-tool-plugins-dev -toolbox enter asdf-tool-plugins-dev -# Install dependencies manually - -# Verify setup -just check # or: cargo check / mix compile / etc. -just test # Run test suite -``` - -### Repository Structure -``` -asdf-tool-plugins/ -├── src/ # Source code (Perimeter 1-2) -├── lib/ # Library code (Perimeter 1-2) -├── extensions/ # Extensions (Perimeter 2) -├── plugins/ # Plugins (Perimeter 2) -├── tools/ # Tooling (Perimeter 2) -├── docs/ # Documentation (Perimeter 3) -│ ├── architecture/ # ADRs, specs (Perimeter 2) -│ └── proposals/ # RFCs (Perimeter 3) -├── examples/ # Examples (Perimeter 3) -├── spec/ # Spec tests (Perimeter 3) -├── tests/ # Test suite (Perimeter 2-3) -├── .well-known/ # Protocol files (Perimeter 1-3) -├── .github/ # GitHub config (Perimeter 1) -│ ├── ISSUE_TEMPLATE/ -│ └── workflows/ -├── CHANGELOG.md -├── CODE_OF_CONDUCT.md -├── CONTRIBUTING.md # This file -├── GOVERNANCE.md -├── LICENSE -├── MAINTAINERS.md -├── README.adoc -├── SECURITY.md -├── flake.guix # Guix flake (Perimeter 1) -└── Justfile # Task runner (Perimeter 1) -``` - ---- - -## How to Contribute - -### Reporting Bugs - -**Before reporting**: -1. Search existing issues -2. Check if it's already fixed in `main` -3. Determine which perimeter the bug affects - -**When reporting**: - -Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md) and include: - -- Clear, descriptive title -- Environment details (OS, versions, toolchain) -- Steps to reproduce -- Expected vs actual behaviour -- Logs, screenshots, or minimal reproduction - -### Suggesting Features - -**Before suggesting**: -1. Check the [roadmap](ROADMAP.md) if available -2. Search existing issues and discussions -3. Consider which perimeter the feature belongs to - -**When suggesting**: - -Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md) and include: - -- Problem statement (what pain point does this solve?) -- Proposed solution -- Alternatives considered -- Which perimeter this affects - -### Your First Contribution - -Look for issues labelled: - -- [`good first issue`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/good%20first%20issue) — Simple Perimeter 3 tasks -- [`help wanted`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/help%20wanted) — Community help needed -- [`documentation`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/documentation) — Docs improvements -- [`perimeter-3`](https://github.com/hyperpolymath/asdf-tool-plugins/labels/perimeter-3) — Community sandbox scope - ---- - -## Development Workflow - -### Branch Naming -``` -docs/short-description # Documentation (P3) -test/what-added # Test additions (P3) -feat/short-description # New features (P2) -fix/issue-number-description # Bug fixes (P2) -refactor/what-changed # Code improvements (P2) -security/what-fixed # Security fixes (P1-2) -``` - -### Commit Messages - -We follow [Conventional Commits](https://www.conventionalcommits.org/): -``` -(): - -[optional body] - -[optional footer] diff --git a/asdf-zola-plugin/README.adoc b/asdf-zola-plugin/README.adoc index d08e1dd2..f0cbbf45 100644 --- a/asdf-zola-plugin/README.adoc +++ b/asdf-zola-plugin/README.adoc @@ -1,101 +1,82 @@ -= RSR template repo - see RSR_OUTLINE.adoc in root for general background and specification +== asdf-zola -== This is your repo - don't forget to rename me! +https://github.com/hyperpolymath/asdf-zola-plugin/actions/workflows/build.yml[image:https://github.com/hyperpolymath/asdf-zola-plugin/actions/workflows/build.yml/badge.svg[Build]] +https://github.com/hyperpolymath/asdf-zola-plugin/actions/workflows/lint.yml[image:https://github.com/hyperpolymath/asdf-zola-plugin/actions/workflows/lint.yml/badge.svg[Lint]] +image:https://img.shields.io/badge/License-MPL–2.0-blue.svg[License: +PMPL-1.0,link="`https://github.com/hyperpolymath/palimpsest-license`"] -== ABI/FFI Standards (Hyperpolymath Universal Standard) +https://asdf-vm.com[asdf] plugin for https://www.getzola.org[Zola]. -**All repos with foreign function interfaces MUST follow this standard:** +Fast static site generator. -* **ABI (Application Binary Interface)** → **Idris2** (`src/abi/*.idr`) -** Type definitions with dependent type proofs -** Memory layout verification -** Platform-specific ABIs with compile-time selection -** Formal verification of interface correctness +=== Contents -* **FFI (Foreign Function Interface)** → **Zig** (`ffi/zig/src/*.zig`) -** C-compatible function implementations -** Zero-cost abstractions -** Memory-safe by default -** Cross-compilation support +* link:#dependencies[Dependencies] +* link:#install[Install] +* link:#usage[Usage] +* link:#contributing[Contributing] +* link:#license[License] -* **Generated C Headers** → Auto-generated from Idris2 ABI (`generated/abi/*.h`) -** Bridge between Idris2 and Zig -** Consumed by any language via C ABI +=== Dependencies -**Directory Structure:** ----- -project/ -├── src/abi/ # Idris2 ABI definitions (REQUIRED) -├── ffi/zig/ # Zig FFI implementation (REQUIRED) -├── generated/abi/ # Auto-generated C headers -└── bindings/ # Language-specific wrappers (optional) ----- - -**See:** `ABI-FFI-README.md` for complete documentation +* `+bash+`, `+curl+`, `+tar+`, and +https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html[POSIX +utilities] -== AI CLI standards +=== Install -- Include `ai-cli-crash-capture/` and `contractiles/` from this template in new repos. -- Mirror 6SCM files into `.machine_readable/` (NOT `.machine_readable/6scm/`). -- Before any code generation, check `/var$REPOS_DIR/proven` for the current Idris "unbreakable" library status. -- If a project uses that Idris library, add an *Idris Inside* badge to the repo. -- If new bindings are required, add them in `/var$REPOS_DIR/proven` as `idris2-zig-` during the work. -- If new code suggests additional "unbreakable" Idris modules, add them under `/var$REPOS_DIR/proven` and update binders across all supported languages. +Plugin: -== Standard Dependencies +[source,bash] +---- +asdf plugin add zola https://github.com/hyperpolymath/asdf-zola-plugin.git +---- -=== Web Projects +zola: -AffineScript web projects in the hyperpolymath ecosystem **MUST** use these formally verified components: +[source,bash] +---- +# Show all installable versions +asdf list-all zola -[cols="1,2,1"] -|=== -|Library |Purpose |Status +# Install specific version +asdf install zola latest -|link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter] -|Formally verified DOM mounting -|**REQUIRED** +# Set a version globally (in your ~/.tool-versions file) +asdf global zola latest -|link:https://github.com/hyperpolymath/affinescript-tea[affinescript-tea] -|TEA architecture framework -|Recommended +# Now zola commands are available +zola --version +---- -|link:https://github.com/hyperpolymath/cadre-tea-router[cadre-tea-router] -|Proven-safe URL routing -|Recommended +Check https://asdf-vm.com/guide/getting-started.html[asdf] readme for +more instructions. -|link:https://github.com/hyperpolymath/proven[proven] -|Idris2 formally verified library -|Core Dependency -|=== +=== Usage -==== Why SafeDOM is Required +[source,bash] +---- +# List installed versions +asdf list zola -Traditional DOM mounting can fail: +# Set local version for current directory +asdf local zola -[source,javascript] ----- -// ❌ UNSAFE: Can crash with null pointer -const el = document.getElementById('app') -el.innerHTML = html // 💥 +# Uninstall a version +asdf uninstall zola ---- -SafeDOM provides **compile-time proofs** that DOM operations cannot fail: +=== Contributing -[source,affinescript] ----- -// ✅ PROVEN SAFE: Mathematically guaranteed -SafeDOM.mountSafe("#app", html, - ~onSuccess=el => Console.log("Success"), - ~onError=err => Console.error(err)) ----- +Contributions welcome! Read the link:CONTRIBUTING.adoc[contributing +guidelines] first. + +=== License -**Mathematical Guarantees:** +Licensed under the link:LICENSE[Palimpsest-MPL License (PMPL-1.0)]. -✓ No null pointer dereferences (Idris2 proof) -✓ No invalid CSS selectors (dependent types) -✓ No malformed HTML (balanced tag checking) -✓ Type-safe operations (AffineScript + Idris2) -✓ Zero runtime overhead (proofs erased) +''''' -See link:https://github.com/hyperpolymath/affinescript-dom-mounter[affinescript-dom-mounter documentation] for full details. +____ +Maintained by https://github.com/hyperpolymath[hyperpolymath] +____ diff --git a/asdf-zola-plugin/README.md b/asdf-zola-plugin/README.md deleted file mode 100644 index eb94b490..00000000 --- a/asdf-zola-plugin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# asdf-zola - -[![Build](https://github.com/hyperpolymath/asdf-zola-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/hyperpolymath/asdf-zola-plugin/actions/workflows/build.yml) -[![Lint](https://github.com/hyperpolymath/asdf-zola-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/hyperpolymath/asdf-zola-plugin/actions/workflows/lint.yml) -image:https://img.shields.io/badge/License-MPL--2.0-blue.svg[License: PMPL-1.0,link="https://github.com/hyperpolymath/palimpsest-license"] - -[asdf](https://asdf-vm.com) plugin for [Zola](https://www.getzola.org). - -Fast static site generator. - -## Contents - -- [Dependencies](#dependencies) -- [Install](#install) -- [Usage](#usage) -- [Contributing](#contributing) -- [License](#license) - -## Dependencies - -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) - -## Install - -Plugin: - -```bash -asdf plugin add zola https://github.com/hyperpolymath/asdf-zola-plugin.git -``` - -zola: - -```bash -# Show all installable versions -asdf list-all zola - -# Install specific version -asdf install zola latest - -# Set a version globally (in your ~/.tool-versions file) -asdf global zola latest - -# Now zola commands are available -zola --version -``` - -Check [asdf](https://asdf-vm.com/guide/getting-started.html) readme for more instructions. - -## Usage - -```bash -# List installed versions -asdf list zola - -# Set local version for current directory -asdf local zola - -# Uninstall a version -asdf uninstall zola -``` - -## Contributing - -Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.adoc) first. - -## License - -Licensed under the [Palimpsest-MPL License (PMPL-1.0)](LICENSE). - ---- - -> Maintained by [hyperpolymath](https://github.com/hyperpolymath) diff --git a/asdf-zola-plugin/SECURITY.adoc b/asdf-zola-plugin/SECURITY.adoc new file mode 100644 index 00000000..b0574dfd --- /dev/null +++ b/asdf-zola-plugin/SECURITY.adoc @@ -0,0 +1,24 @@ +== Security Policy + +=== Supported Versions + +[cols=",",options="header",] +|=== +|Version |Supported +|main |:white_check_mark: +|< main |:x: +|=== + +=== Reporting a Vulnerability + +Please report security vulnerabilities through GitHub private +vulnerability reporting: 1. Go to the *Security* tab 2. Click *Report a +vulnerability* 3. Fill out the form + +We respond within 48 hours. + +=== Security Measures + +* Dependabot for dependency updates +* CodeQL for code scanning +* Secret scanning and push protection diff --git a/asdf-zola-plugin/SECURITY.md b/asdf-zola-plugin/SECURITY.md deleted file mode 100644 index f66809e5..00000000 --- a/asdf-zola-plugin/SECURITY.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| main | :white_check_mark: | -| < main | :x: | - -## Reporting a Vulnerability - -Please report security vulnerabilities through GitHub private vulnerability reporting: -1. Go to the **Security** tab -2. Click **Report a vulnerability** -3. Fill out the form - -We respond within 48 hours. - -## Security Measures - -- Dependabot for dependency updates -- CodeQL for code scanning -- Secret scanning and push protection diff --git a/docs/tech-debt-2026-05-26.adoc b/docs/tech-debt-2026-05-26.adoc new file mode 100644 index 00000000..17e6bf1d --- /dev/null +++ b/docs/tech-debt-2026-05-26.adoc @@ -0,0 +1,66 @@ +== Tech-Debt Audit — asdf-tool-plugins — 2026-05-26 + +*Source:* estate-wide automated scan 2026-05-26. *Companion:* +https://github.com/hyperpolymath/standards/tree/main/docs/audits[`+hyperpolymath/standards+` +2026-05-26-estate-*-debt audits]. *Combined severity:* `+2026-05-22+`. + +This file records the _raw findings_ — it does not by itself fix the +debt. Each section ends with a '`Recommended next move`' line; closing +the debt is follow-up work. + +=== 1. Proof debt + +Scanner counted the following markers in proof-bearing files of this +repo: + +.... +files= 567 | Coq-Axm/Adm= 0 | Lean-srry/ax= 0 | Agda-pst= 0 | Idr-blv= 0 | Idr-prtl= 0 | Fstr-asm= 0 | TODO= 0 | Unsafe= 0 +.... + +*Total markers:* 0. *Severity:* `+>00+`. + +*Recommended next move:* none — no proof-debt markers detected. + +=== 2. Licence debt + +[cols=",",options="header",] +|=== +|Field |Value +|LICENSE file |`+LICENSE+` +|SPDX header |`+MPL-2.0+` +|Manifest licence |`+NONE+` +|Body classifier |`+Palimp-MPL-2.0+` +|Severity |`+ok+` +|=== + +*Recommended next move:* none for licence. + +=== 3. Documentation debt + +[cols=",",options="header",] +|=== +|Field |Value +|README lines |14 +|`+docs/+` files |2 +|`+docs/+` LoC |260 +|CHANGELOG.md |Y +|CONTRIBUTING.md |Y +|CODE_OF_CONDUCT.md |Y +|SECURITY.md |Y +|Severity |`+readme=14 docs=2/260+` +|=== + +=== Cross-references + +* Estate proof-debt audit: +`+hyperpolymath/standards/docs/audits/2026-05-26-estate-proof-debt.md+` +* Estate licence-debt audit: +`+hyperpolymath/standards/docs/audits/2026-05-26-estate-licence-debt.md+` +* Estate documentation-debt audit: +`+hyperpolymath/standards/docs/audits/2026-05-26-estate-documentation-debt.md+` + +''''' + +🤖 Generated by Claude Code estate-wide tech-debt scan (2026-05-26). +This file is informational — closing the debt is follow-up work owned by +the maintainer. diff --git a/docs/tech-debt-2026-05-26.md b/docs/tech-debt-2026-05-26.md deleted file mode 100644 index bbee468f..00000000 --- a/docs/tech-debt-2026-05-26.md +++ /dev/null @@ -1,60 +0,0 @@ - - -# Tech-Debt Audit — asdf-tool-plugins — 2026-05-26 - -**Source:** estate-wide automated scan 2026-05-26. -**Companion:** [`hyperpolymath/standards` 2026-05-26-estate-*-debt audits](https://github.com/hyperpolymath/standards/tree/main/docs/audits). -**Combined severity:** `2026-05-22`. - -This file records the *raw findings* — it does not by itself fix the debt. Each section ends with a 'Recommended next move' line; closing the debt is follow-up work. - -## 1. Proof debt - -Scanner counted the following markers in proof-bearing files of this repo: - -``` -files= 567 | Coq-Axm/Adm= 0 | Lean-srry/ax= 0 | Agda-pst= 0 | Idr-blv= 0 | Idr-prtl= 0 | Fstr-asm= 0 | TODO= 0 | Unsafe= 0 -``` - -**Total markers:** 0. **Severity:** `>00`. - -**Recommended next move:** none — no proof-debt markers detected. - -## 2. Licence debt - -| Field | Value | -|---|---| -| LICENSE file | `LICENSE` | -| SPDX header | `MPL-2.0` | -| Manifest licence | `NONE` | -| Body classifier | `Palimp-MPL-2.0` | -| Severity | `ok` | - -**Recommended next move:** none for licence. - -## 3. Documentation debt - -| Field | Value | -|---|---| -| README lines | 14 | -| `docs/` files | 2 | -| `docs/` LoC | 260 | -| CHANGELOG.md | Y | -| CONTRIBUTING.md | Y | -| CODE_OF_CONDUCT.md | Y | -| SECURITY.md | Y | -| Severity | `readme=14 docs=2/260` | - - -## Cross-references - -- Estate proof-debt audit: `hyperpolymath/standards/docs/audits/2026-05-26-estate-proof-debt.md` -- Estate licence-debt audit: `hyperpolymath/standards/docs/audits/2026-05-26-estate-licence-debt.md` -- Estate documentation-debt audit: `hyperpolymath/standards/docs/audits/2026-05-26-estate-documentation-debt.md` - ---- - -🤖 Generated by Claude Code estate-wide tech-debt scan (2026-05-26). This file is informational — closing the debt is follow-up work owned by the maintainer. diff --git a/llm-warmup-dev.adoc b/llm-warmup-dev.adoc new file mode 100644 index 00000000..41a4980f --- /dev/null +++ b/llm-warmup-dev.adoc @@ -0,0 +1,19 @@ +== LLM Warmup — asdf-tool-plugins (Developer) + +=== What is asdf-tool-plugins? + +See README.adoc for overview. + +=== Key Commands + +* `+just setup+` — set up development environment +* `+just build+` — build the project +* `+just test+` — run tests +* `+just doctor+` — diagnose issues +* `+just heal+` — attempt auto-repair + +=== Quick Context + +* License: MPL-2.0 +* Part of hyperpolymath ecosystem +* See EXPLAINME.adoc for architecture diff --git a/llm-warmup-dev.md b/llm-warmup-dev.md deleted file mode 100644 index 9a1fe5c7..00000000 --- a/llm-warmup-dev.md +++ /dev/null @@ -1,16 +0,0 @@ -# LLM Warmup — asdf-tool-plugins (Developer) - -## What is asdf-tool-plugins? -See README.adoc for overview. - -## Key Commands -- `just setup` — set up development environment -- `just build` — build the project -- `just test` — run tests -- `just doctor` — diagnose issues -- `just heal` — attempt auto-repair - -## Quick Context -- License: MPL-2.0 -- Part of hyperpolymath ecosystem -- See EXPLAINME.adoc for architecture diff --git a/llm-warmup-user.adoc b/llm-warmup-user.adoc new file mode 100644 index 00000000..e5483fcb --- /dev/null +++ b/llm-warmup-user.adoc @@ -0,0 +1,19 @@ +== LLM Warmup — asdf-tool-plugins (User) + +=== What is asdf-tool-plugins? + +See README.adoc for overview. + +=== Key Commands + +* `+just setup+` — set up development environment +* `+just build+` — build the project +* `+just test+` — run tests +* `+just doctor+` — diagnose issues +* `+just heal+` — attempt auto-repair + +=== Quick Context + +* License: MPL-2.0 +* Part of hyperpolymath ecosystem +* See EXPLAINME.adoc for architecture diff --git a/llm-warmup-user.md b/llm-warmup-user.md deleted file mode 100644 index 4daff8c9..00000000 --- a/llm-warmup-user.md +++ /dev/null @@ -1,16 +0,0 @@ -# LLM Warmup — asdf-tool-plugins (User) - -## What is asdf-tool-plugins? -See README.adoc for overview. - -## Key Commands -- `just setup` — set up development environment -- `just build` — build the project -- `just test` — run tests -- `just doctor` — diagnose issues -- `just heal` — attempt auto-repair - -## Quick Context -- License: MPL-2.0 -- Part of hyperpolymath ecosystem -- See EXPLAINME.adoc for architecture