AI Agents SDE Task Viewer
      • Context
      • Plan
      • Prd
  1. Home
  2. AgentSDE
  3. agent-core
  4. gh-228
  5. plan
  6. context.json
context.json(4.6 KB)· Apr 1, 2026
{
  "meta": {
    "agent": "planner",
    "task_id": "228",
    "title": "Agent quality gate: run unit tests + check for conflicts before opening PRs",
    "created_at": "2026-04-01T22:45:00Z",
    "updated_at": "2026-04-01T23:30:00Z",
    "update_reason": "Revised to use husky pre-commit hooks instead of custom pre-pr-gate.sh script, per reviewer feedback"
  },
  "inputs": [
    {
      "name": "GitHub issue #228",
      "type": "context",
      "ref": "https://github.com/AgentSDE/agent-core/issues/228",
      "notes": "Pre-PR quality gate for agent-created PRs"
    },
    {
      "name": "deliver-implementation skill",
      "type": "file",
      "ref": ".claude/skills/deliver-implementation/SKILL.md",
      "notes": "Current PR creation flow with inline lint/test loop"
    },
    {
      "name": "create-pr.sh",
      "type": "file",
      "ref": "scripts/tools/create-pr.sh (in ai-agents-sde)",
      "notes": "PR creation wrapper script"
    },
    {
      "name": "directive.dto.ts",
      "type": "file",
      "ref": "src/directive/dto/directive.dto.ts",
      "notes": "ALLOWED_DIRECTIVES source of truth"
    },
    {
      "name": "directive.service.ts",
      "type": "file",
      "ref": "src/directive/directive.service.ts",
      "notes": "Directive handling logic"
    },
    {
      "name": "phase-router.service.ts",
      "type": "file",
      "ref": "src/phase-router/phase-router.service.ts",
      "notes": "Phase orchestration, gate map, Claude invocation env"
    }
  ],
  "outputs": [
    {
      "name": "plan.md",
      "type": "plan",
      "format": "md",
      "content": "Plan for pre-PR quality gate implementation using husky"
    }
  ],
  "files": [
    {
      "path": "package.json",
      "action": "modify",
      "reason": "Add husky as devDependency with prepare script to install hooks"
    },
    {
      "path": ".husky/pre-commit",
      "action": "create",
      "reason": "Husky pre-commit hook running npm run lint && npm run test before each commit"
    },
    {
      "path": "src/directive/dto/directive.dto.ts",
      "action": "modify",
      "reason": "Add skip-quality-gate to ALLOWED_DIRECTIVES"
    },
    {
      "path": "src/directive/directive.service.ts",
      "action": "modify",
      "reason": "Handle skip-quality-gate directive"
    },
    {
      "path": "src/phase-router/phase-router.service.ts",
      "action": "modify",
      "reason": "Add skip-quality-gate to VALID_DIRECTIVES, pass override env var"
    },
    {
      "path": "src/database/entities/task.entity.ts",
      "action": "modify",
      "reason": "Add qualityGateOverride boolean column"
    },
    {
      "path": "src/task-state/task-state.service.ts",
      "action": "modify",
      "reason": "Add quality gate override setter/getter"
    },
    {
      "path": "src/directive/directive.service.spec.ts",
      "action": "modify",
      "reason": "Test skip-quality-gate directive"
    },
    {
      "path": "src/phase-router/phase-router.service.spec.ts",
      "action": "modify",
      "reason": "Test override env passthrough"
    }
  ],
  "steps": [
    {
      "id": "S1",
      "summary": "Add skip-quality-gate directive and task entity column",
      "acceptance": [
        "skip-quality-gate is in ALLOWED_DIRECTIVES and VALID_DIRECTIVES",
        "TaskEntity has qualityGateOverride boolean column defaulting to false",
        "TaskStateService has setQualityGateOverride method",
        "DirectiveService handles skip-quality-gate by setting the flag and posting confirmation"
      ],
      "depends_on": []
    },
    {
      "id": "S2",
      "summary": "Install husky and create pre-commit hook",
      "acceptance": [
        "husky is added as a devDependency in package.json",
        "package.json has a prepare script that runs husky install",
        ".husky/pre-commit runs npm run lint && npm run test",
        "Hook blocks commits when lint or tests fail"
      ],
      "depends_on": []
    },
    {
      "id": "S3",
      "summary": "Wire override env var through phase-router invocation and write tests",
      "acceptance": [
        "PhaseRouterService passes QUALITY_GATE_OVERRIDE=1 env var when task has qualityGateOverride=true",
        "directive.service.spec.ts covers skip-quality-gate handling",
        "phase-router.service.spec.ts covers override env passthrough",
        "npm run test passes",
        "npm run lint passes"
      ],
      "depends_on": [
        "S1"
      ]
    }
  ],
  "risks": [
    {
      "risk": "Existing in-flight tasks lack qualityGateOverride column",
      "mitigation": "SQLite default value (false) handles existing rows without migration"
    }
  ],
  "assumptions": [
    "All agent-created PRs flow through the deliver-implementation skill — no other skill creates PRs directly",
    "husky is the idiomatic Node.js solution for git hooks and is preferred over custom shell scripts",
    "skip-quality-gate override is one-time per deliver phase (reset after use)"
  ],
  "open_questions": [
    "Should skip-quality-gate persist for the task lifetime or reset after deliver? Recommend reset after deliver."
  ]
}
Plan