Runtime autonomy release-candidate branch#5
Conversation
There was a problem hiding this comment.
Code Review
This pull request refines the local-first runtime contract of the ctxt CLI. It updates the DSL validator to reject legacy executable blocks (such as tools and tasks) while adding support for local-only syntax, updates documentation with a deterministic validation matrix, and introduces several smoke tests. The review feedback highlights two valuable improvement opportunities in src/runtime.rs: using strip_prefix instead of trim_start_matches to avoid repeatedly stripping prefixes, and optimizing the legacy block check to prevent unnecessary string allocations by performing case-insensitive checks in-place.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| fn valid_use_directive(line: &str) -> bool { | ||
| let name = line.trim_start_matches("use:"); | ||
| valid_identifier_body(name) | ||
| } |
There was a problem hiding this comment.
Using trim_start_matches with a string literal prefix like "use:" can be error-prone and misleading, as it repeatedly strips the prefix if it appears multiple times (e.g., "use:use:abc" becomes "abc").
To ensure the prefix is stripped exactly once and in a more idiomatic Rust fashion, use strip_prefix combined with map_or.
| fn valid_use_directive(line: &str) -> bool { | |
| let name = line.trim_start_matches("use:"); | |
| valid_identifier_body(name) | |
| } | |
| fn valid_use_directive(line: &str) -> bool { | |
| line.strip_prefix("use:") | |
| .map_or(false, valid_identifier_body) | |
| } |
| fn looks_like_block_legacy_semantic(line: &str) -> bool { | ||
| let lower = line.to_ascii_lowercase(); | ||
| lower.starts_with("oauth") | ||
| || lower.starts_with("provider") | ||
| || lower.starts_with("shell ") | ||
| || lower.starts_with("exec ") | ||
| || lower.starts_with("run ") | ||
| || lower.starts_with("http://") | ||
| || lower.starts_with("https://") | ||
| || lower.starts_with("resource://") | ||
| } |
There was a problem hiding this comment.
Calling to_ascii_lowercase() on every line during DSL validation allocates a new String each time, which introduces unnecessary memory overhead.
We can perform case-insensitive prefix checks without any allocations by using line.get(..prefix.len()) and eq_ignore_ascii_case.
fn looks_like_block_legacy_semantic(line: &str) -> bool {
let starts_with_ignore_case = |prefix: &str| {
line.get(..prefix.len())
.map_or(false, |sub| sub.eq_ignore_ascii_case(prefix))
};
starts_with_ignore_case("oauth")
|| starts_with_ignore_case("provider")
|| starts_with_ignore_case("shell ")
|| starts_with_ignore_case("exec ")
|| starts_with_ignore_case("run ")
|| starts_with_ignore_case("http://")
|| starts_with_ignore_case("https://")
|| starts_with_ignore_case("resource://")
}
Summary
This draft PR isolates the runtime-autonomy release-candidate work on top of
fusion/ctxt-runtime-only.It adds deterministic runtime-contract coverage and release-readiness hardening without enabling provider calls, network behavior, external agent execution, production MCP support, or crates.io publishing.
Changes
local-fixture-v1subset.RELEASE_NOTES_v0.1.0.mdwith the current local runtime scope.Boundaries
Local validation
Local validation passed:
cargo fmt --checkcargo checkcargo testcargo clippy -- -D warningscargo package --list --allow-dirtycargo test --releaseObserved local timing:
cargo test --release: 36.15scargo clippy -- -D warnings: 2.73sReview intent
Draft/experiment PR for visibility and review only.
Do not merge into
maindirectly.