Skip to content

docs: add comprehensive documentation for orchestrator_mapreduce module - #115

Open
groupthinking wants to merge 1 commit into
masterfrom
docs/orchestrator-mapreduce
Open

docs: add comprehensive documentation for orchestrator_mapreduce module#115
groupthinking wants to merge 1 commit into
masterfrom
docs/orchestrator-mapreduce

Conversation

@groupthinking

Copy link
Copy Markdown
Owner

Adds full documentation for the orchestrator_mapreduce.py module at docs/orchestrator_mapreduce.md.

Contents

  • Architecture diagram and lifecycle flow
  • Full API reference for all classes (TaskStatus, SubTask, OrchestratedJob, HierarchicalOrchestrator)
  • All public methods documented with signatures, parameters, and return types
  • Customization guide for verification gates and reducers (with contract specs)
  • Protocol compatibility table (legacy zero-arg vs new-style kwargs)
  • 5 complete usage examples
  • Integration reference with existing modules
  • Configuration tuning guidance
  • Error handling and escalation tiers
  • Changelog

Includes:
- Architecture diagram and lifecycle flow
- Full API reference for all classes and methods
- Customization guide (verification gates, reducers)
- Protocol compatibility table (legacy vs new-style)
- 5 usage examples (minimal, fan-out, heterogeneous, custom gate, step-by-step)
- Integration reference with existing modules
- Configuration tuning guidance
- Error handling and escalation tiers
Copilot AI review requested due to automatic review settings June 23, 2026 00:58
@groupthinking
groupthinking enabled auto-merge (squash) June 23, 2026 00:59
@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Summary by CodeRabbit

  • Documentation
    • Added extensive documentation for the orchestrator module including detailed coverage of system architecture, orchestration design patterns, complete API reference with code examples, practical usage scenarios from basic to advanced, guidance for customizing and extending functionality, comprehensive error handling and recovery documentation, state persistence information, memory optimization strategies, and integration guidelines for connecting with other system components.

Walkthrough

Adds docs/orchestrator_mapreduce.md, a 571-line reference document for the orchestrator_mapreduce module. The document covers the public API (__all__), data models (TaskStatus, SubTask, OrchestratedJob), HierarchicalOrchestrator constructor and lifecycle methods, customization contracts, protocol calling conventions via inspect.signature(), state persistence to STATE.md, failure tiers, usage examples, integration points, configuration reference, a lifecycle diagram, and a v1.0.0 changelog entry.

Changes

HierarchicalOrchestrator Documentation

Layer / File(s) Summary
Module identity, public API, and data models
docs/orchestrator_mapreduce.md
Documents module dependencies and __all__ exports alongside TaskStatus states and SubTask/OrchestratedJob field shapes.
Constructor and lifecycle methods
docs/orchestrator_mapreduce.md
Documents HierarchicalOrchestrator constructor parameters and the run/plan/map_execute/reduce_verify methods, including bounded concurrency, per-subtask timeouts, retry/mutation loop, escalation, and STATE.md persistence. Includes the lifecycle flow diagram.
Customization contracts and protocol calling conventions
docs/orchestrator_mapreduce.md
Documents the verification_gate return contract and reducer interface with worked examples; describes three task() calling conventions resolved via inspect.signature().
Persistence, failure tiers, and memory management
docs/orchestrator_mapreduce.md
Documents STATE.md audit append behavior, the three-tier failure strategy (retry/escalate/timeout), and max_job_history pruning during plan().
Usage examples, integration, configuration, and changelog
docs/orchestrator_mapreduce.md
Provides minimal through step-by-step usage examples; integration with protocols.loader, agents.mutator, utils.tracker, utils.logger; parameter configuration reference with tuning guidance; and v1.0.0 changelog entry.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • groupthinking/self-correcting-executor#114: Introduces the orchestrator_mapreduce.py implementation that this documentation directly describes, including HierarchicalOrchestrator, SubTask, OrchestratedJob, and the Plan→Map→Reduce lifecycle.

Suggested labels

documentation

Poem

🗺️ The plan divides, the map fans wide,
Subtasks race with bounded stride,
A gate inspects each reduced result—
Retry, mutate, or humans consult.
STATE.md holds the audit trail,
In quantum steps, no task shall fail! ⚛️

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main change: adding comprehensive documentation for the orchestrator_mapreduce module.
Description check ✅ Passed The description provides a clear summary of changes and lists documentation contents, but does not include the Type of change section or completion of the provided template checklist.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/orchestrator-mapreduce

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot added the documentation Improvements or additions to documentation label Jun 23, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new, comprehensive Markdown document describing the orchestrator_mapreduce.py module (Plan → Map → Reduce flow, public API/classes, customization points, protocol calling behavior, persistence, and examples) to help developers integrate and extend the orchestrator.

