Skip to content

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-012 import 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.md
  • go-platform/docs/architecture/legacy-api-map.md
  • go-platform/docs/agents/service-agent-execution-queue.json
  • go-platform/docs/agents/service-agent-closeout-ledger.json
  • go-platform/docs/agents/service-tasks/import-service.md
  • go-platform/docs/agents/service-tasks/import-pdf-ocr-boundary.md
  • go-platform/docs/agents/service-tasks/import-mathtype-conversion-boundary.md
  • go-platform/docs/agents/agent-handoff-format.md
  • go-platform/docs/api/docx-import-service.md
  • go-platform/docs/qa/import-route-rehearsals.md
  • go-platform/docs/qa/service-agent-goal-completion-audit.md
  • go-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.go
  • go-platform/services/docx-import-service/internal/repository/memory.go
  • go-platform/services/docx-import-service/internal/repository/postgres.go
  • go-platform/services/docx-import-service/internal/usecase/import_job.go
  • go-platform/services/docx-import-service/internal/http/server.go
  • go-platform/services/docx-import-service/internal/http/server_test.go
  • go-platform/contracts/openapi/services/docx-import-service.yaml
  • go-platform/services/docx-import-service/api/openapi.yaml
  • go-platform/docs/api/docx-import-service.md
  • go-platform/docs/agents/service-tasks/import-service.md
  • go-platform/docs/agents/handoffs/SVC-012-import-list-repository-pagination.md
  • go-platform/docs/agents/service-agent-closeout-ledger.json
  • go-platform/docs/agents/service-agent-closeout-ledger.md

Behavior Implemented

  • Added domain.ImportJobListQuery and domain.ImportJobListResult for repository-level list filtering.
  • Added ListJobsPage to 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 accurate total before LIMIT/OFFSET.
  • GET /v1/import/docx/teacher-library and 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.updated replay 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-import remains legacy-proxied in deploy/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.json as 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.

Go-platform documentation is generated from repository Markdown.