You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi @EricNGOntos, I'd like to take this on if it's still open.
Reading the current state: packages/shared-python/shared/services/storage/zip_package_writer.py writes chunks.json, doc_nav.json, and manifest.json directly from dict payloads, and apps/worker/app/services/document_ingestion/success_finalization.py:finalize_parse_success is the natural pre-completion hook but doesn't validate output shape today. The existing contract test (apps/worker/tests/contract/test_parse_task_contract.py) covers end-to-end behaviour but only asserts presence of fields like result_s3_key and chunk counts, not the inner shape of the three JSON artifacts.
Concrete shape I'd build:
Pydantic V2 models (in packages/shared-python/shared/contracts/parse_result/) for Manifest, ChunkRecord, and DocNav capturing the current shape produced by the worker. Each model carries a schema_version field starting at 1 so future shape changes are versioned, not silent.
A single validate_parse_result(manifest, chunks, doc_nav) helper called from finalize_parse_success before the job is marked done. Validation failure fails the job with a structured error that names the violated field and the schema version, so SDK maintainers immediately see a contract break instead of a malformed ZIP reaching consumers.
SDK-discoverable schema: dump the Pydantic models to JSON Schema under packages/shared-python/shared/contracts/parse_result/schemas/ so the Node + Python SDKs can vendor or reference them, and add a make sync-contracts target (or equivalent) that regenerates the schema files from the models so they cannot drift.
Unit tests for each model covering the happy path plus one violation per required field. Extend the existing parse-task contract test with one assertion that the validator is called and rejects a deliberately-malformed payload.
Scope questions before I start:
Schema location: would you prefer packages/shared-python/shared/contracts/ as proposed, or a separate top-level packages/contracts/ so the Node SDK can pin to it without depending on the Python shared package?
Contract violation on the worker side: fail the job hard (status=failed), or finalize with the partial result and surface the violation through a non-fatal warning channel? My read of the issue ("detect the break before it reaches consumers") is hard-fail, but I want to confirm before locking in.
Versioning policy: when a field is added in a backwards-compatible way, do we bump schema_version minor, or only on breaking changes? A short note in the repo will make this explicit for future contributors.
If you'd rather scope this differently or split it across PRs, I can adjust. Otherwise, please confirm and I'll open a draft.
Draft RFC for this issue (no implementation): #420
It answers the three scope questions from 2026-06-12 against current main (9489fa2c):
Schema location: Pydantic models in packages/shared-python/shared/contracts/parse_result/ as source of truth; generated JSON Schema in language-neutral packages/contracts/parse_result/ for Node/Python SDK vendoring; make sync-contracts + CI drift check.
Violation: hard-fail the job (status=failed), do not upload the ZIP. Validate in ZipResultService.generate_zip_package after payloads exist and before ZipPackageWriter.write.
Versioning: integer schema_version starting at 1, independent of existing manifest.version / doc_nav.version strings. Additive optional fields do not bump; breaking changes bump. One ZIP, one version.
Also asks whether doc_nav.json is required on every successful job (today it can be omitted after a warning).
Please confirm or redirect on those points before any models/validator PR.
Activity
[-]Parsed result ZIP contract: sync mechanism for API → SDKs → dependent services[/-][+]Parsed result contract[/+]nuemaan commentedon Jun 12, 2026
Hi @EricNGOntos, I'd like to take this on if it's still open.
Reading the current state:
packages/shared-python/shared/services/storage/zip_package_writer.pywriteschunks.json,doc_nav.json, andmanifest.jsondirectly from dict payloads, andapps/worker/app/services/document_ingestion/success_finalization.py:finalize_parse_successis the natural pre-completion hook but doesn't validate output shape today. The existing contract test (apps/worker/tests/contract/test_parse_task_contract.py) covers end-to-end behaviour but only asserts presence of fields likeresult_s3_keyand chunk counts, not the inner shape of the three JSON artifacts.Concrete shape I'd build:
packages/shared-python/shared/contracts/parse_result/) forManifest,ChunkRecord, andDocNavcapturing the current shape produced by the worker. Each model carries aschema_versionfield starting at1so future shape changes are versioned, not silent.validate_parse_result(manifest, chunks, doc_nav)helper called fromfinalize_parse_successbefore the job is markeddone. Validation failure fails the job with a structured error that names the violated field and the schema version, so SDK maintainers immediately see a contract break instead of a malformed ZIP reaching consumers.packages/shared-python/shared/contracts/parse_result/schemas/so the Node + Python SDKs can vendor or reference them, and add amake sync-contractstarget (or equivalent) that regenerates the schema files from the models so they cannot drift.Scope questions before I start:
packages/shared-python/shared/contracts/as proposed, or a separate top-levelpackages/contracts/so the Node SDK can pin to it without depending on the Python shared package?status=failed), or finalize with the partial result and surface the violation through a non-fatal warning channel? My read of the issue ("detect the break before it reaches consumers") is hard-fail, but I want to confirm before locking in.schema_versionminor, or only on breaking changes? A short note in the repo will make this explicit for future contributors.If you'd rather scope this differently or split it across PRs, I can adjust. Otherwise, please confirm and I'll open a draft.
Frankie-Xu commentedon Sep 14, 2026
@suguanYang @EricNGOntos @nuemaan
Draft RFC for this issue (no implementation): #420
It answers the three scope questions from 2026-06-12 against current
main(9489fa2c):packages/shared-python/shared/contracts/parse_result/as source of truth; generated JSON Schema in language-neutralpackages/contracts/parse_result/for Node/Python SDK vendoring;make sync-contracts+ CI drift check.status=failed), do not upload the ZIP. Validate inZipResultService.generate_zip_packageafter payloads exist and beforeZipPackageWriter.write.schema_versionstarting at1, independent of existingmanifest.version/doc_nav.versionstrings. Additive optional fields do not bump; breaking changes bump. One ZIP, one version.Also asks whether
doc_nav.jsonis required on every successful job (today it can be omitted after a warning).Please confirm or redirect on those points before any models/validator PR.