Changes:

  • Introduces full module documentation for orchestrator_mapreduce.py in docs/orchestrator_mapreduce.md.
  • Adds architecture/lifecycle diagrams, API reference, customization contracts, and usage examples.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +277 to +284
The module uses `inspect.signature()` to determine how to call each protocol's `task()` function:

| Protocol Signature | Behavior |
| :--- | :--- |
| `def task():` | Called with no arguments (legacy compatibility) |
| `def task(**kwargs):` | Receives the full `inputs` dict as keyword arguments |
| `def task(endpoint, timeout=30):` | Receives matching keys from `inputs` as named arguments |

Comment on lines +285 to +297
**Example — New-style protocol (`protocols/api_health_checker.py`):**

```python
import requests

def task(endpoint: str, timeout: int = 10) -> dict:
"""Check if an API endpoint is healthy."""
try:
resp = requests.get(f"https://api.example.com{endpoint}", timeout=timeout)
return {"success": resp.status_code == 200, "status_code": resp.status_code}
except Exception as e:
return {"success": False, "error": str(e)}
```
],
)
```

**Behavior:**
- Acquires a semaphore slot before executing each subtask
- Applies `subtask_timeout` via `asyncio.wait_for()`
- Tracks outcomes via `track_outcome()` (non-blocking, via `run_in_executor`)
| `verification_gate` | `Callable` | `_default_gate` | Async function that evaluates whether a job passes verification |
| `reducer` | `Callable` | `_default_reducer` | Async function that aggregates subtask results into a single output |
| `state_file` | `str` | `<module_dir>/STATE.md` | Path to the Markdown file where job state is persisted |
| `subtask_timeout` | `float` | `300.0` | Maximum seconds a single subtask may run before being killed |
| :--- | :--- | :--- |
| **Retry** | Subtask failed, `attempts < max_attempts` | Mutate protocol, re-execute |
| **Escalate** | All retries exhausted, verification still failing | Log escalation, notify human (via MCP/Slack when configured) |
| **Timeout** | Subtask exceeds `subtask_timeout` seconds | Kill subtask, mark as FAILED, enter retry tier |

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/orchestrator_mapreduce.md`:
- Line 21: The fenced code block at line 21 in the orchestrator_mapreduce.md
file is missing a language identifier, which violates the MD040 markdown linting
rule. Add the language identifier `text` immediately after the opening triple
backticks on the line containing the fenced code block start marker to specify
that this is a text/ASCII art block, ensuring compliance with markdown
standards.
- Line 520: The fenced code block at line 520 in the orchestrator_mapreduce.md
file is missing a language identifier, which violates the MD040 Markdown linting
rule. Add the language identifier `text` to the opening of the fenced code block
(the line with the opening triple backticks) since this contains an ASCII
diagram. Change the opening ``` to ```text to specify that the content is plain
text.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 1cc1a810-26b5-4476-a2fa-6f3e527537c5

📥 Commits

Reviewing files that changed from the base of the PR and between 1637fd3 and 2a5099a.

📒 Files selected for processing (1)
  • docs/orchestrator_mapreduce.md


## Architecture

```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Add language identifier to fenced code block (MD040).

Fenced code blocks should specify a language. Since this is ASCII art, use text:

📝 Fix MD040 violation
-```
+```text
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
```
🧰 Tools
🪛 markdownlint-cli2 (0.22.1)

[warning] 21-21: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/orchestrator_mapreduce.md` at line 21, The fenced code block at line 21
in the orchestrator_mapreduce.md file is missing a language identifier, which
violates the MD040 markdown linting rule. Add the language identifier `text`
immediately after the opening triple backticks on the line containing the fenced
code block start marker to specify that this is a text/ASCII art block, ensuring
compliance with markdown standards.

Source: Linters/SAST tools


## Lifecycle Diagram

```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Add language identifier to fenced code block (MD040).

Fenced code blocks should specify a language. Since this is an ASCII diagram, use text:

📝 Fix MD040 violation
-```
+```text
🧰 Tools
🪛 markdownlint-cli2 (0.22.1)

[warning] 520-520: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/orchestrator_mapreduce.md` at line 520, The fenced code block at line
520 in the orchestrator_mapreduce.md file is missing a language identifier,
which violates the MD040 Markdown linting rule. Add the language identifier
`text` to the opening of the fenced code block (the line with the opening triple
backticks) since this contains an ASCII diagram. Change the opening ``` to
```text to specify that the content is plain text.

Source: Linters/SAST tools

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants