Q&A: Phase 16.3 — ImprovementPlanner (priority formula, safety gate, parameters tuple, lock scope) #425
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.3 —
ImprovementPlannerIssue: #423 | Show & Tell: #424
Q1: Why does
ImprovementActionuseTuple[Tuple[str, str], ...]forparametersinstead ofdict?A:
ImprovementActionis a frozen dataclass, which means it must be hashable (for use in sets or as dict keys).dictis not hashable — a frozen dataclass containing adictwill raiseTypeError: unhashable type: 'dict'at construction time. Using a tuple of 2-tuples keeps the dataclass hashable while still supporting key-value semantics. Convert to dict when reading:dict(action.parameters).Q2: The priority formula can go negative. What happens then?
A: The formula
urgency - cost_weight × costcan produce a small negative value when cost is high and urgency is low (e.g., urgency=0.1, cost=0.70 → priority=-0.11). The result is clamped to[0.0, 1.0]withmin(1.0, max(0.0, priority)), so it becomes 0.0. Combined with themin_priority_thresholdfilter (default 0.2), such actions are discarded entirely — which is the correct behaviour: proposing an expensive module hot-swap to fix a barely-detectable weakness would be wasteful.Q3: What is the scope of the
asyncio.LockinRuleBasedPlanner?A: The lock covers the entire
plan()body — both the rule-matching loop and the safety-gate calls. This means concurrentplan()calls are serialised. The rationale is that the rule table and counters are shared state; serialising is safe and the planning loop is expected to be fast (microseconds). If profiling shows contention, the lock scope can be narrowed to counter increments only — but this requires the safety-filter calls to be re-entrant, which is not guaranteed for all implementations.Q4: How does
_downgrade()preserve operator intent when blocking a HOT_SWAP_MODULE?A:
_downgrade()replacesaction_kindwithFLAG_FOR_REVIEWand prepends"[safety-gated] original=HOT_SWAP_MODULE; "to the rationale string. Themodule_name,priority, andparametersare preserved verbatim. This means theSelfOptimiseror a human operator can see: (a) which module was targeted, (b) what the original intent was, and (c) that it was blocked by the safety filter — without losing any diagnostic context.Q5: Can I override cost estimates per-module rather than globally?
A: Not in the current
PlannerConfigdesign, which uses a singlecost_weightscalar. To support per-module overrides, extendPlannerConfigwithmodule_cost_overrides: Tuple[Tuple[str, float], ...] = ()and look up the override inplan()before applying the formula. This is a good first-contribution opportunity — see issue #423.Q6: How does
max_actions_per_reportinteract with a batch of 10 reports?A: The current implementation applies the cap as
max_actions_per_report × len(reports). Withmax_actions_per_report=3and 10 reports, the global cap is 30 actions. This is intentionally permissive at the batch level — theSelfOptimiseris responsible for rate-limiting execution. If you want strict per-report caps, track a per-report counter inside the inner loop and break when it hitsmax_actions_per_report.Q7: What does a full Grafana panel config look like for the planner?
Beta Was this translation helpful? Give feedback.
All reactions