Repository navigation
0.44: allow agent state - #85
Merged
Merged
Conversation
`evolvable! { type State: Default + Send + 'static; .. }` lets declared
functions take `&mut State` / `&State`. The agent defines `State`; the host
holds an opaque `symbiont::State` per run (`Runtime::new_state`, generated
`new_state(revision)`). The dylib allocates, borrows and drops the value
through exported glue, so only the code that knows the layout touches it.
- Bound to its revision by a tag (address of a static in the creating dylib),
checked by every export wrapper; a mismatch aborts, because equal crate
names make equal TypeIds with different layouts.
- Pins its revision like RevisionFn, value dropped before the pin, so
unload_revision cannot unmap the drop code under a live state.
- Panicking State::default() is an error, panicking Drop stays in the dylib.
- Miri covers the handle layout, borrows and drop order via state_preamble.rs.
One revision (~1.5k lines, half of it tests): the handle, the glue and the
macro only make sense together; split, the first half is dead code under
-D warnings.
…k the agent can act on
…ble code, so long-lived state iterates reproducibly
…eps a State between candles
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.
• Declared functions can now take &mut State or &State. You declare it with evolvable! { type State: Default + Send + 'static; .. }, and the agent defines the type.
• The host holds an opaque symbiont::State for each run, created with Runtime::new_state or the generated new_state(revision). The dylib allocates, borrows and drops the value itself, because only the code that knows the layout should touch it.
• Each State is tied to the revision that created it, and every call checks this. A mismatch aborts, because two revisions can share a TypeId but have different layouts.
• A State pins its revision. The value is dropped before the pin is released, so unload_revision cannot unmap code that a live state still needs.
• If State::default() panics, you get an error. A panic in Drop stays inside the dylib. Miri tests cover the handle layout, borrows and drop order.