Issue 131 #138
No reviewers
Labels
No labels
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
refactor
rust
technical-debt
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
navicore/patch-seq!138
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "issue-131"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
https://github.com/navicore/patch-seq/issues/131
Code Review: PR #138 - Generator/Weave Support
Overview
This PR implements generator/coroutine support for Seq through a new "weave" system. The implementation adds
strand.weave,strand.resume, andyieldoperations to enable lazy sequences and backtracking patterns (particularly for the seq-prolog project).✅ Strengths
1. Excellent Architecture & Documentation
weave.rsmodule has comprehensive documentation explaining the architecture, flow, and API2. Consistent Naming Convention
spawntostrand.spawnthroughout the codebasestrand.namespace convention3. Type System Integration
builtins.rsRowVar)4. Follows Existing Patterns
spawnimplementation patternsACTIVE_STRANDScounter and shutdown synchronization⚠️ Issues & Concerns
1. CRITICAL: Missing Test Coverage
Severity: High
The PR adds 434 lines of new runtime code but includes only a single example program (
counter.seq) with no automated tests.Required:
tests/integration/src/test-weave.seqyieldoutside a weave (should panic)yieldwith different value types)Reference: See existing test patterns in
tests/integration/src/test-channel-safe.seq2. CRITICAL: Binary File in PR
Severity: High
The file
http_simple(2.4MB executable) was accidentally committed:Action Required:
Add to
.gitignoreif not already present:3. Potential Memory Leak in Weave Registry
Severity: Medium
Location:
crates/runtime/src/weave.rs:352-357If a weave is created but never resumed to completion, the entry remains in
WEAVE_REGISTRYindefinitely.Scenario:
Suggested Fix:
Consider adding a cleanup mechanism:
strand.weave-closeoperation4. DONE_SENTINEL Collision Risk
Severity: Low
Location:
crates/runtime/src/weave.rs:39While unlikely, a weave could legitimately yield
i64::MIN, causing premature completion detection.Suggested Fix:
Use a dedicated enum or
Option<Value>in the channel:5. Panic on Invalid Weave ID
Severity: Low
Location:
crates/runtime/src/weave.rs:309-315Resuming with a non-Int value panics. Consider if this should return an error state instead for better error handling.
Current:
Consider: Return
(weave_id, 0, false)to indicate error without panic.6. Thread-Local Storage with May Migration
Severity: Low
Location:
crates/runtime/src/weave.rs:55-56The
CURRENT_WEAVEuses thread-local storage, but May can migrate coroutines between threads. While the architecture doc mentions this is acceptable for arenas, verify that:7. Type Signature Limitation
Severity: Low
Location:
crates/compiler/src/builtins.rs:495-503The
yieldtype signature is( a b -- a b ), which implies the yielded and resumed values must be the same type. This may be too restrictive.Example that might not type-check:
Consider if this should be
( a b -- a c )to allow different resume types.📋 Minor Issues
8. Code Duplication in weave.rs
Lines 124-200 (Quotation handling) and 201-261 (Closure handling) have significant duplication. Consider extracting common logic:
9. Incomplete Naming Migration
While most references were updated to
strand.spawn, verify that:strand.spawnnotspawn10. Missing Documentation Updates
The following docs should be updated:
docs/ARCHITECTURE.md:213-228- Update concurrency section to mention weavesdocs/language-guide.md- Add weave/generator examplesREADME.md:122-125- Update concurrency section🔒 Security Assessment
✅ No security issues identified
🎯 Performance Considerations
Positive:
Concerns:
WEAVE_REGISTRYlock on every resume (potential contention)DashMap) if high concurrency expected✅ Action Items
Must Fix (Blocking):
http_simplebinary fileShould Fix:
4. ⚠️ Replace
DONE_SENTINELwith proper enum5. ⚠️ Document thread migration behavior with weaves
6. ⚠️ Update architecture documentation
Nice to Have:
7. ✨ Reduce code duplication in
weave.rs8. ✨ Consider more flexible
yieldtype signature9. ✨ Add
docs/WEAVE_GUIDE.mdwith detailed examples📊 Overall Assessment
Code Quality: B+ (well-structured, good patterns, missing tests)
Documentation: B (good inline docs, needs user-facing guide)
Completeness: C+ (core implementation solid, testing incomplete)
Recommendation: Request changes for:
Once addressed, this will be a solid addition to the language. The architecture is sound and follows established patterns well.
Review generated with assistance from Claude Code
Code Review: PR #138 - Weave/Generator Implementation
Summary
This PR successfully implements generator/coroutine support (weaves) for Seq, addressing issue #131. The implementation adds three new operations (
strand.weave,strand.resume,yield) with a zero-mutex, channel-based architecture that maintains consistency with the existing strand/channel design.Overall Assessment: Strong implementation with excellent architecture. A few minor issues to address.
Strengths
1. Architectural Excellence
The zero-mutex design is outstanding:
2. Type System Integration
Well-integrated with Seq's type system:
builtins.rs3. Documentation Quality
Excellent inline documentation:
weave.rsexplains architecturecounter.seqandtest-weave.seq4. Consistent Naming
The rename from
spawntostrand.spawnmaintains namespace consistency and sets up clean API evolution.Issues & Recommendations
Critical
1. Potential Memory Leak in
patch_seq_weave(crates/runtime/src/weave.rs:134)When the quotation completes, you pop the WeaveCtx but don't properly clean up the final stack:
The returned stack pointer is discarded. If there are other values on the stack, they leak.
Fix: Either assert the stack is empty, or properly clean up all remaining values:
Same issue at line 188 for the Closure path.
2. Inconsistent Error Handling (crates/runtime/src/weave.rs:261, 330)
patch_seq_resumereturns false on channel errors (good), butpatch_seq_yieldpanics (bad):Recommendation: Either document why yield should panic (programming error?) or make it return a Result/Bool for consistency. The current design means weaves can't gracefully handle cancellation from the caller side.
High Priority
3. Missing Stack Validation (crates/runtime/src/weave.rs:240, 306)
Both
patch_seq_resumeandpatch_seq_yieldassert stack is not null but don't verify sufficient depth:Fix: Either document that pop is safe to call on empty stack (returns sentinel?) or add proper depth checks.
4. Type System Limitation (crates/compiler/src/builtins.rs:496-507)
The
yieldsignature uses generic type variables but doesn't enforce that WeaveCtx is actually a WeaveCtx:This means the type checker won't catch:
Recommendation: Either add a WeaveCtx type to the type system, or document this as a known limitation.
Medium Priority
5. Sentinel Value Choice (crates/runtime/src/weave.rs:40)
While unlikely, this prevents
i64::MINfrom being a valid yielded value.Alternatives:
6. Missing Test Coverage
The test file
test-weave.seqis good but missing:7. Auto-Closure Conversion Comment (crates/compiler/src/typechecker.rs:843)
Should this also handle
strand.weave? The comment mentions spawn but not weave. Either add weave to the condition or document why weave doesn't need it.Low Priority (Enhancements)
8. Performance: Unnecessary Clones
Lines 257-258 in
weave.rs:You clone the value even if send might fail. Consider:
Though Arc clones are cheap, avoiding unnecessary work is better.
9. Missing Debug Trait Implementation
WeaveCtx in
value.rsis not included in any Debug implementations. This makes debugging harder.10. Serialization Error Message (crates/runtime/src/serialize.rs:193)
The error message says "ChannelNotSerializable" for a WeaveCtx. Consider adding a dedicated
WeaveNotSerializableerror for clarity.Security Assessment
No security concerns identified.
The implementation:
Performance Considerations
Overall: Good performance characteristics
Pros:
Potential concerns:
Recommendation: Add benchmark comparing weave-based iteration vs recursive approaches for the examples (counter, fibonacci, etc.)
Code Quality & Style
Excellent overall. The code follows Rust best practices:
Minor style notes:
patch_seq_weave). Consider extracting helpers for Quotation vs Closure paths.unsafe { ... }blocksTesting
Based on the commit messages, you report:
Recommendations:
Documentation
Good but could be expanded:
What's missing:
API Design
The explicit context threading is elegant but verbose. Compare:
Current:
Alternative (if implicit):
The explicit approach is more principled and avoids hidden state. Good choice for a systems language.
Question: Is the plan to add effect tracking (as mentioned in issue #131 comments) in a future PR? That would make the context requirement compile-time verifiable.
Recommendations Summary
Must Fix
Should Fix
Nice to Have
Conclusion
This is high-quality work that successfully implements a complex feature with excellent architecture. The zero-mutex design is particularly impressive and shows deep understanding of the existing concurrency model.
The issues identified are primarily:
Once the critical issues are addressed, this is ready to merge.
Estimated effort to address critical issues: 1-2 hours
Great work! 🎉
Code Review: Weave (Generator) Implementation
This PR implements generator/coroutine support ("weaves") for Seq, addressing issue #131. The implementation is comprehensive and well-designed. Below is my detailed review.
✅ Strengths
1. Excellent Architecture - Zero-Mutex Design
The weave implementation follows the same lock-free pattern as channels by passing communication handles on the stack rather than using a global registry. This is elegant and avoids contention.
2. Type System Integration
The addition of computational effects to the type system is well-designed:
SideEffect::Yieldproperly captures the yielded type| Yield Tsyntax is clear and follows conventions3. Consistent API Naming
Renaming
spawn → strand.spawnand addingstrand.weave,strand.resumecreates a coherent namespace. Good consistency.4. Comprehensive Testing
5. Good Documentation
The inline comments and module documentation clearly explain:
🔍 Issues & Concerns
CRITICAL: Resource Leak Risk
Location:
crates/runtime/src/weave.rs:99-141,crates/runtime/src/weave.rs:160-196Issue: If a weave is created but never resumed to completion, the spawned coroutine will hang forever waiting on
resume_chan.receiver.recv(), and the active strand count will never decrement.Scenario:
Impact:
wait_all_strands()Recommended Fix:
Implement a
Drophandler for WeaveHandle or use weak references with timeout:HIGH: Panic in Production Code
Location:
crates/runtime/src/weave.rs:321,331-332,337Issue: The
yieldfunction usespanic\!for error handling. In a language runtime, panics should be reserved for unrecoverable bugs, not user errors.Better approach: Return error values on the stack (like channels do with success flags):
Or use Seq's type system to enforce
yieldonly in weave contexts at compile time (which you're already doing with effects!).Severity: Medium - The type system already prevents misuse, but runtime defense is good practice.
MEDIUM: Effect Matching Too Lenient
Location:
crates/compiler/src/typechecker.rs:340-354Issue: The check only verifies that inferred effects are declared, but doesn't verify that ALL declared effects are actually used. This allows declaring effects that don't occur:
Impact:
Recommended Fix:
MEDIUM: Missing
effect_matches_anyImplementationLocation:
crates/compiler/src/typechecker.rs:340The code calls
self.effect_matches_any()but this method is not defined in the diff. Is it implemented elsewhere? If not, the code won't compile.Action Needed: Verify this method exists or add it:
LOW: Inconsistent Naming
Location:
crates/runtime/src/weave.rs:348Issue: The function is named
weave_yieldin the export butyieldin Seq. This inconsistency could confuse developers.Suggestion: Use
yieldorpatch_seq_weave_yieldfor consistency:LOW: Sentinel Value Magic Number
Location:
crates/runtime/src/weave.rs:40Concern: Using
i64::MINas a sentinel is fragile. If a user actually yieldsi64::MIN, it would be misinterpreted as completion.Probability: Low, but edge case exists.
Better approach: Use a dedicated enum or variant type:
Or reserve a special
Valuevariant:LOW: Clone Overhead
Location:
crates/runtime/src/weave.rs:258,327Issue: Values are cloned before sending through channels. For large variants or strings, this could be expensive.
Consideration:
Impact: Minor performance concern, likely acceptable for generator use cases.
INFO: Test Coverage Gaps
Location:
tests/integration/src/test-weave.seqMissing test cases:
Recommendation: Add these test cases to ensure robustness.
🛡️ Security Considerations
1. Stack Overflow
The
counter-loopexample uses tail recursion to create an infinite generator. Verify TCO works correctly for weaves - if TCO fails, stack overflow is possible.Test needed:
2. Use-After-Free Prevention
Verify that dropping a WeaveHandle doesn't cause use-after-free if the weave is still running. The
Arc<ChannelData>should prevent this, but worth explicit testing.📊 Performance Considerations
1. Channel Allocation
Each weave creates two MPMC channels. For high-frequency generator creation, this could add overhead.
Benchmark needed:
2. Context Switch Cost
Every
yieldinvolves two channel operations (send + recv). May's coroutine switch is ~100ns, but channel ops might add latency.Benchmark needed:
3. Memory Footprint
Each weave has:
For applications creating thousands of weaves, this could add up.
📝 Documentation Suggestions
1. Add Migration Guide
For users upgrading, document the
spawn → strand.spawnrename:2. Document Effect System
Add examples to
TYPE_SYSTEM_GUIDE.md:3. Add "Weave vs Strand" Guide
Help users choose between
strand.spawnandstrand.weave:✅ Best Practices Followed
strand.*namespace is clean🎯 Recommendations
Before Merge:
effect_matches_anyimplementation existsPost-Merge (Future Work):
strand.weave_timeoutfor bounded executionTYPE_SYSTEM_GUIDE.md📊 Summary Score
Overall: 8/10 - Excellent implementation with minor issues to address.
🏁 Verdict
APPROVE WITH CHANGES REQUESTED
This is a solid implementation of a complex feature. The architecture is excellent and the type system integration is well-designed. However, the resource leak issue should be addressed before merge.
The PR demonstrates strong understanding of Seq's architecture and makes thoughtful design choices (zero-mutex, effect system, TCO compatibility). With the critical issue fixed, this will be a valuable addition to the language.
Great work! 🎉
Review conducted with attention to: code quality, type safety, concurrency correctness, memory safety, performance, and documentation quality, following the repository's architectural principles.
Pull Request Review: Issue #131 - Generator/Weave Support
Summary
This PR successfully implements generator/coroutine support ("weaves") for Seq, enabling lazy sequences, streaming, and backtracking patterns. The implementation is well-designed, leveraging the existing May coroutine infrastructure with bidirectional channel-based communication.
Overall Assessment: ✅ Excellent implementation with minor recommendations
🎯 Strengths
1. Zero-Mutex Design
The weave architecture follows the same philosophy as channels - no global registry, no mutex contention. WeaveCtx travels on the stack as a value, which is elegant and avoids synchronization overhead.
2. Type System Integration
The computational effects system is well-designed:
SideEffect::Yieldproperly tracks generator effectsThe error messages are helpful:
3. Documentation Quality
Excellent inline documentation, particularly in:
crates/runtime/src/weave.rs(architecture, resource management, limitations)examples/weave/counter.seqis comprehensive4. Consistent Naming
The rename from
spawntostrand.spawnimproves clarity and namespacing. The new names (strand.weave,strand.resume) are intuitive.🐛 Potential Issues
1. Resource Leak Risk (High Priority)
Location:
crates/runtime/src/weave.rs:32-49The documentation warns about resource leaks if weaves aren't resumed to completion:
Problem: This is a footgun for users. Unlike channels (which can be safely dropped), weaves require explicit cleanup.
Recommendations:
DropforWeaveCtxthat panics or logs if dropped while still active:Track weave state - Add a state field to detect incomplete weaves.
Document escape hatches - Provide a
weave.cancel()or similar for explicit early termination.2. i64::MIN Sentinel Conflict (Medium Priority)
Location:
crates/runtime/src/weave.rs:62-67Problem: Silent data corruption if user yields
-9223372036854775808.Recommendations:
Send
WeaveMessage::Yield(value)for normal yields andWeaveMessage::Donefor completion. This eliminates the sentinel entirely.i64::MINinpatch_seq_yieldand panic with a clear error.3. Missing Serialization Support (Low Priority)
Location:
crates/runtime/src/serialize.rs:193Note: Currently reuses
ChannelNotSerializableerror. Consider adding:This is fine for now since weaves inherently can't be serialized (they contain runtime state), but a specific error type would be clearer.
4. Type Safety: Effect Polymorphism
Location:
crates/compiler/src/typechecker.rs:920-923Question: Can quotations with
Yieldeffects be passed tostrand.spawn?Looking at line 941-942:
Recommendation: Verify that
strand.spawnrejects quotations withYieldeffects (since spawn is fire-and-forget). Consider adding a test:⚡ Performance Considerations
1. Channel Overhead
Each weave creates two MPMC channels. For fine-grained generators (e.g., byte-level streaming), this might be overkill.
Mitigation: Document recommended use cases (coarse-grained generators). For high-frequency yields, users should batch values.
2. Arc Cloning
Channels are wrapped in
Arcand cloned frequently:Status: This is correct and necessary. Arc cloning is cheap (atomic increment), and the design avoids locks, so performance is good.
3. Stack Cloning for Quotations
Location:
crates/runtime/src/weave.rs:120Observation: Stack cloning for quotations (vs. fresh stack for closures) is correct but potentially expensive for deep stacks.
Recommendation: Mention in documentation that weaves with quotations inherit the creation stack (like
strand.spawn).🔒 Security Concerns
1. Unsafe Code Review
The unsafe code looks correct:
Verification:
assert!(!stack.is_null())Value::Quotationbeforestd::mem::transmute(wrapper)child_base.is_null()check before useNo issues found.
2. Channel Cleanup on Panic
If the weave quotation panics, the channels are dropped (via RAII), so no leak occurs. The caller will get a channel error on the next resume. Good!
🧪 Test Coverage
Positive Aspects:
tests/integration/src/test-weave.seqexamples/weave/counter.seqGaps:
No test for resource leaks - Should have a test that intentionally leaks a weave and documents expected behavior.
No test for Yield effect type checking - Add negative tests:
No test for strand.spawn + Yield rejection - Verify that spawning a yielding quotation is rejected.
No stress test - Consider a test that creates/resumes thousands of weaves to verify no memory leaks.
No test for i64::MIN edge case - Document that yielding
i64::MINis unsupported (or add a panic test).Recommendations:
📝 Code Quality & Best Practices
1. Consistent Style ✅
2. Error Handling ✅
3. Backward Compatibility ✅
spawn→strand.spawnis breaking but intentional4. Documentation ⚠️
Missing:
Suggestion for README.md:
🎯 Recommendations Summary
High Priority:
Medium Priority:
Low Priority:
✅ Approval Decision
Status: Approved with recommendations
This is a well-designed feature that integrates cleanly with Seq's existing architecture. The type system integration is particularly impressive. Address the high-priority items (resource leak detection, sentinel replacement) before merging, but the core implementation is solid.
The PR successfully achieves its goal of enabling seq-prolog and other generator-based patterns. Great work! 🚀
Reviewed by: Claude Code
Review Date: 2025-12-30
PR Review: Generator/Coroutine Support (Issue #131)
This is an impressive implementation of generator support with strong type system integration. The PR delivers a well-architected solution with excellent documentation and test coverage.
🎯 Summary
This PR implements generator/coroutine functionality using a zero-mutex, stack-based design where weave contexts travel as values rather than through global state. The implementation includes:
strand.weave,strand.resume,yield,strand.weave-cancel)| Yield Tannotations✅ Strengths
1. Excellent Architecture
strand.weave-cancelprevents resource leaks2. Strong Type System Integration
| Yield Tannotations provide compile-time safety (crates/compiler/src/types.rs:13-23)3. Comprehensive Documentation
4. Thorough Testing
🔍 Code Quality Observations
Runtime Implementation (crates/runtime/src/weave.rs)
Good:
Potential Issues:
Sentinel Value Limitations (lines 84-88)
i64::MINandi64::MIN + 1cannot be yieldedPanic on Channel Errors (line 399)
extern "C"functions can cause undefined behaviorUnreachable After Blocking (line 422)
unreachable!()Type System (crates/compiler/src/typechecker.rs)
Excellent work on bidirectional effect checking!
Effect Propagation Through Quotations (line 820)
strand.weave? Or isstrand.spawnmeant to reject them?Effect Merging in Branches (lines 838-845)
contains()to deduplicate effectsYield Tbut may need refinement if more effect types are addedHashSetor ensuring effects are properly ordered/canonicalParser (crates/compiler/src/parser.rs)
Clean implementation of effect annotation parsing
|🐛 Potential Bugs
1. Resource Leak on Dropped WeaveHandle
strand.weave-cancel, the spawned coroutine hangs forever2. Stack Overflow in Infinite Loops Without Yield
Yieldannotation but doesn't enforce that yield is actually calledActually, checking the code more carefully - this is already handled correctly by the bidirectional checking. False alarm! ✅
⚡ Performance Considerations
1. Channel Allocation Per Weave
strand.weavecreates two channels (yield_chan, resume_chan)2. Arc Cloning
Arc<ChannelData>3. Sentinel Value Checks
🔒 Security Concerns
1. No Memory Safety Issues
2. No Panic Across FFI Boundary
3. No Data Races
📊 Test Coverage
Excellent coverage overall:
✅ Basic yield/resume flow (test-weave.seq)
✅ Completion detection
✅ Immediate completion (no yields)
✅ Cancellation before first resume
✅ Cancellation after partial resume
✅ Records with nested ADTs (test-weave-records.seq)
✅ Natural completion with records
Suggestions for additional tests:
🎨 Style and Best Practices
1. Naming Convention
strand.weave,strand.resume,strand.weave-cancel- consistent namespace ✅strand.spawn✅2. Comment Quality
3. Example Quality
🚀 Recommendations
High Priority
Medium Priority
Low Priority
📝 Documentation Suggestions
The documentation is excellent! Minor additions:
✅ Final Assessment
Overall: Excellent work! 🎉
This PR demonstrates:
The implementation achieves the goals stated in issue #131 and provides a solid foundation for seq-prolog and other generator use cases.
Verdict: APPROVE ✅
The identified issues are minor and mostly suggestions for future improvements. The core implementation is sound, well-tested, and production-ready.
What Makes This PR Stand Out:
Great work! This is a substantial feature addition that's well-integrated with the existing codebase.
Pull Request Review: Generator/Weave Support (Issue #131)
Summary
This PR adds comprehensive generator/coroutine support to Seq through the "weave" mechanism, enabling lazy sequences, streaming, and backtracking patterns. This is a significant and well-architected feature addition that aligns with the repository's goals and implements the feature request from Issue #131.
✅ Strengths
1. Excellent Architecture & Design
crates/runtime/src/weave.rswith clear documentationstrand.weave-cancelprevents resource leaks from abandoned weaves2. Type System Integration
SideEffect::Yieldto the type system (crates/compiler/src/types.rs:12-30) properly tracks generator effects at compile time3. Documentation Quality
weave.rsexplaining the zero-mutex design, API, architecture, and resource managementexamples/weave/counter.seqandexamples/weave/sensor-classifier.seqtests/integration/src/test-weave.seqandtests/integration/src/test-weave-records.seq4. Lint Integration
crates/compiler/src/lints.toml(lines 122-150) to catch common mistakes:weave-immediate-drop: Prevents dropping WeaveHandle without cancellation (error severity)unchecked-resume: Warns about not checking completion status5. Migration & Backward Compatibility
spawntostrand.spawnmaintains consistency with newstrand.weaveAPI🔍 Issues & Concerns
CRITICAL: Sentinel Value Collision Risk
Location:
crates/runtime/src/weave.rs:79-88Using
i64::MINandi64::MIN + 1as sentinels means users cannot yield these values. While documented (lines 66-71), this is a silent correctness bug - yielding i64::MIN would be SILENTLY interpreted as completion with no error message.Impact: High - data corruption with no error message
Recommendation: Use a tagged enum or wrapper type instead to eliminate the sentinel collision risk entirely. The performance overhead of matching is negligible compared to the channel send/receive operations.
HIGH: Resource Leak on Panic
Location:
crates/runtime/src/weave.rs:398-406If
yieldpanics, the strand counter is never decremented, causingwait_all_strandsto hang forever.Recommendation: Wrap coroutine execution in a panic guard or use
catch_unwindto ensurecleanup_strand()is always called, even on panic.MEDIUM: Type System - Unchecked Effect Soundness
Location:
crates/compiler/src/typechecker.rs:344-367The bidirectional effect checking is good, but the type system doesn't verify that the Yield effect CAN occur (just that IF it occurs, it's declared). A function that declares
| Yield Intbut never actually yields is allowed.Recommendation: This is probably acceptable (conservative typing), but consider adding a lint for "declared but never used" effects if you want stricter checking.
MEDIUM: Missing Tests
While test coverage is good, these scenarios are missing:
strand.weave-cancelis called while the weave is actively executing (not blocked on yield)?Recommendation: Add stress tests and error case tests.
LOW: Parser Effect Annotation Edge Cases
Location:
crates/compiler/src/parser.rs:732-776The parser requires at least one effect after
|(line 771). Document the grammar explicitly and add tests for invalid syntax like( a -- b | )and consider future extensibility for multiple effects.LOW: Documentation - Sentinel Value Warning
The sentinel value limitation is documented in
weave.rsbut NOT in the user-facing language guide or examples.Recommendation: Add a warning box to
docs/language-guide.mdor create adocs/WEAVE_GUIDE.mdexplaining what weaves are, how to use them, the i64::MIN limitation prominently, and resource management best practices.🎯 Code Quality
Best Practices ✅
strand.weave,strand.resume,strand.weave-cancel)Arc, proper Drop semantics)Minor Style Issues
crates/compiler/src/builtins.rs:467-520- Some comment formatting inconsistency (minor)crates/runtime/src/weave.rs:416-422- The "block forever" approach on cancellation is clever but could use more explanation🔒 Security
No significant security concerns. The weave mechanism:
unsafeblocks only where necessary (FFI boundaries)⚡ Performance
Performance looks good:
Note: The sentinel value check on every resume adds a branch, but this is unavoidable with the current design. Switching to a tagged enum would make this more explicit without performance penalty.
📝 Test Coverage
Test coverage is solid:
Missing:
🚀 Recommendations
Before Merge (Critical)
Before Merge (High Priority)
Future Work (Nice to Have)
yield_allfor sub-generator delegation🎉 Conclusion
This is high-quality work that adds a powerful and well-designed feature to Seq. The architecture is sound, the implementation is clean, and the integration with the type system is excellent.
The sentinel value issue is the main concern - it's a correctness bug waiting to happen in production code. Fixing this to use proper enum tagging would make this PR production-ready.
Recommendation: Request changes to address the sentinel value issue, then approve. The rest of the concerns can be addressed in follow-up PRs.
Reviewed by Claude Code
addressing concerns in separate PRs
see