2.6 KiB
2.6 KiB
Tasks: env-spec-conformance
1. Spec annotations
- 1.1 Add a real
**Verified by:**line under every### ENV-NN —block inopenspec/specs/env/spec.mdfor ENV-01 through ENV-17. Nodeferred/follow-upmarkers remain.
2. Spec → impl alignment (spec is the contract)
- 2.1
CoercionErrorthrowsENV.INVALID_FORMAT(notENV.COERCE_ERROR);COERCE_ERRORremoved from the registry. Tests + docs updated. - 2.2
createEnvruns a fixpoint${VAR}interpolation pass over the merged values map before coercion (cross-loader interpolation works). - 2.3 Wire
CreateEnvOptionsSchema,DotenvLoaderOptionsSchema,ObjectLoaderOptionsSchemaat the public boundaries ofcreateEnv,dotenvLoader,objectLoader. Invalid options throwEnvValidationErrorwith codeENV.VALIDATION_FAILED. - 2.4 Wire OTel instruments in
createEnvviametrics.getMeter('suaveplan.env'):env.validation.totalcounter,env.validation.errorscounter,env.load.duration_mshistogram. Add@opentelemetry/apias a runtime dep.
3. Impl → spec alignment (impl is the intended design)
- 3.1
ENV-04updated to spec the single-optionsobjectLoader({source, sourceName})form. - 3.2
ENV-05updated:parseDotenvsilently skips malformed lines;DotenvLoaderOptions.overridedefaults tofalse. - 3.3
ENV-07updated:addRule()onBaseField;optional()/default()lifted to each subclass because their return type narrows. - 3.4
ENV-09updated:ValidationResultshape is{ success, data, errors: ReadonlyArray<EnvError> }. - 3.5
ENV-10updated:maskSensitive(schema, values)argument order; mask glyph is'****'.
4. New tests
- 4.1
src/core/create-env/create-env.spec-conformance.test.tscovers literal-type narrowing, loader-chain merge order,parseDotenvpurity + interpolation chain,dotenvLoadermissing-file fallback,maskSensitivenon-mutation,EnvValidationError.code === ENV.VALIDATION_FAILED,ENV_CODES.*literal typing, cross-loader${VAR}interpolation, unresolved-token default, Zod boundary failures (createEnv / dotenvLoader / objectLoader), and OTel non-throwing instrumentation. - 4.2
tests/dep-graph.test.tsflipped to assert@opentelemetry/apiIS a runtime dep (ENV-14 contract). - 4.3
tests/tree-shake.test.tsupdated to referenceINVALID_FORMATinstead of the removedCOERCE_ERROR.
5. Verify
- 5.1
bunx turbo lint typecheck test --filter=@suaveplan/envgreen. - 5.2
bunx turbo test:coverage --filter=@suaveplan/env100/100/100/100. - 5.3
bun scripts/openspec-conformance.ts @suaveplan/envexits 0.