version: '3'

vars:
  DEFT_ROOT: '{{joinPath .TASKFILE_DIR ".."}}'

# Capacity allocation accounting surface (#1419 Delivery Slice 4).
#
# `task capacity:show` derives per-bucket target-vs-actual mix from the vBRIEF
# lifecycle folders (filesystem-truth, offline) with outcome (rework) and cost
# overlays, and renders advisory mode when classified completions are below
# minSampleSize. It is a DISPLAY surface and always exits 0 on a valid project
# root (the companion `task verify:capacity` in tasks/verify.yml is the
# three-state advisory gate).
#
# Conventions (mirroring tasks/scope.yml / tasks/verify.yml):
#  * `dir: '{{.USER_WORKING_DIR}}'` so the script's CWD is the consumer project
#    root, not deft/.
#  * `DEFT_ROOT` defined locally via joinPath so the script path resolves on
#    Windows (#566).
#  * `{{.CLI_ARGS}}` forwarded bare (no double quotes, #577) and NO `sources:` /
#    `generates:` so go-task does not swallow flags (#574 / conventions/
#    task-caching.md).
tasks:
  show:
    desc: "Capacity allocation target-vs-actual mix (advisory, offline). task capacity:show [-- --project-root <path>]"
    dir: '{{.USER_WORKING_DIR}}'
    deps:
      - task: :engine:_ts-build
    cmds:
      - task: :engine:invoke
        vars:
          ENGINE_CMD: 'capacity-show --project-root "{{.USER_WORKING_DIR}}" {{.CLI_ARGS}}'

  backfill:
    desc: "One-time capacity-bucket backfill for completed vBRIEFs (#1606): infer capacityBucket from origin-issue labels + stamp completedAt from git. Dry-run by default; idempotent; never touches cost. -- task capacity:backfill [-- --apply] [--window-only] [--cache-dir <path>] [--json]"
    dir: '{{.USER_WORKING_DIR}}'
    deps:
      - task: :engine:_ts-build
    cmds:
      - task: :engine:invoke
        vars:
          ENGINE_CMD: 'capacity-backfill --project-root "{{.USER_WORKING_DIR}}" {{.CLI_ARGS}}'
