Q&A: Phase 16.4 — SelfOptimiser (rate-limit, dispatcher, dry-run, HOT_SWAP wiring, mocking) #428
Unanswered
web3guru888
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Q&A: Phase 16.4 —
SelfOptimiser(rate-limiting, dispatch, dry-run, HOT_SWAP wiring)Q1: Why is
_lockheld for the entireenact()loop rather than per-action?A: The coarse lock prevents two concurrent
enact()calls from both passing the rate-limit check for the same(module, kind)key simultaneously. If call A and call B both seelast_ts=0and both see the cool-down has not been exceeded, both would succeed — defeating the throttle. Holding one lock serialises all enactments so rate-limit state is always coherent.If you need parallel enactment for different modules (lower latency at scale), replace the single
_lockwith adefaultdict(asyncio.Lock)keyed bymodule_name— then only enactments for the same module are serialised.Q2: What happens if
LiveModuleOrchestratoris not injected and aHOT_SWAP_MODULEaction arrives?A:
_apply_hot_swapchecksif self._orch is Noneand returnsEnactmentStatus.SKIPPEDwithdetail="no orchestrator injected". No exception is raised. This allowsSelfOptimiserto function in degraded mode (observe + plan but not swap) when the orchestrator is unavailable or not yet initialised.Q3: How does
dry_run=Trueinteract withFLAG_FOR_REVIEW?A:
dry_runis checked at the top of_dispatch()before thematchstatement, so all actions — includingFLAG_FOR_REVIEW— are short-circuited toSKIPPED. Nothing is enqueued toalert_queuein dry-run mode. This makes dry-run a true no-side-effect observation pass.Q4: What is the
attempted_atfield onEnactmentRecordused for?A:
attempted_atrecords the monotonic timestamp at which enactment was attempted.ReflectionCycle(Phase 16.5) uses this to:attempted_at - action_creation_time(if planners stamp actions with a creation time).Q5: Can two
EnactmentRecords for the same action appear in the sameenact()call?A: No. The loop iterates
actions(aSequence) and produces exactly oneEnactmentRecordper element. If the sameImprovementActionobject appears twice in the sequence (unlikely but possible if a caller dedupes poorly), it would produce two records with the second subject to rate-limiting (since the first updates_last_enactedimmediately onSUCCESS).Q6: How do I mock
CognitiveCyclefor_apply_tunein tests?A: Use a simple namespace object with the
_detector_configattribute:Q7: Grafana 4-panel dashboard YAML for
SelfOptimiserBeta Was this translation helpful? Give feedback.
All reactions