Appearance
Handoff: SVC-012-import-list-repository-pagination import-service repository pagination
Scope
- Service/area:
import-service - Task pack:
docs/agents/service-tasks/import-service.md - Goal: complete the bounded
SVC-012import list compatibility slice by moving teacher-library and SSE snapshot filtering/pagination/counting into the repository layer with organization scoping. - Non-goals: public
/api/exam-import*route promotion, PDF/OCR or MathType status/download/accounting parity, canonical question/exam storage ownership, real live/browser route proof, rollback-after-candidate proof, or changes to legacy source under/Users/velikho/Desktop/WORKING/HOCTAPAZ/.
Docs Read
go-platform/docs/architecture/service-responsibility-matrix.mdgo-platform/docs/architecture/legacy-api-map.mdgo-platform/docs/agents/service-agent-execution-queue.jsongo-platform/docs/agents/service-agent-closeout-ledger.jsongo-platform/docs/agents/service-tasks/import-service.mdgo-platform/docs/agents/service-tasks/import-pdf-ocr-boundary.mdgo-platform/docs/agents/service-tasks/import-mathtype-conversion-boundary.mdgo-platform/docs/agents/agent-handoff-format.mdgo-platform/docs/api/docx-import-service.mdgo-platform/docs/qa/import-route-rehearsals.mdgo-platform/docs/qa/service-agent-goal-completion-audit.mdgo-platform/docs/qa/service-agent-readiness-smoke.md
Legacy Evidence Read
/Users/velikho/Desktop/WORKING/HOCTAPAZ/node-platform/apps/api/src/modules/ai-import/**/Users/velikho/Desktop/WORKING/HOCTAPAZ/node-platform/apps/api/src/modules/exam-paper-templates/exam-paper-templates.controller.ts/Users/velikho/Desktop/WORKING/HOCTAPAZ/node-platform/apps/api/src/modules/app-data/app-data.import-jobs.ts/Users/velikho/Desktop/WORKING/HOCTAPAZ/node-platform/apps/api/src/modules/app-data/app-data.exam-import-*.ts/Users/velikho/Desktop/WORKING/HOCTAPAZ/node-platform/apps/api/src/modules/formula-recognition/**- Legacy source was read-only evidence only; no default route or legacy source change is claimed.
Files Changed
go-platform/services/docx-import-service/internal/domain/job.gogo-platform/services/docx-import-service/internal/repository/memory.gogo-platform/services/docx-import-service/internal/repository/postgres.gogo-platform/services/docx-import-service/internal/usecase/import_job.gogo-platform/services/docx-import-service/internal/http/server.gogo-platform/services/docx-import-service/internal/http/server_test.gogo-platform/contracts/openapi/services/docx-import-service.yamlgo-platform/services/docx-import-service/api/openapi.yamlgo-platform/docs/api/docx-import-service.mdgo-platform/docs/agents/service-tasks/import-service.mdgo-platform/docs/agents/handoffs/SVC-012-import-list-repository-pagination.mdgo-platform/docs/agents/service-agent-closeout-ledger.jsongo-platform/docs/agents/service-agent-closeout-ledger.md
Behavior Implemented
- Added
domain.ImportJobListQueryanddomain.ImportJobListResultfor repository-level list filtering. - Added
ListJobsPageto the import job repository contract and implemented it for memory and Postgres stores. - Repository list queries now scope rows by
X-Organization-Id, filter status/source/search/date windows before pagination, and compute accuratetotalbeforeLIMIT/OFFSET. GET /v1/import/docx/teacher-libraryand the SSE snapshot path now use repository-level pagination instead of capped global fetch plus in-memory post-filtering.- Missing organization context returns an empty compatibility snapshot rather than falling back to cross-organization rows.
- SSE live
job.updatedreplay now checks organization ownership before emitting updates.
Tests And Verification
- Command:
GOTOOLCHAIN=go1.25.11 go test ./services/docx-import-service/internal/http -run 'TestImportQASJobCompatibilityListUsesRepositoryPagination|TestImportQASJobCompatibilityStatusAndEvents|TestImportQASJobEventsStreamsLiveUpdates' -count=1 -v - Result: passed.
- Evidence: focused tests prove org isolation, repository total before pagination, status/source filters, empty snapshot without org, and org-scoped SSE updates.
- Command:
GOTOOLCHAIN=go1.25.11 go test ./services/docx-import-service/... -count=1 - Result: passed.
- Evidence: all docx-import-service packages passed after repository pagination and OpenAPI/docs updates.
- Command:
make test-import-status-routes test-import-approval-routes - Result: passed.
- Evidence: default import routes stayed legacy and non-default status/approval route examples remained valid.
- Command:
make test-import-review-roundtrip-routes - Result: passed.
- Evidence: non-default review/detail route table guard passed.
- Command:
IMPORT_REVIEW_ROUNDTRIP_SELF_TEST=1 make test-import-review-roundtrip-live - Result: passed.
- Evidence: live-smoke harness self-test passed; this is not real live gateway proof.
Route State
- Legacy route: default
/api/exam-importremains legacy-proxied indeploy/gateway/routes.json. - Native route: non-default import status, approval, and review roundtrip route examples remain rehearsal-only.
- Gateway state: route guards passed; no default route table was changed.
- Rollback: keep
deploy/gateway/routes.jsonas the active route table. Revert the repository pagination code path if org-scoped list regressions appear; do not promote import routes until real live/browser evidence and rollback proof are attached.
Data Notes
- Tables touched: none in this handoff run.
- Migration run: none.
- Validation report: not applicable because no live data was migrated or backfilled.
Risks / Blockers
- Real live gateway/browser roundtrip evidence is still missing; only route guards and a self-test harness passed here.
- PDF/OCR and MathType status/download/accounting parity remain future slices.
- Import-service still owns draft/preview/review state only; approved canonical questions and exams stay with question-bank-service and exam-service.
- Public route promotion remains blocked until route-specific live/browser and rollback evidence are attached.
Next Step
- Run a real non-default import review/browser roundtrip against a seeded native job with auth/org context, then attach the gateway request/response artifacts and rollback evidence before considering any default import route change.