AI Agents SDE Task Viewer
      • Context
      • Plan
      • Prd
  1. Home
  2. AgentSDE
  3. agent-core
  4. gh-542
  5. plan
  6. context.json
context.json(4.9 KB)· Apr 23, 2026
{
  "meta": {
    "agent": "planner",
    "task_id": "542",
    "title": "BJ-2: BitbucketOAuthAuthProvider",
    "created_at": "2026-04-23T17:11:20Z"
  },
  "inputs": [
    {
      "name": "issue",
      "type": "link",
      "ref": "https://github.com/AgentSDE/agent-core/issues/542",
      "notes": "BJ-2 — concrete Bitbucket OAuth provider"
    },
    {
      "name": "epic",
      "type": "link",
      "ref": "https://github.com/AgentSDE/agent-core/issues/539",
      "notes": "Parent Atlassian integration EPIC (Wave 1)"
    },
    {
      "name": "github-module-reference",
      "type": "file",
      "ref": "src/github/github.module.ts:14",
      "notes": "Factory pattern to mirror for PLATFORM_AUTH_PROVIDER wiring"
    },
    {
      "name": "auth-provider-contract",
      "type": "file",
      "ref": "src/platform/platform-auth-provider.interface.ts",
      "notes": "Contract (platform, getToken, getBotUsername) the new provider must satisfy via base class"
    }
  ],
  "outputs": [
    {
      "name": "BitbucketOAuthAuthProvider",
      "type": "spec",
      "format": "text",
      "content": "class extending AtlassianOAuthAuthProvider; platform='bitbucket'; token endpoint https://bitbucket.org/site/oauth2/access_token; getBotUsername() returns BITBUCKET_BOT_USERNAME"
    },
    {
      "name": "BitbucketModule",
      "type": "spec",
      "format": "text",
      "content": "NestJS module exporting PLATFORM_AUTH_PROVIDER via factory gated on BITBUCKET_OAUTH_CLIENT_ID"
    }
  ],
  "files": [
    {
      "path": "src/atlassian/bitbucket-oauth-auth.provider.ts",
      "action": "create",
      "reason": "concrete Bitbucket OAuth provider extending the Atlassian base"
    },
    {
      "path": "src/atlassian/bitbucket-oauth-auth.provider.spec.ts",
      "action": "create",
      "reason": "unit tests for platform id, bot username, conditional factory registration"
    },
    {
      "path": "src/bitbucket/bitbucket.module.ts",
      "action": "create",
      "reason": "new module that registers the provider under PLATFORM_AUTH_PROVIDER"
    },
    {
      "path": "src/app.module.ts",
      "action": "modify",
      "reason": "import BitbucketModule alongside GitHubModule"
    },
    {
      "path": "src/atlassian/atlassian-oauth-auth.provider.ts",
      "action": "inspect",
      "reason": "base class from BJ-1; must be merged before this task can build"
    }
  ],
  "steps": [
    {
      "id": "S1",
      "summary": "Create BitbucketOAuthAuthProvider extending AtlassianOAuthAuthProvider with bitbucket-specific overrides",
      "acceptance": [
        "File src/atlassian/bitbucket-oauth-auth.provider.ts exists and compiles",
        "readonly platform === 'bitbucket'",
        "Token endpoint string equals 'https://bitbucket.org/site/oauth2/access_token'",
        "getBotUsername() returns BITBUCKET_BOT_USERNAME from ConfigService",
        "getBotUsername() throws a typed error when BITBUCKET_BOT_USERNAME is unset"
      ],
      "depends_on": []
    },
    {
      "id": "S2",
      "summary": "Create BitbucketModule with factory registration of PLATFORM_AUTH_PROVIDER gated on BITBUCKET_OAUTH_CLIENT_ID, and register it in app.module.ts",
      "acceptance": [
        "src/bitbucket/bitbucket.module.ts exists with factory provider mirroring src/github/github.module.ts",
        "Factory returns BitbucketOAuthAuthProvider only when BITBUCKET_OAUTH_CLIENT_ID is set",
        "Module boots cleanly when BITBUCKET_OAUTH_CLIENT_ID is absent",
        "BitbucketModule is imported in src/app.module.ts"
      ],
      "depends_on": [
        "S1"
      ]
    },
    {
      "id": "S3",
      "summary": "Add unit tests for the new provider and factory wiring",
      "acceptance": [
        "src/atlassian/bitbucket-oauth-auth.provider.spec.ts exists",
        "Spec asserts platform id, token endpoint, getBotUsername success and throw paths",
        "Factory wiring test covers both configured and unconfigured BITBUCKET_OAUTH_CLIENT_ID",
        "npm run test passes with zero failures",
        "npm run lint passes with zero warnings"
      ],
      "depends_on": [
        "S2"
      ]
    }
  ],
  "risks": [
    {
      "risk": "Depends on #540 (BJ-0 platform unions) and #541 (BJ-1 Atlassian base class) which are still OPEN",
      "mitigation": "Block implementation until both deps land on rc/atlassian-integration; detect missing base class at import time and signal BLOCKED"
    },
    {
      "risk": "BITBUCKET_* env vars not yet in Joi schema (BJ-4)",
      "mitigation": "Use config.get() with typed fallbacks; defer schema validation to BJ-4; flag in review"
    }
  ],
  "assumptions": [
    "AtlassianOAuthAuthProvider (BJ-1) implements the OAuth refresh flow and PlatformAuthProvider.getToken() so this subclass is thin (overrides platform, endpoint, getBotUsername only)",
    "BitbucketModule does not yet exist — this task creates it; scope says 'updated' but repo has no src/bitbucket/ directory",
    "Branch target is rc/atlassian-integration (already checked out)",
    "BITBUCKET_BOT_USERNAME missing → typed exception, not silent fallback"
  ],
  "open_questions": [
    "Does BJ-1 expose the token endpoint as a protected property/method override, or does the subclass need to reimplement refresh logic entirely?"
  ]
}
Plan