3.6 KiB
3.6 KiB
id, title, status, wave, depends_on, plan, requirements, acceptance_criteria, system_design
| id | title | status | wave | depends_on | plan | requirements | acceptance_criteria | system_design | |||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 01-valid-pr-discovery | Restore valid PR discovery | done | 1 | plan.md |
|
|
|
Task 01: Restore valid PR discovery
Summary
Correct the shared GraphQL PR selection and prove discovery writes the expected association. Keep same-repository, fork, and missing-head identity behavior explicit.
In scope
- First add
TestPRDiscoveryQueryContractin the proposedgraphql_pr_discovery_contract_test.go. Validate the generated Repository selection against a checked field contract; run it red oncloneUrl. - Replace the selection with
url; map the decoded URL to the clone identity. Reuse shared conversion where applicable without conflating CLI JSON and GraphQL. - Add
TestPRDiscoveryHeadIdentityfor normal, fork, null, and missing head data. - Add
TestPRDiscoveryAssociationRecoveryusing the real service and store: rejected query creates no association; corrected successful query discovers one eligible PR, persists it once, and publishes the scoped task PR event. - Exercise both branch and known-PR batch builders. Keep definitive empty, ambiguity, tombstones, and fork-network call-count coverage green.
Out of scope
Retry policy, health projection, UI, credential selection, and live task repair.
Acceptance
- The contract regression fails on the current invalid selection and passes with supported fields; no live GitHub credential is required by tests.
- Head and target identities remain distinct and correct, including null data.
- Persistence and publication use existing writers and retain unlink protection.
Verification
Run from repository root. Record red output before implementation, then green results.
(cd apps/backend && go test ./internal/github -run 'TestPRDiscovery' -count=1)
(cd apps/backend && go test -race ./internal/github -count=1)
git diff --check
Files likely touched
apps/backend/internal/github/graphql.goapps/backend/internal/github/gh_client.go(shared repository decoding only)apps/backend/internal/github/graphql_pr_discovery_contract_test.go(new)apps/backend/internal/github/graphql_test.goapps/backend/internal/github/service_pr_watch_batched_budget_test.go
Dependencies
None.
Risks
Do not obtain a clone URL by using the PR target when the head is a fork. Validate the schema fixture against the upstream source linked in the design; do not merely snapshot today's production query.
Parallelism
sequential
Inputs
- Requirements, discovery criteria.
- Design, query validation and association.
apps/backend/internal/github/AGENTS.mdand existing GraphQL/service test patterns.
Results
- Replaced the invalid GraphQL
headRepository.cloneUrlselection with the supportedurlfield in both batched PR query builders. - Derived HTTPS clone identity from the GraphQL repository URL while keeping target and head repository identities distinct, including nullable head data.
- Added query-contract, identity, and query-recovery association/event tests.
- TDD verification passed:
go test ./internal/github -run 'TestPRDiscovery(HeadIdentity|QueryContract|AssociationAfterQueryRecovery)' -count=1.