Files
honey-biscuit-workshop/workshop-engine/AGENTS.md
T
Catty Steve 26809df720 feat(bake): DAG scheduler, decorator execution, notify refactor, workshop-schedule crate
- Add workshop-schedule crate (petgraph-based DAG scheduling)
- Implement all bake decorators with combinator chain execution
- Refactor notify module: extract handler, rule, template, util, queue
- Add NotificationQueue with priority/drain semantics
- Enhance finalize plugin system with internal plugin registration
- Update ExecutionContext and event types
- Add per-crate AGENTS.md knowledge base files
- Remove inline AGENTS.md files (consolidated into per-crate docs)
2026-06-15 20:45:06 +08:00

3.5 KiB

WORKSHOP-ENGINE KNOWLEDGE BASE

OVERVIEW

Core execution layer for HoneyBiscuitWorkshop. Library-only crate (no binary). Provides Engine executor, process abstraction, package manager interfaces, duration parsing, and typed error/event systems. Used by workshop-baker; depends on no other workspace crates.

WHERE TO LOOK

Task File Notes
Script execution src/executor.rs Engine::execute_script() — spawn, stream, timeout, kill
Process abstraction src/child.rs ManagedChild trait; TokioChild (real), MockChild (hand-rolled, no mockall)
Configurable commands src/command.rs CustomCommand — name, command, env, working_dir, timeout
System PMs src/pm.rs + pm/{apt,pacman,dnf,apk}.rs PackageManager trait; all_managers(), select(name)
User PMs src/upm.rs + upm/{rust,go,python,custom}.rs UserPackageManager trait (async); UPMSysDeps
Repology endpoint src/repology.rs + repology/local.rs RepologyEndpoint enum; local instance support
Duration parsing src/time.rs parse_duration_to_ms(), serde helpers
Core types src/types.rs ExecutionContext, ExecutionResult, ExecutionEvent, EventSender, StreamType, Engine
Error types src/error.rs ExecutionError, DependencyError, HasExitCode trait, EXITCODE_* constants
Integration tests tests/engine_integration.rs 12 async tests; run with cargo test --test engine_integration

CONVENTIONS

  • Edition: Rust 2024
  • Key deps: tokio (full), thiserror, serde+serde_yaml, async-trait, chrono, os_info, duration-str, libc, lazy_static
  • Process mgmt: ManagedChild trait abstracts over real/mock children. TokioChild wraps tokio::process::Child. MockChild is hand-rolled (no mockall dep); supports hanging, custom output, exit codes.
  • Package manager selection: Use pm::select("apt") with explicit name — NEVER auto-detect by probing the filesystem.
  • Error mapping: HasExitCode trait maps errors to numeric exit codes. ExecutionError maps to specific EXITCODE_*; DependencyError always maps to 1.
  • Re-exports: lib.rs re-exports key types for convenience (Engine, ExecutionContext, PackageManager, ExecutionError, etc.)
  • Tests: Inline #[cfg(test)] blocks in pm.rs (8 tests). Integration tests in tests/engine_integration.rs (12 async tests, separate binary). CI runs both.
  • Kill semantics: TokioChild::kill() sends SIGKILL to entire process group via libc::kill(-PGID, SIGKILL) with ESRCH silently ignored.

ANTI-PATTERNS

  • Do NOT auto-detect the host package manager — always use pm::select() with an explicitly configured name. Production PM selection comes from environment config, not probing.
  • Do NOT use detect()/adopt() patterns for PM selection — these don't exist in this crate, and callers must not invent them.
  • Do NOT depend on workshop-baker or other workspace crates — engine is a leaf dependency. Types needed by external callers should flow through ExecutionContext, not reverse imports.
  • Do NOT use mockall or other mocking frameworksMockChild is the only mock mechanism. Keep it that way.
  • Do NOT use unimplemented!() — all package manager implementations are complete. Stubs belong in workshop-baker, not here.
  • Do NOT add magic platform detectionos_info is used only for mirror config mapping in PM impls. Do not extend its use to auto-detect behavior.