Skip to content

Implementation plan / Session plan / Handover RC-1-S28-F30

Handover RC-1-S28-F30 Fix: adm-patient-administration's contract tests cannot install the contract tools when contracts/common/node_modules exists in the checkout

Card: RC-1-S28-F30. Issue: cema-care/his#283. Branch: session/RC-1-S28-F30. Slice: RC-1. This is a round 2 fix of the gate session RC-1-S28-G2. The unit belongs to RC-1-S09. It comes after RC-1-S28-F23, the last change to the unit.

The failure

The gate's evidence is in the first comment on #283. At commit 1586d431, ConsumerContractTest and ProviderContractTest stopped at initializationError:

could not install the contract tools: ERR_PNPM_ABORTED_REMOVE_MODULES_DIR_NO_TTY

ContractTools copied the whole of contracts/ into its Node container. That copy included the host's contracts/common/node_modules, which was made for the host's pnpm store and links into the host's paths. pnpm then wanted to purge that folder. With no TTY and no CI in the container, it aborted. Any checkout where contracts/common was installed fails this way. CLAUDE.md section 3 tells contract work to install it, and other folders' tests install it too. The gate runs every folder in one such checkout.

What was changed and where

Only the tests of services/adm-patient-administration, in app/src/test/java/care/cema/his/adm/app/contract/:

  • ContractTools: the install script is now the constant INSTALL. It copies /src (the repository's contracts/, mounted read-only) to /tmp/contracts with tar --exclude=node_modules. That leaves out the host's node_modules of every contract folder, not only common, together with their links into the host. It then runs CI=true corepack pnpm install --frozen-lockfile. Without a foreign node_modules pnpm has nothing to purge. CI=true stops any other prompt from aborting the same way. This is the same method the ess units already use (ess-governance sets CI=true; ess-reference removes node_modules).
  • ContractToolsTest (new, tags contract and NFR-ADM-009): copies contracts/ to a temporary folder and plants what a host install leaves behind: a .modules.yaml for the host store /repo/.pnpm-store/v10, a .pnpm folder, and links into /repo in common/node_modules and adm/node_modules. The test then starts the tools and runs his-contract lint on contracts/adm. It also checks that the host's folder is left as it was.

No production code, contract, dependency, lockfile or migration changed. No decision record was written: this is a test-harness repair that follows the method other units already use.

Checks and their results

Light profile as HIS_SESSION=RC-1-S28-F30, in services/adm-patient-administration:

Check Result
ContractToolsTest against the old ContractTools Fail: could not install the contract tools: ERR_PNPM_ABORTED_REMOVE_MODULES_DIR_NO_TTY Aborted removal of modules directory due to no TTY, the gate's error
ContractToolsTest with the fix Pass
./gradlew :app:test --tests '*contract*' Pass: ConsumerContractTest 6/6, ProviderContractTest 1/1, ContractToolsTest 1/1
./gradlew build --continue after pnpm install --frozen-lockfile in contracts/common on the host, which is the gate's condition Pass: 222 tests, 0 failed, 1 skipped (the Kafka test, which needs the full profile)
platform/delivery-pipeline/bin/secret-scan code origin/main No leaks
python3 docs/implementation_plan/tools/check_links.py 0 broken

I did not run the slice scenario. This change touches only the unit's contract-test harness. No production code or contract changed, so no scenario step can come out differently.

What the gate line now shows

The line covers criterion 6 (ACC-005) and criterion 3 of slice gate RC-1: the unit's contract tests (session rule 5), run in one checkout of all folders. The gate's run had contracts/common/node_modules installed on the host. In that checkout, ConsumerContractTest and ProviderContractTest (IF-ADM-003) now install the tools and pass, rather than stopping at initializationError. ContractToolsTest keeps that case covered.

Requirements and test scenarios of the card

Requirement Test
NFR-ADM-009 (interoperability: the unit's provider and consumer contract tests run), session rule 5 ContractToolsTest.installsBesideAHostInstall; ConsumerContractTest and ProviderContractTest (RC-1-S09's tags unchanged)

The tests of the owning session RC-1-S09, and of every later session on the unit, are part of ./gradlew build above.

Done differently from the specification or contract

Nothing.

Follow-up

  • RC-1-S28-F31 fixes the same fault in services/ess-audit. The copy that leaves out node_modules, with CI=true, should work there too.
  • Each Java unit has its own copy of a contract-tools helper. A shared helper in services/_template (the service kit's test fixtures) would stop the next unit from repeating this fault. That work belongs to the template's owner.