Appearance
Handoff: SVC-013-formula-adapter-determinism-proof formula-docx-service adapter determinism proof
Scope
- Service/area:
formula-docx-service - Task ID:
SVC-013-formula-adapter-determinism-proof - Dispatch ID:
SVC-013 - Task pack:
docs/agents/service-tasks/formula-docx-service.md - Accepted first-slice handoff:
docs/agents/handoffs/SVC-013-formula-runtime-boundary-audit.md - Goal: prove parser/runtime determinism stays behind the external Go Formula adapter without creating a deployable
services/formula-docx-service. - Non-goals: editing legacy source, creating a new Go-platform service directory, public route promotion, default gateway route changes, or claiming formula-docx service completion.
Docs Read
docs/architecture/service-responsibility-matrix.mddocs/agents/service-agent-next-slice-queue.jsondocs/agents/service-agent-next-slice-closeout-ledger.jsondocs/agents/service-agent-next-slice-spawn-packets.mddocs/agents/service-agent-closeout-ledger.jsondocs/agents/service-agent-accepted-handoffs.mddocs/agents/agent-handoff-format.mddocs/agents/handoffs/SVC-013-formula-runtime-boundary-audit.mddocs/agents/handoff-phase-4-go-formula-docx-runtime.mddocs/agents/handoff-phase-5-docx-parser-benchmark.mddocs/agents/service-tasks/formula-docx-service.mddocs/agents/service-tasks/import-mathtype-conversion-boundary.md
Legacy Evidence Read
runtimes/go-formula-docx/**/Users/velikho/Desktop/WORKING/HOCTAPAZ/node-platform/apps/api/src/modules/formula-recognition/**/Users/velikho/Desktop/WORKING/HOCTAPAZ/node-platform/apps/api/src/modules/exam-paper-templates/**- Legacy source and the external Go Formula runtime were read-only evidence only. No files under
/Users/velikho/Desktop/WORKING/HOCTAPAZ/were changed.
Files Changed
services/docx-import-service/internal/parser/docx/go_formula.goservices/docx-import-service/internal/parser/docx/go_formula_test.godocs/api/docx-import-service.mddocs/agents/handoffs/SVC-013-formula-adapter-determinism-proof.mddocs/agents/service-agent-next-slice-closeout-ledger.jsondocs/agents/service-agent-next-slice-closeout-ledger.mddocs/agents/service-agent-accepted-handoffs.mddocs/qa/service-agent-goal-completion-audit.mddocs/qa/service-agent-readiness-smoke.mdscripts/test/service-agent-next-slice-closeout-coverage.shservices/docx-import-service/internal/parser/docx/go_formula_corpus_integration_test.goscripts/test/docx-formula-determinism-runtime.mjsMakefiledocs/qa/docx-formula-determinism-runtime-proof.mddocs/.vitepress/config.tsdocs/agents/service-workflow-test-matrix.md
Behavior Implemented
- The adapter now prevents an unbounded Go Formula request when a caller injects an
http.ClientwithTimeout == 0: it copies that client and uses the configuredGO_FORMULA_DOCX_TIMEOUT_MSvalue or the 180-second default. A caller-supplied positive timeout and all transport settings remain intact. - Verified the external adapter path exists:
runtimes/go-formula-docx. - Verified
services/formula-docx-servicedoes not exist, preserving the runtime-adapter boundary. - Verified the adapter/runtime wiring guard still treats Go Formula as internal runtime evidence behind
docx-import-service, not a deployable service row. - Verified parser package determinism through the current docx parser test suite.
- Added a QAS adapter regression that varies only parser latency over 24 runs and requires byte-identical import-visible JSON after
latency_msis removed. It covers question IDs/types/options/answers, media, MathType provenance, formulas, warnings, and aggregate stats without modifying the external runtime. - Added a bounded request invariant:
GO_FORMULA_DOCX_TIMEOUT_MSdefaults to 180 seconds even when a caller injects anhttp.ClientwithTimeout == 0. The adapter clones that client instead of mutating it, preserving any custom transport while preventing a stalled parser request from waiting indefinitely. - Added a read-only two-call corpus proof for Math and Physics. The JavaScript artifact hashes versioned, import-visible QAS content without latency, while
TestGoFormulaCorpusImportVisibleDeterminismexecutes the actual Go adapter and requires byte-identical JSON after clearinglatency_ms. - The proof deliberately filters raw OLE/WMF non-display diagnostics in the same way as
mapGoFormulaQASImages; these assets cannot become persisted browser media. Formula LaTeX/MathML/MTEF provenance remains in the compared payload.
Required evidence covered:
- external adapter evidence
- parser/runtime determinism proof
- no services/formula-docx-service directory
Tests And Verification
Command:
sh scripts/test/go-formula-runtime-coverage.shResult: passed.
Output:
ok go-formula runtime coverage: compose=/tmp/hoctapaz-go-compose-rendered.yaml helm=/tmp/hoctapaz-go-formula-helm-rendered.yamlEvidence: runtime coverage keeps
go-formula-docxin Compose/Helm internal runtime wiring and outside canonical deployable service rows.Command:
GOTOOLCHAIN=go1.25.11 go test ./services/docx-import-service/internal/parser/docx -count=1Result: passed.
Output:
ok github.com/hongochai10/hoctapaz/go-platform/services/docx-import-service/internal/parser/docx 0.490sEvidence: adapter-facing DOCX parser package tests passed.
Determinism regression:
TestMapGoFormulaQASResultIsDeterministicApartFromLatencymaps the same versioned QAS payload 24 times.latency_msmay differ, but all import-visible JSON used by review/approval must remain byte-identical.Timeout regressions:
TestNewParserFromEnvproves an injected timeout-free client receives the configured 250 ms request deadline without mutation, and a directly constructed adapter falls back to the 180-second default.Command:
GOTOOLCHAIN=go1.25.11 go test ./services/docx-import-service/... -count=1Result: passed.
Output: all current
docx-import-servicepackages passed; packages without tests reported[no test files].Evidence: broader import-service adapter boundary still passes.
Command:
DOCX_FORMULA_DETERMINISM_CONFIRM=read-only-formula-runtime GO_FORMULA_DOCX_URL=http://127.0.0.1:8080 HOCTAPAZ_DOCX_CORPUS_DIR=/Users/velikho/Desktop/test-hoctapaz make test-docx-formula-determinismResult: passed.
Output: Math fingerprint
cae23f6583080f5c6e1f41abf2664fbf1690dcc4b2d7c8ca45ceae5e6d6c91d7for 22 questions and 125 formulas; Physics fingerprint11b1bd26d1a8ee2d5501f95c66a4e3a7670778e4ef8a9e5e4440c1467282f892for 28 questions and 84 formulas. The integration test passed both fixtures.Evidence:
output/qa/docx-formula-determinism-runtime-20260714122647510/summary.jsonplus the Go adapter integration result. Runtime latency was observed, not compared (Math 58/33 ms; Physics 30/31 ms).Command:
if [ -d services/formula-docx-service ]; then printf 'exists\n'; exit 1; else printf 'missing services/formula-docx-service as expected\n'; fiResult: passed.
Output:
missing services/formula-docx-service as expectedEvidence: no deployable
services/formula-docx-servicedirectory exists.Command:
if [ -d runtimes/go-formula-docx ]; then printf 'external runtime exists: runtimes/go-formula-docx\n'; else printf 'missing external runtime\n'; exit 1; fiResult: passed.
Output:
external runtime exists: runtimes/go-formula-docxEvidence: external adapter evidence path exists and was not edited.
Route State
- Route/default state: runtime-adapter only; no deployable service or default route promotion.
- Delegated gateway verification scope: none; no gateway route edits delegated.
- Public frontend state: no frontend or gateway route should call
formula-docx-servicedirectly. - Rollback notes: keep the current
docx-import-serviceadapter fallback and internal runtime wiring. If parser runtime changes are needed, request a separate user-approved task for the external runtime instead of editing it from this Go-platform service-agent slice.
Data Notes
- Tables touched: none.
- Migrations: none.
- Data validation report: not applicable because this proof changed no data.
Risks / Blockers
- Raw runtime diagnostic OLE/WMF asset paths are not bit-identical in every envelope; they are excluded by the adapter before review persistence. The import-visible adapter response is deterministic for the checked corpus.
- Materialized formula-reference and deployed/runtime-version parity outside this local external runtime remain future import-service adapter work.
- No public API, default route, or deployable
formula-docx-servicepromotion is accepted by this handoff. - The broad rollout remains active-not-complete.
Next Step
- Use
docs/agents/service-tasks/import-mathtype-conversion-boundary.mdfor the next MathType/OLE parser contract slice, keeping conversion status/download ownership inimport-serviceunless a later ADR promotes a formal parser service boundary.