project:
  name: novel
  root: .
  task_file: .nightshift/tasks.md
  artifact_dir: .nightshift

safety:
  require_clean_worktree: false
  scoped_paths:
    - story
    - README.md
    - STORY_FILES.md
    - pyproject.toml
  allowed_commands:
    - python -m pytest -q
  forbidden_commands:
    - rm -rf
    - git push
    - curl | bash

experiment:
  label: tutorial-novel-simple
  prompt_variant: scene-state-simple-v1

agents:
  drafter:
    backend: ollama
    model: nightshift-writer
    temperature: 0.7
    num_ctx: 16384
    num_predict: 8192
    system_prompt: .nightshift/agents/drafter.md

  state_updater:
    backend: ollama
    model: nightshift-writer
    temperature: 0.2
    num_ctx: 16384
    num_predict: 4096
    system_prompt: .nightshift/agents/state-updater.md

pipeline:
  max_task_retries: 3
  stop_on_repeated_failure_signature_after: 3
  continue_on_task_failure: false
  stages:
    - id: build_context
      type: repo_context
      output: context-pack.md

    - id: draft_scene
      type: file_writer
      agent: drafter
      output: scene-draft.patch
      allowed_paths:
        - story/chapters
      on_fail: draft_scene

    - id: normalize_patch
      type: patch_normalizer
      output: normalized-scene.patch

    - id: hard_validate_patch
      type: patch_validator
      output: scene-validation.md
      max_files: 1
      max_lines: 4000
      max_delete_ratio: 0.50
      allowed_paths:
        - story/chapters
      on_fail: draft_scene

    - id: apply_scene
      type: patch_apply
      mode: apply
      output: scene-apply-output.txt
      on_fail: draft_scene

    - id: update_state
      type: file_writer
      agent: state_updater
      output: state-update.patch
      allowed_paths:
        - story/plot-state.md
        - story/timeline.md
        - story/unresolved-threads.md
      on_fail: summarize_warnings

    - id: hard_validate_state
      type: patch_validator
      output: state-validation.md
      max_files: 3
      max_lines: 1200
      max_delete_ratio: 0.35
      allowed_paths:
        - story/plot-state.md
        - story/timeline.md
        - story/unresolved-threads.md
      on_fail: summarize_warnings

    - id: apply_state
      type: patch_apply
      mode: apply
      output: state-apply-output.txt
      on_fail: summarize_warnings

    - id: summarize_warnings
      type: summarize
      output: final-notes.md
