Skip to content

Conversation

@ahogappa
Copy link
Owner

@ahogappa ahogappa commented Jan 23, 2026

Summary

  • Add Taski::Env class to hold system-managed execution environment info (root_task, started_at, working_directory)
  • Remove system attributes from Taski::Args (now holds only user-defined options)
  • Add mock_env helper in TestHelper for testing

Motivation

Previously, Taski.args contained both user-defined options and system-managed execution information. This separation provides cleaner API:

  • Taski.args - User-defined options passed via run(args: {...})
  • Taski.env - System-managed execution environment information

API Changes

Before:

Taski.args[:env]              # User option
Taski.args.working_directory  # System info
Taski.args.started_at         # System info
Taski.args.root_task          # System info

After:

Taski.args[:env]              # User option
Taski.env.working_directory   # System info
Taski.env.started_at          # System info
Taski.env.root_task           # System info

Test plan

  • All existing tests pass
  • Tests updated to use Taski.env for system attributes
  • Lint passes

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • New Features

    • Added Env API for accessing runtime environment details (working directory, task start time, root task).
    • Task execution now supports direct instantiation with user-defined arguments and worker configuration.
    • New test helpers for isolated mocking of arguments and environment state.
  • Documentation

    • Updated guides to reflect separated Args (user options) and Env (runtime data) namespaces.

✏️ Tip: You can customize this high-level summary in your review settings.

ahogappa and others added 4 commits January 23, 2026 00:41
- Add args: and workers: parameters to Task.new for instance-based execution
- Add args parameter to TaskWrapper to store args for later use
- Make Taski.with_args private and use send for internal calls
- Add mock_args helper to TestHelper for testing args-dependent code
- Add tests for Task.new(args:).run pattern

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Separate system-managed execution environment information from user-defined
arguments:

- Add Taski::Env class to hold root_task, started_at, working_directory
- Add Taski.env, start_env, reset_env!, with_env methods
- Remove system attributes from Taski::Args (now holds only user options)
- Update call sites to use Taski.env for system info, Taski.args for user options
- Add mock_env helper in TestHelper for testing

This provides cleaner separation of concerns:
- Taski.args: User-defined options passed via run(args: {...})
- Taski.env: System-managed execution environment information

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update test_args.rb to use Taski.env for system attributes:
- working_directory, started_at, root_task now accessed via Taski.env
- Rename test methods to reflect env usage
- Update assertions to check both args and env are cleared after execution

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update documentation to reflect the separation of Args and Env:
- README.md: Document Taski.args for user options, Taski.env for system info
- examples/args_demo.rb: Update example to use Taski.env for system attributes
- examples/README.md: Update API reference

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 23, 2026

Walkthrough

This PR separates runtime environment metadata from user-defined arguments in Taski. It introduces a new Taski::Env class to hold execution context (root_task, started_at, working_directory), removes these fields from Taski::Args, updates the lifecycle APIs to handle both separately, and adjusts examples and tests accordingly.

Changes

Cohort / File(s) Summary
Documentation
README.md, examples/README.md
Updated references from Taski.args to Taski.env for runtime metadata (working_directory, started_at, root_task); clarified that Args holds user-defined options.
New Environment Class
lib/taski/env.rb
Introduced Taski::Env class with immutable attr_reader for root_task, started_at (captured at initialization), and working_directory (captured from Dir.pwd).
Core Lifecycle Management
lib/taski.rb
Added env management primitives (env, start_env, reset_env!, with_env); removed root_task parameter from start_args(options:) and with_args(options:); added env monitor for concurrent lifecycle coordination.
Arguments Refactor
lib/taski/args.rb
Removed attr_reader for started_at, working_directory, root_task; simplified initialize to accept only options parameter; updated documentation to reflect Args-only holds user options.
Task Execution Wiring
lib/taski/task.rb, lib/taski/execution/task_wrapper.rb
Updated Task.new to accept args and workers parameters; enhanced TaskWrapper.initialize to accept optional args; refactored with_args_lifecycle to respect pre-set Taski state and wrap with with_env/with_args as needed.
Test Utilities
lib/taski/test_helper.rb, lib/taski/test_helper/mock_registry.rb
Added mock_args(**options) and mock_env(root_task: nil) helpers for isolated testing; updated MockRegistry.reset! to clear both args and env state.
Test Suite Updates
test/test_args.rb, test/test_worker_count_configuration.rb
Replaced Taski.args.* references with Taski.env.* for environment metadata; expanded tests to cover Task.new(args:, workers:) pattern and new mock_args/mock_env helpers; adjusted teardown expectations.
Example Code
examples/args_demo.rb
Refactored to demonstrate both Args and Env APIs separately; changed Taski.args.* to Taski.env.* for working_directory, started_at, root_task; updated initialization and summary construction.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

Possibly related PRs

Poem

🐰 Env and Args, now apart they live,
User options here, system time there,
No more tangled threads to give,
Each lifecycle, precisely laid bare! 🌟

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 36.59% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely summarizes the main objective: separating Taski.env from Taski.args into distinct APIs for system metadata versus user options.

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

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@ahogappa ahogappa merged commit 9bf4dcb into master Jan 23, 2026
11 of 14 checks passed
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.

2 participants