Skip to content

code-yeongyu/oh-my-openagent / .agents/skills/senpi-qa

senpi-qa

Verified

QA the omo Senpi adapter (packages/omo-senpi, packages/senpi-task) against the REAL senpi binary in strict isolation, and write every artifact to the one canonical evidence path .omo/evidence/omo-senpi-adapter/<slug>/. The live drivers under packages/omo-senpi/scripts/qa/ create their own isolated SENPI_CODING_AGENT_DIR and ignore the caller's, so the real ~/.senpi/agent is never written. Ships scripts/resolve-evidence-dir.mjs, which is the ONLY sanctioned way to pick an evidence directory: it rejects traversal, separators, absolute paths, and stray roots such as local-ignore/qa-evidence. Use whenever someone changes anything under packages/omo-senpi or packages/senpi-task, or wants to QA, smoke-test, verify, or debug the Senpi adapter, the task/team engine, the DAG, task RPC, or skill delivery. Triggers: senpi qa, qa senpi, senpi-qa, test senpi adapter, verify senpi task, senpi task e2e, senpi team e2e, task dag qa, live senpi driver, senpi evidence path.

scripts/resolve-evidence-dir.test.mjs

View on GitHub
import { afterEach, describe, expect, test } from "bun:test"
import { spawnSync } from "node:child_process"
import { existsSync, mkdirSync, mkdtempSync, rmSync, symlinkSync } from "node:fs"
import { tmpdir } from "node:os"
import { join, relative } from "node:path"
import { fileURLToPath, pathToFileURL } from "node:url"

import { EVIDENCE_RELATIVE_ROOT, resolveEvidenceDir } from "./resolve-evidence-dir.mjs"

const cleanupRoots = []
const cliPath = fileURLToPath(new URL("./resolve-evidence-dir.mjs", import.meta.url))

afterEach(() => {
  for (const root of cleanupRoots.splice(0)) rmSync(root, { recursive: true, force: true })
})

function makeGitRoot() {
  const root = mkdtempSync(join(tmpdir(), "senpi-qa-evidence-"))
  cleanupRoots.push(root)
  mkdirSync(join(root, ".git"))
  return root
}

describe("resolveEvidenceDir", () => {
  test("#given a git worktree and a safe slug #when resolved #then it returns the canonical adapter evidence directory", () => {
    // given
    const repoRoot = makeGitRoot()

    // when
    const resolved = resolveEvidenceDir({ repoRoot, slug: "20260820-senpi-qa-contract" })

    // then
    expect(resolved).toBe(join(repoRoot, ".omo", "evidence", "omo-senpi-adapter", "20260820-senpi-qa-contract"))
  })

  test("#given a relative git worktree path #when resolved #then it still returns an absolute evidence directory", () => {
    // given
    const repoRoot = makeGitRoot()
    const relativeRoot = relative(process.cwd(), repoRoot)

    // when
    const resolved = resolveEvidenceDir({ repoRoot: relativeRoot, slug: "20260820-relative-root" })

    // then
    expect(resolved).toBe(join(repoRoot, ".omo", "evidence", "omo-senpi-adapter", "20260820-relative-root"))
  })

  test("#given a resolved evidence path #when the resolver returns #then it has created no directory", () => {
    // given
    const repoRoot = makeGitRoot()

    // when
    const resolved = resolveEvidenceDir({ repoRoot, slug: "20260820-senpi-qa-contract" })

    // then
    expect(existsSync(resolved)).toBe(false)
    expect(existsSync(join(repoRoot, ".omo"))).toBe(false)
  })

  test("#given the adapter evidence root #when it is the declared relative root #then it stays under .omo/evidence", () => {
    // given / when / then
    expect(EVIDENCE_RELATIVE_ROOT).toBe(join(".omo", "evidence", "omo-senpi-adapter"))
  })

  test("#given an unsafe slug #when resolved #then it is rejected before any path is produced", () => {
    // given
    const repoRoot = makeGitRoot()
    const unsafeSlugs = [
      "",
      "   ",
      ".",
      "..",
      "../escape",
      "nested/slug",
      "nested\\slug",
      "/absolute",
      join(repoRoot, "absolute"),
      "local-ignore/qa-evidence/20260819-senpi",
      "..%2Fescape",
      "-leading-hyphen",
      "trailing-hyphen-",
      "Upper-Case",
      "under_score",
    ]

    // when / then
    for (const slug of unsafeSlugs) {
      expect(() => resolveEvidenceDir({ repoRoot, slug }), `must reject ${JSON.stringify(slug)}`).toThrow()
    }
  })

  test("#given a directory that is not a git worktree #when resolved #then it is rejected", () => {
    // given
    const notARepo = mkdtempSync(join(tmpdir(), "senpi-qa-not-git-"))
    cleanupRoots.push(notARepo)

    // when / then
    expect(() => resolveEvidenceDir({ repoRoot: notARepo, slug: "20260820-senpi-qa-contract" })).toThrow(/git/i)
  })

  test("#given a rejected slug #when the error surfaces #then it names the offending slug for the operator", () => {
    // given
    const repoRoot = makeGitRoot()

    // when / then
    expect(() => resolveEvidenceDir({ repoRoot, slug: "local-ignore/qa-evidence/x" })).toThrow(
      /local-ignore\/qa-evidence\/x/,
    )
  })

  test("#given the documented Node CLI #when valid and invalid slugs run #then stdout and exit codes enforce the contract", () => {
    // given
    const repoRoot = makeGitRoot()

    // when
    const valid = spawnSync("node", [cliPath, "--repo-root", repoRoot, "--slug", "20260820-node-cli"], {
      encoding: "utf8",
    })
    const invalid = spawnSync("node", [cliPath, "--repo-root", repoRoot, "--slug", "local-ignore/qa-evidence/x"], {
      encoding: "utf8",
    })

    // then
    expect(valid.status).toBe(0)
    expect(valid.stdout.trim()).toBe(join(repoRoot, EVIDENCE_RELATIVE_ROOT, "20260820-node-cli"))
    expect(invalid.status).toBe(1)
    expect(invalid.stderr).toContain("local-ignore/qa-evidence/x")
  })

  test("#given a symlink to the documented Node CLI #when invoked #then the entrypoint still enforces the contract", () => {
    // given
    const repoRoot = makeGitRoot()
    const symlinkPath = join(repoRoot, "resolve-evidence-dir.mjs")
    symlinkSync(cliPath, symlinkPath)

    // when
    const result = spawnSync("node", [symlinkPath, "--repo-root", repoRoot, "--slug", "20260820-symlink-cli"], {
      encoding: "utf8",
    })

    // then
    expect(result.status).toBe(0)
    expect(result.stdout.trim()).toBe(join(repoRoot, EVIDENCE_RELATIVE_ROOT, "20260820-symlink-cli"))
  })

  test("#given an embedding runner with a missing argv path #when the module is imported #then exports still load", () => {
    // given
    const missingEntrypoint = join(tmpdir(), `missing-senpi-qa-entrypoint-${process.pid}.mjs`)
    const moduleUrl = pathToFileURL(cliPath).href

    // when
    const result = spawnSync(
      "node",
      [
        "--input-type=module",
        "--eval",
        `process.argv[1] = ${JSON.stringify(missingEntrypoint)}; await import(${JSON.stringify(moduleUrl)})`,
      ],
      { encoding: "utf8" },
    )

    // then
    expect(result.status).toBe(0)
    expect(result.stdout).toBe("")
    expect(result.stderr).toBe("")
  })
})
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 322kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 322kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 322kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 198kUpdated Claude CodeCodexVerifiedInstall