-
Notifications
You must be signed in to change notification settings - Fork 0
co-pilot instructions and example fixes from PR review #66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| # Copilot PR Review Instructions — FastEdge-sdk-rust | ||
|
|
||
| ## Constitution | ||
|
|
||
| This repository is `fastedge` (crate) — the Rust SDK for Gcore FastEdge. It provides the `#[fastedge::http]` and `#[wstd::http_server]` handler macros, type conversions, an outbound HTTP client, and ProxyWasm FFI wrappers for CDN apps. | ||
|
|
||
| ### Principles (enforce during review) | ||
|
|
||
| 1. **Handler preference** — `#[wstd::http_server]` (async, wasm32-wasip2) is the recommended handler for new HTTP apps. `#[fastedge::http]` is legacy. New examples must use `wstd`. | ||
| 2. **No over-engineering** — Simple solutions over complex abstractions. Three similar lines > premature abstraction. | ||
| 3. **Platform constraints** — Only stdout is captured; `eprintln!` output is silently lost. Flag any use of stderr in code or examples. | ||
| 4. **CDN/HTTP separation** — CDN apps (proxy-wasm filters) and HTTP apps (standalone handlers) are independent application types with different architectures and lifecycles. Never mix their APIs. | ||
| 5. **WIT submodule integrity** — `wit/` files come from `G-Core/FastEdge-wit` submodule. Never modify them directly. | ||
|
|
||
| ### Public API contract | ||
|
|
||
| The public API surface is defined by: | ||
| - `src/lib.rs` — Core types (`Body`, `Error`), type conversions, `send_request` | ||
| - `derive/src/lib.rs` — `#[fastedge::http]` proc macro | ||
| - `src/proxywasm/` — ProxyWasm FFI wrappers (KV store, secrets, dictionary, utils) | ||
| - `src/http_client.rs` — Outbound HTTP client | ||
|
|
||
| Changes to these surfaces require updated `docs/`, updated tests, and a semver-appropriate version bump. | ||
|
|
||
| ## Generated Content — `docs/` | ||
|
|
||
| Files in `docs/` are **machine-generated** from source code by `./fastedge-plugin-source/generate-docs.sh`. They must not be edited by hand — manual changes will be silently overwritten on the next generation run. | ||
|
|
||
| ### When reviewing PRs that touch `docs/`: | ||
|
|
||
| - **Never** suggest manual edits to any file in `docs/` | ||
| - If docs are stale or incorrect, suggest: **Run `./fastedge-plugin-source/generate-docs.sh`** | ||
| - If the generated output itself is wrong (e.g., wrong structure, missing section), the fix belongs in `fastedge-plugin-source/.generation-config.md`, not in `docs/` directly | ||
| - If a PR modifies `docs/` files without a corresponding source code change, flag it — the change should come from the generation script, not a hand-edit | ||
|
|
||
| ### When reviewing PRs that change source code covered by `docs/`: | ||
|
|
||
| - Check whether the change affects the public API or user-facing behavior | ||
| - If yes, and `docs/` was not regenerated in the same PR, **request changes** with: | ||
| > Source code affecting public API was changed but docs/ was not regenerated. | ||
| > Run: `./fastedge-plugin-source/generate-docs.sh` | ||
|
|
||
| ## Documentation Freshness | ||
|
|
||
| ### Public API changes (must regenerate docs/) | ||
| - New, modified, or removed public types/functions in `src/lib.rs` | ||
| - Changes to `#[fastedge::http]` macro behavior in `derive/src/lib.rs` | ||
| - Changes to ProxyWasm wrapper APIs in `src/proxywasm/` | ||
| - Changes to outbound HTTP client in `src/http_client.rs` | ||
| - New or modified WIT interfaces in `wit/` | ||
| - Changes to `Cargo.toml` (version, features, dependencies) | ||
|
|
||
| ### Mapping: code location → doc file | ||
|
|
||
| | Code path | Doc file | | ||
| | --------------------------------------------- | --------------------- | | ||
| | `src/lib.rs` (Body, Error, send_request) | `docs/SDK_API.md` | | ||
| | `derive/src/lib.rs` (handler macros) | `docs/SDK_API.md` | | ||
| | `src/http_client.rs` (outbound HTTP) | `docs/SDK_API.md` | | ||
| | `src/proxywasm/key_value.rs` | `docs/HOST_SERVICES.md` | | ||
| | `src/proxywasm/secret.rs` | `docs/HOST_SERVICES.md` | | ||
| | `src/proxywasm/dictionary.rs` | `docs/HOST_SERVICES.md` | | ||
| | `src/proxywasm/utils.rs` | `docs/HOST_SERVICES.md` | | ||
| | `src/proxywasm/` (CDN lifecycle, FFI) | `docs/CDN_APPS.md` | | ||
| | `Cargo.toml` (version, features) | `docs/INDEX.md` | | ||
| | `fastedge-plugin-source/manifest.json` | `.github/copilot-instructions.md` | | ||
|
|
||
| ### Violation example | ||
|
|
||
| > PR changes `send_request` signature in `src/lib.rs` but `docs/SDK_API.md` still shows the old signature → **request changes**. Run `./fastedge-plugin-source/generate-docs.sh` before merge. | ||
|
|
||
| ### Quickstart protection | ||
|
|
||
| If any public API signature or behavior changes, check whether `docs/quickstart.md` examples are still accurate. Request regeneration if examples would no longer work against the updated code. | ||
|
|
||
| ## Pipeline source contract | ||
|
|
||
| If `fastedge-plugin-source/manifest.json` lists source files that overlap with files changed in this PR, request that `docs/` is regenerated (run `./fastedge-plugin-source/generate-docs.sh`) to keep the plugin pipeline's source material current. | ||
|
|
||
| ## Quality Rules | ||
|
|
||
| - All public function signatures in docs must match actual source declarations | ||
| - No `eprintln!` or `eprint!` in any code or examples — output is lost on the platform | ||
| - New HTTP examples must use `#[wstd::http_server]`, not `#[fastedge::http]` | ||
| - No marketing language in documentation — precise, technical prose only |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| name: Copilot Instructions Sync | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - fastedge-plugin-source/manifest.json | ||
| - fastedge-plugin-source/check-copilot-sync.sh | ||
| - .github/copilot-instructions.md | ||
| - .github/workflows/copilot-sync.yml | ||
| - examples/** | ||
| - docs/** | ||
|
|
||
| jobs: | ||
| check-sync: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Check manifest ↔ copilot-instructions sync | ||
| run: bash fastedge-plugin-source/check-copilot-sync.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Check 3,
manifest_examples=$(... | grep '^examples/' | sort -u)can cause the whole script to exit underset -euo pipefailwhen the manifest currently contains zeroexamples/entries (grep exits 1). That would turn this intended advisory check into a hard failure. Consider filtering withjq(e.g.,select(startswith("examples/"))) or otherwise neutralizing the non-match case (e.g.,|| true) so an empty examples list results in warnings rather than an early exit.