# specproof.config.yaml
# ---------------------------------------------------------------------------
# Per-repo configuration for specproof (playwright adapter).
# Drop this file at your REPOSITORY ROOT (the directory that contains your
# e2e package / monorepo packages).  specproof reads it at runtime by walking
# up from process.cwd().
#
# Labels: [required] must be set  /  [optional] safe to omit or leave blank
# Full schema reference: docs/config-schema.md
# ---------------------------------------------------------------------------

# [required] Adapter type. Tells specproof which framework-specific logic to
# activate. Supported values: playwright | flutter
adapter: playwright

# [required] BDD framework identifier (used in logs and generated comments).
bddRunner: playwright-bdd

# [required] Glue-code generation tool name (used in error messages).
bddGenTool: bddgen

# [required] Gherkin locale (Cucumber i18n code).
# Must match the "# language: <code>" header in your .feature files.
# Common values: "en" (English), "ja" (Japanese)
language: en

# ---------------------------------------------------------------------------
# commands: shell commands specproof invokes (run from the repo root)
# ---------------------------------------------------------------------------
commands:
  # `specproof init` scaffolds the e2e package into its own directory
  # (layout.e2eRoot; the repo root has no workspaces wiring), so every command
  # must `cd` into it explicitly rather than relying on `npm run` resolving
  # scripts from the repo root.
  generate: "cd packages/e2e && npm run bddgen" # [required] generate glue code from .feature files
  typecheck: "cd packages/e2e && npm run typecheck" # [required] TypeScript type check
  lint: "cd packages/e2e && npm run lint" # [required] lint + format
  # [optional] product-code checks run by specproof-implement. typecheck / lint above
  # check the e2e package only; when these are unset, the skill reports the product
  # side as "not verified" instead of guessing a command.
  # productTypecheck: "npm run typecheck"
  # productLint: "npm run lint"
  smoke: "cd packages/e2e && npm run test:smoke" # [required] fast subset — excludes @slow, used in CI
  # [optional] traceability engine (framework-agnostic Node CLI): check / update /
  # list / stats. Works for any repo because it hashes file/section text. After
  # installing @pound79/specproof-traceability you can drop `-y -p` and call the
  # bin directly (e.g. `npx specproof-check`).
  traceabilityCheck: "npx -y -p @pound79/specproof-traceability@0.9.0 specproof-check"
  traceabilityUpdate: "npx -y -p @pound79/specproof-traceability@0.9.0 specproof-update"
  traceabilityList: "npx -y -p @pound79/specproof-traceability@0.9.0 specproof-list"
  traceabilityStats: "npx -y -p @pound79/specproof-traceability@0.9.0 specproof-stats"
  install: cd packages/e2e && npm install

# ---------------------------------------------------------------------------
# layout: file/directory locations (relative to repo root)
# ---------------------------------------------------------------------------
layout:
  e2eRoot: "packages/e2e" # [required] root of the e2e package
  featuresDir: "packages/e2e/features" # [required] .feature files directory
  stepsDir: "packages/e2e/steps" # [required] step definitions directory
  stepFileSuffix: ".steps.ts" # [optional] naming convention for step files
  stepFileExt: ".ts" # [required] step file language extension
  pagesDir: "packages/e2e/src/pages" # [required] Page Object Model directory
  # [optional] specproof-list candidate-detection suffix. The engine
  # default ("Page.tsx", a React-app convention) does NOT match this scaffold's
  # own Page Objects (LoginPage.ts, ExamplePage.ts — plain .ts), so set it
  # explicitly to keep untracked-page detection working. Follow this suffix
  # when naming new page objects; see docs/config-schema.md.
  candidateSuffix: "Page.ts"
  textConstants: "packages/e2e/src/config/text.ts" # [required] UI string constants file
  manifest: "packages/e2e/traceability.yaml" # [required] traceability manifest path
  specDir: "docs" # [required] design rationale docs root
  implGlobs:
    # [optional] implementation files tracked by traceability
    # TODO: replace these globs with paths that match your application's source
    # Also used by `specproof-check` to flag implementation files with no
    # linked spec/feature ("unregistered-impl"). Advisory by default (does
    # not fail CI); set strictUnregisteredImpl: true (top-level) to harden it.
    - "src/**/*.ts"
    - "src/**/*.tsx"
  # [optional] files under implGlobs to leave out of "unregistered-impl" (tests and mocks
  # by default; add generated files your app keeps under implGlobs)
  implExcludeGlobs:
    - "**/__tests__/**"
    - "**/__mocks__/**"
    - "**/*.test.*"
    - "**/*.spec.*"
  # [optional] spec files ("<path>") or headings ("<path>#<heading>") to leave out of
  # "unregistered-spec-heading" (role lists, glossaries, revision history)
  # specHeadingIgnore:
  #   - "docs/glossary.md"
  scratchDir: ".specproof/drafts" # [optional] temporary output for bootstrap drafts
  e2eReadme: "packages/e2e/README.md" # [optional] E2E package README; specproof-* skills link here
  i18nSource: packages/e2e/src/config/text.ts
  testRunnerConfig: packages/e2e/playwright.config.ts
  idiomGuide: packages/e2e/README.md

