Repository navigation
Core correctness and API ergonomics - #3
Merged
Merged
Conversation
Covers 5 phases: Process API surface, GenServer ergonomics (ServerRef, reply, stop), Supervisor completeness (terminate/delete/restart_child), Application fixes (remove unsafe, fix stop_all ordering), and documentation sync.
…_after Expose Erlang/OTP-style process primitives as top-level convenience functions that delegate to task-local context, matching the existing pattern used by current_pid(), send(), recv(), and exit(). - Add ProcessFlag enum (TrapExit variant) in core module - Add link/unlink for bidirectional failure propagation - Add monitor/demonitor for unidirectional process observation - Add flag() for setting process flags (returns previous value) - Add send_after() convenience wrapper with OTP argument order - Export all new functions from runtime, lib.rs, and prelude - Add integration test verifying all new functions work in process context
Phase 2 of the core correctness and API ergonomics plan: - Add ServerRef type for addressing GenServers by Pid or registered name - Update call() and cast() to accept impl Into<ServerRef> instead of Pid - Add public reply() function for deferred reply pattern (NoReply + later reply) - Add public stop() function for graceful GenServer shutdown - Update lib.rs prelude re-exports to include ServerRef, reply, stop - Remove #[allow(dead_code)] from encode_stop (now used by stop()) - Add tests for ServerRef conversions, resolve, call with ServerRef, and stop
…start) Replace stub implementations of terminate_child and delete_child with real message-passing command pattern using TaggedEnvelope protocol. Add new restart_child public API. Fix wait_for_termination to use task-local context instead of global runtime.
Replace raw pointer extraction with Arc::clone for safe access to application start functions across RwLock boundaries. The previous approach extracted a raw pointer from a Box behind a RwLock guard and used it after the guard was dropped via an unsafe block. Also fix stop_all to properly stop applications in reverse dependency order using visit_deps, rather than relying on arbitrary HashMap iteration order.
Sync documentation with the real code after Phases 1-4 consolidated the project into a single crate with updated APIs: - Crate structure: single `crates/ambitious/` crate, not multi-crate - GenServer: self-as-state pattern with &mut self handlers, Init/Reply/Status return types - Supervisor: SupervisorInit with SupervisorFlags, RuntimeHandle-based client API - Term/Message: separate traits (Term for serialization, Message for tagged dispatch) - Process API: updated signatures (SendError, Result returns, current_pid) - Build commands: cargo test -p ambitious (not ambitious-process)
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
link,unlink,monitor,demonitor,flag,send_afteras top-levelambitious::convenience functions, plus newProcessFlagenumServerReftype (address GenServers by PID or registered name), updatecall/castto acceptimpl Into<ServerRef>, add publicreply()for deferred replies andstop()for graceful shutdownterminate_child/delete_childstubs with real implementations using OTP-faithful command message pattern; add newrestart_childfunctionunsafeblock fromAppControllerby switching fromBoxtoArcfunction pointers; fixstop_allto use reverse dependency ordering&mut selfGenServer handlers,Reply<T>/Status/Init<Self>return types, correct trait signatures)Test plan
just cigreen: fmt, clippy, tests)#[deny(warnings)]unsafecode remaining in application modulePidarguments still work viaFrom<Pid> for ServerRef