Implementation plan / Session plan / Handover RC-5-S05
Handover RC-5-S05 Build: Coordination services (document service)¶
Card: RC-5-S05. Issue: cema-care/his#180. Branch: session/RC-5-S05. Slice: RC-5. Decision record: ADR-HIS-129.
Comes after RC-5-S01, which wrote document-reference.v1 (IF-ESS-011) and DocumentRegistered (EVT-ESS-013), and ADR-HIS-125 point 5, which fixed the content channel. This session builds MOD-ESS-009, the document service (FR-ESS-DOC-001), in the empty module the template left in services/ess-coordination. It serves all 11 operations of the contract and meets the ten RC-5-S05 points of CONTRACT-POINTS.md. No contract was changed.
What was built and where¶
All the code is in services/ess-coordination. The unit's README lists the packages and the his.document.* settings.
MOD-ESS-009 (mod-ess-009/src/main/java/care/cema/his/ess/mod009/):
- documents/DocumentService:
- document types;
- uploads: a pre-signed PUT for at most 15 minutes, bound to the calling service;
- registration, with outcome registered or existing (PR-DOC-001-1);
- new versions, whose predecessor must be the current version; entered in error;
- search, read and the version list;
- Domain 6's flags and disposal, refused under legal hold or within retention (PR-DOC-001-4).
- documents/ResolutionService:
- resolution after a policy decision, with the obligations it can honour; a retrieval bound to the subject for at most 5 minutes;
- redemption: the hash is verified, then an address pinned to the object version is answered, valid for 60 seconds.
- documents/Intake: the checks of an upload before it is stored: owner, type, size, real type, malware scan and hash.
- documents/DocumentStore, DocumentEvents and PatientMergeHandler: persistence, DocumentRegistered, and patient merge and unmerge (part 10).
- intake/: Formats (the limits of CFG-ESS-024), ContentInspector (the real type by content) and MalwareScanner (the port: Unconfigured by default, EicarStub).
- storage/: ObjectStore (the port) and S3ObjectStore (signature version 4 on the JDK client, object lock GOVERNANCE, version-pinned addresses, governance bypass at disposal).
- types/: document types as configuration items ess.document-type, the ConfigurationChanged handler, the item type registration, and a synthetic seed (document/types.json, off by default).
- ports/SearchFilters: the search filter of the policy decision point (/v1/decisions/search-filter).
- web/DocumentController: the 11 paths.
- Mod009Module: the schema, the topic his.ess.document.v1, the subscriptions to his.adm.person.v1 and his.ess.configurationitem.v1, and the port beans.
- Migration mod-ess-009/src/main/resources/db/mod_ess_009/V1__documents.sql.
Service kit (service-kit/src/main/java/care/cema/his/kit/policy/):
- PolicyRequest now sends patientRef, encounterRef and subject.onBehalfOf as policy-decision.v1 names them, and leaves out empty fields.
- PolicyCheck has actingFor(account).
Existing callers are unchanged: the old constructors remain.
How to run the checks, and their result¶
On the light profile, started under the session's name:
HIS_SESSION=RC-5-S05 platform/dev-environment/his-env start light
cd services/ess-coordination
./gradlew build # every module, the kit and the app
./gradlew :mod-ess-009:test --tests '*DocumentContractTest' # his-contract verify of the 11 operations, validate-event
./gradlew :mod-ess-009:test --tests '*S3ObjectStoreTest' # the S3 channel against a pinned RustFS (Docker)
Results on 2026-12-02:
- ./gradlew build: successful. 181 tests, none failing (kit 28 with 1 skipped as before, MOD-ESS-007 39, MOD-ESS-008 62, MOD-ESS-009 47, app 5).
- DocumentContractTest: every operation passes his-contract verify (documented request, missing credential, broken body), and the DocumentRegistered events published pass validate-event.
- S3ObjectStoreTest: passes against rustfs/rustfs@sha256:69bd3c4d…, published on 127.0.0.1 only and removed when the tests end.
platform/delivery-pipeline/bin/secret-scan code origin/main: no finding. Documentation: check_links.py and mkdocs build pass.
Requirements and tests¶
Every test is tagged FR-ESS-DOC-001, and those of the scenario also TEST-ESS-032. Its display name starts with the identifiers.
| Requirement or scenario | Test |
|---|---|
| AC-01 found by patient, encounter, type, author and date | DocumentAccessTest.searchFinds |
| AC-02 unauthorized resolution: no content, denial audited (PR-DOC-001-2) | DocumentAccessTest.unauthorizedResolution |
| AC-03 new version of a signed document: both retrievable | DocumentLifecycleTest.newVersionOfSigned |
| AC-04 legal hold: disposal refused (PR-DOC-001-4), including a hold that arrives while content is being removed | DocumentLifecycleTest.legalHoldDisposal, holdDuringDisposal |
| AC-05 out-of-band alteration: detected, withheld, alerted (PR-DOC-001-3) | DocumentAccessTest.outOfBandAlteration |
| PR-DOC-001-1 duplicate | DocumentRegistrationTest.duplicate |
| PR-DOC-001-5 another subject or expired | DocumentAccessTest.retrievalBound |
| TEST-ESS-032 non-permitted format, oversize, renamed executable: each rejected | DocumentRegistrationTest.uploadsRejected |
| TEST-ESS-032 as a whole | The tests above tagged TEST-ESS-032 |
| Parts 6.1, 6.2, 6.8: stored under lock with its hash; metadata; DocumentRegistered; Record change audit | DocumentRegistrationTest.registers |
| Part 6.3 version chain and If-Match | DocumentLifecycleTest.versionChainRules |
| Part 6.4 search filter (clauses, no clause, outage), in the database, with paging | DocumentAccessTest.searchFiltered, searchFilteredInTheDatabase |
| Part 6.5 resolution and redemption; BR-ESS-033 | DocumentAccessTest.resolveAndRedeem, obligationsAndOnBehalfOf |
| Part 6.7 flags and disposal by Domain 6 only; tombstone; a disposal failed part-way and retried | DocumentLifecycleTest.disposal, disposalRetried |
| Part 6.9 DICOM as an external reference | DocumentRegistrationTest.externalReference |
| Part 6.10 the real type: PDF/A, encrypted PDF, FHIR, CDA with no DTD | DocumentRegistrationTest.realType |
| Part 6.10 the checked version is the one stored, even if the upload address is used again | DocumentRegistrationTest.overwriteDuringChecks, S3ObjectStoreTest.copiesTheCheckedVersion |
| Part 7 malware refused and audited | DocumentRegistrationTest.malware |
| Part 10 storage unavailable; who registers | DocumentRegistrationTest.storageUnavailable, whoRegisters; S3ObjectStoreTest.unreachable |
| Part 10 patient merge and unmerge | DocumentLifecycleTest.patientMerge |
| Part 11 entered in error | DocumentLifecycleTest.enteredInError |
| CFG-ESS-024 types from configuration; their read behind a decision | DocumentLifecycleTest.typesFromConfiguration, DocumentAccessTest.typesNeedADecision |
| The S3 channel: pre-signed, lock, pinned version, bypass, expiry | S3ObjectStoreTest |
| IF-ESS-011, EVT-ESS-013 | contract/DocumentContractTest |
Non-functional targets:
- NFR-ESS-007: every operation asks the policy decision point. Content is checked by its real type, scanned and hashed. CDA is read without DTD or external entities. Stored content is under object lock.
- NFR-ESS-011: the contract test.
- NFR-ESS-015: times are UTC, from the kit's clock, in milliseconds.
- NFR-ESS-016: a document carries its language.
- NFR-ESS-017: the kit's telemetry and correlation identifiers, and the counter his.ess.document.security (kinds malware and integrity).
TEST-ESS-018 was listed in the RC-5-S01 handover as partly this session's. The specification names only FR-ESS-TRM-003 for it, and its "resolution notification" is the terminology reporter's, so it is not covered here.
Done differently, and why¶
None from the specification or the contract. The open choices are recorded in ADR-HIS-129: 1. a hand-written S3 client; 2. GOVERNANCE lock; 3. the checks of the real type; 4. the scanner port; 5. disposal only after a configured retention period; 6. the obligations honoured; 7. the retrieval bound to the token's subject; 8. search by filter; 9. merge and unmerge; 10. the format of an external location.
Some things to know:
- Disposal is in three steps: a claim, then the removal of content, then the tombstone. Once a disposal is claimed, a legal hold on that document is refused with "a disposal is in progress", as are changes and resolution. Domain 6 must expect this answer when it holds a document it has just instructed to be disposed of (ADR-HIS-129 point 5).
- With no storage endpoint, or no scanner, the service answers 503 for content. It does not register anything unscanned or unstored.
- The contract names no policy action for listDocumentTypes. It asks for resource ess.DocumentType with action read, and no patient, as MOD-ESS-007 does for its types. Policy authoring must permit it for the roles and services that register or show documents (follow-up 9).
- A denied resolution is audited twice: the kit's access-denied event and ess.doc.resolve-denied. The second is the one the contract names, and it carries the document and patient.
Questions for a person¶
- Retention periods (Domain 6 and Domain 10 leads). PR-DOC-001-4 refuses disposal "within retention", but the schedule is Domain 6's, and no contract gives it to this unit. This unit holds a period per retention class (
his.document.retention-periods), counted from the latest version's creation time, and refuses any class it has no period for. Please confirm that reading, or say whether a Domain 6 disposal instruction should itself be taken as proof that retention has ended. This does not block: the reading refuses rather than disposes.
Follow-ups outside this card¶
- Topic register:
his.ess.document.v1, produceress-coordination(also in the RC-5-S01 handover). - Object storage in the integration environment (
platform/dev-environment, FN-S02 owner): RustFS with object lock and a bucketess-documents. Until then the tests start their own (RustFs). - A Domain 2 malware scanning contract: the
MalwareScannerport waits for it.eicar-stubstands in. - RC-5-S16 (deploy): set
his.document.storage.*,malware-scanner,retention-periods.*and the service identity. Leaveseed-enabledoff outside test environments. - Domain 6 retention periods for each class it uses (question 1).
- Contract: an optional
formatonExternalLocation(ADR-HIS-129 point 10). - Service kit, other units: the
PolicyRequestchange (patientRef,encounterRef,onBehalfOf, empty fields left out) is in this unit's copy of the kit, as inservices/ess-runtime-decision. The template and the units made from it still sendpatientandencounter, which the decision service reads as their policy-decision.v1 names (DecisionRequests.LEGACYin MOD-ESS-002). The template should take the change. - Kit test fixture:
FakePolicyDecisionPointissuesdec-<uuid>decision identifiers, while policy-decision.v1 says UUID. The contract test here permits with a UUID. - Policy authoring (FR-ESS-AUZ policies): permit
ess.DocumentTyperead, andess.DocumentReferenceregister,search,view,print,export,set-flagsanddispose, for the roles and services that need them.