# ---------------------------------------------------------------------------
# fixtures: page-object fixture name -> source file (used by code-generation)
# ---------------------------------------------------------------------------
fixtures:
  loginPage: "packages/e2e/src/pages/LoginPage.ts"
  examplePage: "packages/e2e/src/pages/ExamplePage.ts"
  # TODO: add additional page object fixtures here as your app grows

# ---------------------------------------------------------------------------
# tags: canonical Gherkin tag definitions
# ---------------------------------------------------------------------------
tags:
  slow: "@slow" # [required] slow scenarios (e.g. real network calls); excluded from smoke
  generate: "@generate" # [required] heavy generation flows; always pair with @slow
  admin: "@admin" # [required] admin-role scenarios (authed-admin project)
  user: "@user" # [required] regular-user-role scenarios
  # State tags are fixed and not configurable: @draft (not decided yet),
  # @red-contract (not implemented yet; runs and stays red), @human (checked by
  # a person) and @out-of-scope (excluded; needs a reason comment). The runner
  # never executes @draft / @human / @out-of-scope. Tags that switch scenarios
  # off (@skip / @fixme / @fail) cannot be used.

# ---------------------------------------------------------------------------
# projects: runner profiles (one per auth state)
# Playwright runner maps each entry to a defineBddProject() call.
# ---------------------------------------------------------------------------
projects:
  - name: "authed"
    # Runs all scenarios NOT tagged @admin
    tags: "not @admin"
    # storageState path written by the auth setup; relative to the e2e package root
    storageState: "playwright/.auth/user.json"
    # When true, the "setup" project runs auth.setup.ts before this project
    setup: true
    # ENV VAR NAMES (not values) used to read credentials at runtime
    credentialsEnv:
      username: "E2E_USERNAME"
      password: "E2E_PASSWORD"
      newPassword: "E2E_NEW_PASSWORD" # optional — only needed for first-login flows
    features:
      - "features/example.feature"
      # TODO: add your .feature files here

  - name: "authed-admin"
    tags: "@admin"
    # Skip this project entirely when E2E_ADMIN_USERNAME is not set
    conditional: "env.adminUsername"
    storageState: "playwright/.auth/admin.json"
    setup: true
    credentialsEnv:
      username: "E2E_ADMIN_USERNAME"
      password: "E2E_ADMIN_PASSWORD"
      newPassword: "E2E_ADMIN_NEW_PASSWORD"
    features:
      - "features/example.feature"
      # TODO: add your .feature files here

  - name: "guest"
    # Unauthenticated — tests the login/auth flow itself
    # 認証ロール付きのシナリオは、同じ feature 内にあっても guest で実行しない。
    tags: "not @admin and not @user"
    storageState: "" # empty string = no stored auth state (clean browser context)
    setup: false
    features:
      - "features/example.feature"
      # TODO: add auth/login .feature files here

# ---------------------------------------------------------------------------
# env: logical names of environment variables (not their values)
# The runner reads process.env[<value>] at runtime.
# ---------------------------------------------------------------------------
env:
  baseUrl: "E2E_BASE_URL" # [required] application URL
  username: "E2E_USERNAME" # [optional] regular user — used for conditional checks
  adminUsername: "E2E_ADMIN_USERNAME" # [optional] admin user — controls authed-admin project

# ---------------------------------------------------------------------------
# agents: review agents specproof-implement invokes (anti-gaming layer 2). [optional]
# STRONGLY RECOMMENDED: uncomment the block below if your agent environment
# has review subagents (Claude Code ships code-reviewer / security-reviewer
# usable as-is). When omitted, specproof-implement falls back to reviewing its
# own diff inline — the layer is never skipped, but a self-review by the same
# context that wrote the code is strictly weaker than an independent
# adversarial review, and the handoff report will flag it as such.
# ---------------------------------------------------------------------------
# agents:
#   codeReviewer: code-reviewer
#   securityReviewer: security-reviewer

# ---------------------------------------------------------------------------
# implement: specproof-implement edit scope. [optional]
# blastRadiusGlobs limits which files specproof-implement may touch. If omitted, it
# defaults conservatively to the target domain's files under layout.implGlobs.
# ---------------------------------------------------------------------------
# productChanges: where specproof-implement puts product-code changes.
#   sameBranch (default) = the same branch as the E2E changes.
#   separateBranch = the E2E branch is not merged; product changes go on their own
#   branch cut from the product's default branch (see specproof-implement).
# implement:
#   blastRadiusGlobs:
#     - "src/pages/**"
#     - "src/components/**"
#   productChanges: sameBranch

# ---------------------------------------------------------------------------
# runner: Playwright-specific runner options
# ---------------------------------------------------------------------------
runner:
  # Playwright device descriptor (see https://playwright.dev/docs/emulation)
  device: "Desktop Chrome"

# ---------------------------------------------------------------------------
# environments: execution environment profiles (required — at least 1 entry)
#
# Each entry defines auth provider, dotenv file, and excluded tags for an
# execution environment. Set SPECPROOF_ENV=<name> to select the active profile
# (see docs/config-schema.md).
# When unset, the entry with `default: true` is used.
#
# Auth provider (auth.provider / auth.description) is defined here only —
# there is no top-level `auth` block.
#
# allowInsecureHttp (optional, default false): when a project below uses
# credentials or a saved session, the run refuses an http:// base URL whose
# host is not localhost, *.localhost, 127.0.0.0/8 or ::1. Set
# `allowInsecureHttp: true` on an entry only for an environment that really
# has no https (it then accepts any http host); prefer https:// elsewhere.
#
# See docs/config-schema.md "environments" for the full field reference.
# ---------------------------------------------------------------------------
environments:
  - name: local
    default: true
    # TODO: replace this auth with the scheme your app uses for local
    # development (mock, email-password, google, saml, ...).
    auth:
      provider: email-password
      description: Example username/password login; replace with the application authentication scheme.

  # TODO: uncomment and configure additional environments as needed
  # - name: dev
  #   dotenvFile: ".env.dev"
  #   auth:
  #     provider: google
  #     description: "Firebase Auth (Google) — dev project."
  #   excludeTags: []
  #   # Only when this environment has no https (see allowInsecureHttp above):
  #   # allowInsecureHttp: true

strictUnregisteredImpl: false
strictUnregisteredSpecHeadings: false
# [optional] true makes --strict fail on the feature lint warnings
# (missing-then / step-order / duplicate-scenario-name / duplicate-scenario).
strictFeatureLint: false
conventions:
  agentsDoc: AGENTS.md
  i18nLintPlugin: none
  stepFrameworkPattern: "createBdd(test): Given/When/Then"
  pendingStubBody: throw new Error("Pending implementation");
examples:
  domainName: example
  specDoc: docs/example.md
  internalConstants:
    - retry limit
    - timeout policy
git:
  commitScope: bdd
  branchPrefix: bdd/
