Skip to content

feat(estimator): sub-cluster estimator + PlanExecutor fan-out (PR-2 #27 reopened) - #31

Merged
flg77 merged 2 commits into
mainfrom
feat/estimator-and-spawn
May 7, 2026
Merged

feat(estimator): sub-cluster estimator + PlanExecutor fan-out (PR-2 #27 reopened)#31
flg77 merged 2 commits into
mainfrom
feat/estimator-and-spawn

Conversation

@flg77

@flg77 flg77 commented May 7, 2026

Copy link
Copy Markdown
Owner

Reopened — original PR #27 was auto-closed when the upstream branch (PR #26) was deleted on merge. All commits + tests unchanged. Verified on acc1: 47/47 tests pass on this branch, 104/104 on the wider spot-check. See test/results/02_PR27_estimator_and_spawn.md for the full result.

flg77 and others added 2 commits May 6, 2026 22:35
…ustering)

New acc/cluster.py module:
* ClusterPlan dataclass with field invariants (subagent_count >= 1,
  difficulty in [0, 1]).
* In-memory registry (register/lookup/unregister/list) with optional
  Redis mirror via redis_compat — edge-friendly: works without Redis.
* new_cluster_id() emits c-prefixed UUIDs to discriminate from task_id
  (plan-…) and agent_id (<role>-<hex>) in log lines / dashboards.
* fetch_cluster_async() backfills from Redis on local-cache miss.

Wire-protocol propagation:
* acc/plan.py:_publish_task_assign accepts optional cluster_id +
  target_agent_id kwargs; both attached only when supplied so legacy
  single-agent payloads stay byte-identical.
* acc/agent.py:_handle_task echoes inbound cluster_id on every
  outbound TASK_PROGRESS and TASK_COMPLETE so cluster fan-in
  aggregators see a complete event stream per cluster.

TUI fan-out:
* NATSObserver gains register_cluster_listener / unregister_cluster_listener
  + internal _fan_out_cluster helper. Every cluster-tagged
  TASK_PROGRESS / TASK_COMPLETE fans out to per-cluster_id callbacks
  with per-callback exception isolation (one buggy listener cannot
  starve others). Payloads without cluster_id are silently ignored.

21 new tests in tests/test_cluster_propagation.py covering:
dataclass invariants, registry round-trip, sync/async lookup miss
behaviour, TASK_ASSIGN cluster_id presence/absence, listener fan-out,
unregister idempotency, multi-listener support, exception isolation.

Foundation for PR-2 (estimator + sub-cluster spawn) and PR-4
(TUI cluster panel). No user-visible change in this PR.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…-out (PR-2)

New acc/estimator.py:
* TaskComplexity dataclass — narrow input surface (tokens, task_type,
  required_skills, has_external_io).
* Estimator Protocol — pure callable, easy to fuzz + custom-implement.
* default_estimator: token-budget heuristic (base + ceil(tokens/per_n))
  with keyword-driven difficulty bumps.  Output clamped to
  [1, min(cap, role.max_parallel_tasks)] — defence in depth on top of
  Cat-A A-019.
* build_estimator() dispatcher: 'heuristic' (default) | 'fixed' |
  'module:dotted.path'.  Unknown / failing strategies log + fall back
  to heuristic — arbiter NEVER crashes on a buggy operator config.
* slice_skill_mix() round-robins skills across N sub-agents so no one
  member loads every skill prompt.
* derive_complexity() turns a raw step payload into TaskComplexity
  (token estimate via len(text)//4, [SKILL: ...] hint extraction).

acc/config.py:
* RoleDefinitionConfig gains max_parallel_tasks: int = 1 (legacy: no
  parallelisation) and estimator: dict[str, Any] = {}.  Schema is a
  free-form dict on purpose so 'module:' strategies don't need
  schema bumps.

acc/plan.py:
* PlanExecutor.__init__ accepts optional role_resolver / skill_resolver
  callbacks.  Without them, dispatch is byte-identical to PR-1.
* _maybe_build_cluster: consults the estimator, returns ClusterPlan or
  None for single-agent fallback.  All exceptions logged + downgraded
  to single-agent dispatch.
* _dispatch_cluster: fans one PLAN step out as N TASK_ASSIGN payloads
  sharing one cluster_id (PR-1 wire shape).
* on_task_complete: cluster aggregation — step transitions only after
  all members report.  COMPLETE if every member ok, FAILED if any one
  blocked.  Cluster auto-unregistered on transition.

regulatory_layer/category_a/constitutional_rhoai.rego:
* Bumped 0.4.0 → 0.5.0.
* Two new rules:
  - deny_cluster_oversize: subagent_count > role.max_parallel_tasks
  - deny_cluster_nonpositive: subagent_count < 1
  Both gate action='CLUSTER_SPAWN' so external (Gatekeeper) admission
  enforces the same invariant as the in-process clamp.

26 new tests in tests/test_estimator.py — heuristic shape, role-cap
clamp, [0,1] difficulty bound, skill_mix precedence, fixed strategy,
module: import + import-failure fallback, unknown-strategy fallback,
slice_skill_mix round-robin, derive_complexity SKILL-hint extraction,
PlanExecutor single-agent fallback, fan-out wire-shape, A-019 in-process
clamp, estimator-failure → single-agent fallback, cluster aggregation
all-members-must-report, any-blocked-fails-step.

47 passed across PR-1 + PR-2 test modules; 104 across all related
modules.

Foundation complete for PR-4 (TUI cluster panel) which subscribes via
the PR-1 register_cluster_listener and PR-3 (markdown role authoring,
independent of this PR).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@flg77
flg77 merged commit 97ea409 into main May 7, 2026
@flg77
flg77 deleted the feat/estimator-and-spawn branch May 7, 2026 12:21
flg77 pushed a commit that referenced this pull request Jun 11, 2026
Bumps [react-router](https://github.com/remix-run/react-router/tree/HEAD/packages/react-router) to 6.30.4 and updates ancestor dependency [react-router-dom](https://github.com/remix-run/react-router/tree/HEAD/packages/react-router-dom). These dependencies need to be updated together.


Updates `react-router` from 6.30.3 to 6.30.4
- [Release notes](https://github.com/remix-run/react-router/releases)
- [Changelog](https://github.com/remix-run/react-router/blob/react-router@6.30.4/packages/react-router/CHANGELOG.md)
- [Commits](https://github.com/remix-run/react-router/commits/react-router@6.30.4/packages/react-router)

Updates `react-router-dom` from 6.30.3 to 6.30.4
- [Release notes](https://github.com/remix-run/react-router/releases)
- [Changelog](https://github.com/remix-run/react-router/blob/react-router-dom@6.30.4/packages/react-router-dom/CHANGELOG.md)
- [Commits](https://github.com/remix-run/react-router/commits/react-router-dom@6.30.4/packages/react-router-dom)

---
updated-dependencies:
- dependency-name: react-router
  dependency-version: 6.30.4
  dependency-type: indirect
- dependency-name: react-router-dom
  dependency-version: 6.30.4
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant