Skip to content

AIFACTORY-FEAT-057: RetentionResidencyService: complete delivery

Generated from the architecture model

This page is rendered from model/**/*.yaml by tools/docs_model during mkdocs build. Edit the YAML, not this page; hand-written design lives on the linked service, platform and plane pages.

A design artefact, not a tracker

This backlog is generated from model/backlog/ and validated against the architecture model. No work item exists in any tracker, and no item carries a date, an estimate or an assignee (ADR-0029).

Epic Data & Event Platform (PF-11) · Increment I4 Trust and accountability · State elaborated · Route backend-developer · Build order 127 of 185 (Factory code)

RetentionResidencyService is the service of bounded context BC-42 (Data & Event Foundations). Retention rules per store class and classification (traces 30 days, audit 7 years redacted, runs and artifacts 1 year tenant-configurable), residency rules per tenant (selected region, allowed engines), deletion orders that fan out to every owning service and complete within 30 days with acknowledgements, and export orders in open formats — data governance (D31, ADR-0019) as a service (BC-42). Its own repository is ConnectSoft.AI.SoftwareFactory.RetentionResidencyService.

Delivers RetentionResidencyService (complete)
Stubs —
Realizes adrs: ADR-0019, ADR-0015
Requirements FR-12, FUX-11, FUX-12, NFR-14, NFR-15, NFR-16, XL-09, XL-13
Depends on —
Sources model/services/data-event/RetentionResidencyService.yaml

Scenarios to trace (14, catalog): SCN-RetentionResidencyService-001 ✓, SCN-RetentionResidencyService-002 ✓, SCN-RetentionResidencyService-003 ✓, SCN-RetentionResidencyService-004 ✓, SCN-RetentionResidencyService-005 ✓, SCN-RetentionResidencyService-006 ✓, SCN-RetentionResidencyService-007 ✓, SCN-RetentionResidencyService-008 ✓, SCN-RetentionResidencyService-009 ✓, SCN-RetentionResidencyService-010 ✓, SCN-RetentionResidencyService-011 ✓, SCN-RetentionResidencyService-012 ✓, SCN-RetentionResidencyService-013 ✓, SCN-RetentionResidencyService-014 ✓

AIFACTORY-US-048: Data is kept, placed and deleted by rule, with proof

behavior · persona workspace-admin As a workspace administrator, I want retention and residency rules for my tenant and deletion orders that every owning service acknowledges, so that I can prove where data lives, how long it is kept and that a deletion happened.

This is the integration PBI of the feature. RetentionResidencyService is the service of bounded context BC-42 that turns the data governance of ADR-0019 into rules and orders. It owns three aggregates in retention-residency-sql: RetentionRule, how long a store class keeps data of a classification for a tenant, under the platform defaults that are the ceiling; ResidencyRule, the region of a tenant with its allowed regions and engines per store class and the residency class it gives the model router; and GovernanceOrder, a tenant deletion, project deletion, run purge, export or legal hold for a scope, fanned out to every owning service as a task that completes only when that owner acknowledges with a receipt and becomes Overdue when DataEvent:Retention:DeletionWindowDays elapses. Callers reach its seven REST operations through the gateway DataEventFoundations under factory.data.read, factory.data.admin and, for owning services, factory.data.acknowledge; StoreProfileService and the model router call Retention.EvaluateResidency. The behaviour is delivered by the behaviour PBIs of this feature: retention rules (AIFACTORY-US-1452), residency (AIFACTORY-US-1453), residency checks (AIFACTORY-US-1454), issuing orders (AIFACTORY-US-1455), dispatch, acknowledgement and the tenant deletion saga (AIFACTORY-US-1456), export (AIFACTORY-US-1457) and the retention sweep (AIFACTORY-US-1458); the deletion-order handlers of the services delivered before this increment, their legal-hold handlers where the feature of the service does not already build one (D137), and the retention and legal-hold handlers of ArtifactService (D125), are built by AIFACTORY-US-1459 to AIFACTORY-US-1465 in the repositories of those services, one PBI per group of owners, proven by the deletion and hold scenarios SCN-RetentionResidencyService-011 and SCN-RetentionResidencyService-014. The six events leave through the outbox of the retention-residency messaging profile under the canonical envelope, and the one consumed event enters through its inbox. Messaging, persistence, scheduling and telemetry come from the base template with the Factory profile and the pinned observability packages, never forked. Repository: ConnectSoft.AI.SoftwareFactory.RetentionResidencyService, created by the repository checklist of feature repository-and-pipeline-conventions.

Acceptance criteria

AC1 Given the repository ConnectSoft.AI.SoftwareFactory.RetentionResidencyService, whose first commit is the unchanged output of dotnet new connectsoft-base -n ConnectSoft.AI.SoftwareFactory.RetentionResidencyService --UseFactoryProfile true from the pinned template package, when its pipeline runs with the work of this feature, then no second scaffold was run, the solution builds, the unit and acceptance tests pass and a container image is published (ADR-0028).
AC2 Given the acceptance suites of AIFACTORY-US-1452 to AIFACTORY-US-1458, when they run in the pipeline, then each of the fourteen scenarios of RetentionResidencyService has a passing test that names its id, and a filter that discovers no test counts as a failure (model/scenarios/RetentionResidencyService.yaml).
AC3 Given the outbox and inbox of the retention-residency messaging profile after the acceptance suites, when their records are read, then RetentionResidencyService/RetentionRuleChanged, RetentionResidencyService/ResidencyRuleChanged, RetentionResidencyService/DeletionOrderIssued, RetentionResidencyService/DeletionOrderCompleted, RetentionResidencyService/ExportCompleted and RetentionResidencyService/LegalHoldChanged were written in the transaction of the state change they announce, and the inbox registers exactly the one subscription the model lists (ADR-0019, model/services/data-event/RetentionResidencyService.yaml).
AC4 Given the acceptance suites of AIFACTORY-US-1459 to AIFACTORY-US-1465 in the repositories of the owning services, when they run, then each owning service named there deletes an ordered scope from the stores it owns and acknowledges through RetentionResidencyService/AcknowledgeOrderTask, and a repeated order changes nothing (ADR-0019).
AC5 Given the service starts, when liveness and readiness are probed, then readiness reports retention-residency-sql and the messaging transport, and the telemetry conformance test of the pinned observability packages passes with connectsoft.factory.data_event.orders, connectsoft.factory.data_event.order_completion_days and connectsoft.factory.data_event.residency_violations, none of them carrying a scope value or a personal datum (ADR-0018, model/services/data-event/RetentionResidencyService.yaml).
Traces: services RetentionResidencyService, DataEventFoundations
Traces: aggregates RetentionResidencyService/RetentionRule, RetentionResidencyService/ResidencyRule, RetentionResidencyService/GovernanceOrder
Traces: apis RetentionResidencyService/ListRetentionRules, RetentionResidencyService/SetRetentionRule, RetentionResidencyService/GetResidency, RetentionResidencyService/SetResidency, RetentionResidencyService/IssueGovernanceOrder, RetentionResidencyService/GetGovernanceOrder, RetentionResidencyService/AcknowledgeOrderTask, RetentionResidencyService/Retention.EvaluateResidency
Traces: events RetentionResidencyService/RetentionRuleChanged, RetentionResidencyService/ResidencyRuleChanged, RetentionResidencyService/DeletionOrderIssued, RetentionResidencyService/DeletionOrderCompleted, RetentionResidencyService/ExportCompleted, RetentionResidencyService/LegalHoldChanged
Traces: adrs ADR-0015, ADR-0018, ADR-0019, ADR-0028
Traces: requirements FR-12, NFR-14, NFR-15, NFR-16
Relates: screens retention-residency, governance-orders
Depends on AIFACTORY-US-1452, AIFACTORY-US-1453, AIFACTORY-US-1454, AIFACTORY-US-1455, AIFACTORY-US-1456, AIFACTORY-US-1457, AIFACTORY-US-1458, AIFACTORY-US-1459, AIFACTORY-US-1460, AIFACTORY-US-1461, AIFACTORY-US-1462, AIFACTORY-US-1463, AIFACTORY-US-1464, AIFACTORY-US-1465, feature:repository-and-pipeline-conventions, feature:component-base-template-factory-profile, feature:contracts-package, feature:component-observability-factory-conventions
Sources model/services/data-event/RetentionResidencyService.yaml, model/scenarios/RetentionResidencyService.yaml, docs/planes/data-event/services/retention-residency-service/index.md#purpose-and-responsibilities, docs/architecture/data-governance.md#retention-and-deletion, docs/architecture/adr/0019-data-governance.md

Tasks

Task Kind Expected output Repository
AIFACTORY-TASK-381 Create the repository ConnectSoft.AI.SoftwareFactory.RetentionResidencyService and scaffold it from the ConnectSoft.BaseTemplate template with the Factory profile implementation The repository exists by the repository checklist of feature repository-and-pipeline-conventions, the output of dotnet new connectsoft-base -n ConnectSoft.AI.SoftwareFactory.RetentionResidencyService --UseFactoryProfile true from the pinned template package is committed unchanged with the messaging service name retention-residency, the repository records the template version, the solution builds and the template tests pass in the repository pipeline, which publishes the container image. ConnectSoft.AI.SoftwareFactory.RetentionResidencyService
AIFACTORY-TASK-382 Domain model: RetentionRule, ResidencyRule, GovernanceOrder implementation The aggregates hold the fields and invariants of the model (a tenant rule never longer than the platform default of its class, audit evidence redacted and kept at least 2555 days, a held scope never expires, deletion includes derived indexes and memory, an export carries a manifest) and the six transitions of OrderState; unit tests cover every invariant and every transition and refuse every transition the model does not list. ConnectSoft.AI.SoftwareFactory.RetentionResidencyService
AIFACTORY-TASK-383 Persistence in retention-residency-sql: RetentionRules, ResidencyRules, GovernanceOrders, GovernanceOrderTasks implementation Mappings and migrations for the four modelled tables with the tenant row filter, the unique index on tenant, store class and classification and the index on tenant, state and due moment; mapping tests run against an isolated test database, never a shared one. ConnectSoft.AI.SoftwareFactory.RetentionResidencyService
AIFACTORY-TASK-384 API hosting skeleton: the 7 REST and 1 gRPC operations with scope enforcement and problem responses implementation The seven REST operations are hosted with JWT validation of the token the gateway forwards, scope enforcement per route, the Idempotency-Key filter of IssueGovernanceOrder, the internal visibility of AcknowledgeOrderTask and problem responses for every modelled refusal code; Retention.EvaluateResidency is hosted with workload identity checks; the OpenAPI and proto documents are published; the behaviour of each operation is delivered by AIFACTORY-US-1452 to AIFACTORY-US-1456, not here. ConnectSoft.AI.SoftwareFactory.RetentionResidencyService
AIFACTORY-TASK-385 Messaging skeleton: outbox of the retention-residency profile for 6 published events, inbox for StoreBindingChanged implementation The outbox writer enlists in the transaction of each state change and the dispatcher publishes the six events on their modelled topics under the canonical envelope; the inbox registers the one subscription to StoreBindingChanged with deduplication on the event id, and a test fails when a subscription appears that the model does not list. ConnectSoft.AI.SoftwareFactory.RetentionResidencyService
AIFACTORY-TASK-386 Worker hosting skeleton: RetentionSweeper, OrderDispatcher, Exporter implementation Each worker is hosted with its modelled trigger, retry policy, idempotency key and partition by tenant (RetentionSweeper daily with ruleId plus day, OrderDispatcher and Exporter on DeletionOrderIssued with orderId plus owner service and orderId); a duplicate trigger has no second effect; what each worker does is delivered by AIFACTORY-US-1456 to AIFACTORY-US-1458. ConnectSoft.AI.SoftwareFactory.RetentionResidencyService
AIFACTORY-TASK-387 Security, tenancy and telemetry of RetentionResidencyService implementation The three scopes and four roles of the model are enforced, every query runs under the tenant row filter so an order or rule of another tenant is not found, the messaging transport secret comes from a secret reference, the host makes the one call of the registration of the pinned observability packages, creates the three metrics of the model through its instrument helper and references the conformance test package from its architecture tests. ConnectSoft.AI.SoftwareFactory.RetentionResidencyService
AIFACTORY-TASK-705 Verify retention-residency-and-deletion by running the declared command verification Run dotnet build -c Release and dotnet test -c Release --no-build in the pipeline of ConnectSoft.AI.SoftwareFactory.RetentionResidencyService, then dotnet test -c Release --filter "Category=Acceptance&Scenario~SCN-RetentionResidencyService"; a filter that discovers no test counts as a failure; they pass and prove AC1 to AC5 of AIFACTORY-US-048, with a test for each of SCN-RetentionResidencyService-001 to SCN-RetentionResidencyService-014. ConnectSoft.AI.SoftwareFactory.RetentionResidencyService

AIFACTORY-US-1452: Read the effective retention per store class and shorten it for a tenant, announced by RetentionRuleChanged

behavior · persona workspace-admin As a workspace admin or a platform admin, I want to see how long each store class keeps data of each classification and to shorten it for my tenant, so that the tenant keeps data no longer than it chose and never longer than the platform allows.

A caller with factory.data.read reads RetentionResidencyService/ListRetentionRules on GET /factory/data/retention and receives, for the tenant of the token, the effective retention of every store class and classification: the platform default of DataEvent:Retention:PlatformDefaults (traces 30 days, runs and artifacts 365, projections 395, audit 2555) where the tenant has no rule, and the tenant rule where it has one, each with its expiry action (delete, redact or archive) and whether it is exempt from legal holds. A Workspace admin calls RetentionResidencyService/SetRetentionRule with factory.data.admin on PUT /factory/data/retention/{storeClass}/{classification} to set the retention days and expiry action of the tenant for that class and classification; the platform default is the ceiling, so a value longer than the default of the class is refused with 422 and the rule named, as is an unknown store class or classification, a negative value or, for the class audit, a value below 2555 days or an expiry action other than redact. A Platform admin sets the platform default of a class through the same operation under the platform tenant. The operation is idempotent by nature: the same value again returns 200 and publishes nothing. A change writes RetentionResidencyService/RetentionRuleChanged with ruleId, tenantId, storeClass, classification and retentionDays in the same transaction; the owning services apply it in their own handlers, and for ArtifactService a tenant rule of the class artifacts replaces the default one-year retention of its own sweep (AIFACTORY-US-1462). A caller without the scope, or a Workspace admin who sets a platform default, is refused with 403. StudioBff serves the reads and the edit through the view retention-residency.

Acceptance criteria

AC1 Given a tenant with one rule of its own and a caller with factory.data.read, when RetentionResidencyService/ListRetentionRules is called, then the response is 200 with the platform default for every class without a tenant rule and the tenant rule for the one it set, each with its expiry action, and nothing is written; a caller without the scope is refused with 403 (SCN-RetentionResidencyService-001).
AC2 Given a Workspace admin with factory.data.admin, when RetentionResidencyService/SetRetentionRule shortens runs of classification internal to 180 days, then the response is 200, the RetentionResidencyService/RetentionRule holds 180 and RetentionResidencyService/RetentionRuleChanged is written in the same transaction; the same call again returns 200 and writes nothing (SCN-RetentionResidencyService-002, ADR-0019).
AC3 Given a value longer than the platform default of the class, an audit value below 2555 days or with an expiry action other than redact, or an unknown class or classification, when RetentionResidencyService/SetRetentionRule is called, then the response is 422 naming the rule; given a caller without the scope, or a Workspace admin setting a platform default, then 403; no refusal writes a row or an event (SCN-RetentionResidencyService-002).
AC4 Given a rule changed, when the outbox dispatcher publishes RetentionResidencyService/RetentionRuleChanged on data-foundations.retention.v1.retention-rule-changed, then the event is sent under the canonical envelope with ruleId, tenantId, storeClass, classification and retentionDays, and a transport outage is retried with backoff so the event is neither lost nor duplicated under its event id (SCN-RetentionResidencyService-009, ADR-0012).
Traces: services RetentionResidencyService
Traces: aggregates RetentionResidencyService/RetentionRule
Traces: apis RetentionResidencyService/ListRetentionRules, RetentionResidencyService/SetRetentionRule
Traces: events RetentionResidencyService/RetentionRuleChanged
Traces: adrs ADR-0012, ADR-0019
Traces: requirements FR-12, NFR-14
Traces: scenarios SCN-RetentionResidencyService-001, SCN-RetentionResidencyService-002, SCN-RetentionResidencyService-009
Relates: screens retention-residency
Sources model/services/data-event/RetentionResidencyService.yaml, docs/architecture/data-governance.md#retention-and-deletion

Tasks

Task Kind Expected output Repository
AIFACTORY-TASK-558 Retention and residency rules implementation Retention rules are stored per tenant, store class and classification under the platform defaults of DataEvent:Retention:PlatformDefaults, ListRetentionRules returns the effective rule per class and classification and SetRetentionRule changes it and writes RetentionRuleChanged in the same transaction. ConnectSoft.AI.SoftwareFactory.RetentionResidencyService
AIFACTORY-TASK-5875 Ceiling, audit floor and refusals of SetRetentionRule implementation SetRetentionRule refuses with 422 a value above the platform default of the class, an audit rule below 2555 days or with an expiry action other than redact and an unknown class or classification, refuses with 403 a missing scope and a Workspace admin who sets a platform default, and changes nothing on an unchanged repeat; unit tests cover each rule. ConnectSoft.AI.SoftwareFactory.RetentionResidencyService
AIFACTORY-TASK-5876 Verify retention rules through the acceptance suite verification Run dotnet test -c Release --filter "Category=Acceptance&(Scenario=SCN-RetentionResidencyService-001\|Scenario=SCN-RetentionResidencyService-002\|Scenario=SCN-RetentionResidencyService-009)"; a zero-match filter counts as a failure; the tests prove AC1 to AC4 of AIFACTORY-US-1452, including the publication and payload of RetentionRuleChanged under a transport outage; consumer handling is proven by the suites of the consumers. ConnectSoft.AI.SoftwareFactory.RetentionResidencyService

AIFACTORY-US-1453: Read the residency of a tenant and select its region, announced by ResidencyRuleChanged

behavior · persona platform-admin As a platform admin or a workspace admin, I want to select the region of a tenant and the engines allowed per store class, so that every store, model deployment and connector of the tenant is placed where its rule allows.

A caller with factory.data.read reads RetentionResidencyService/GetResidency on GET /factory/data/residency and receives the residency rule of the tenant of the token: its region, its allowed regions, the allowed engines per store class and its model data residency (same-region, eu or any), which feeds the privacy class of the model router. A tenant without a rule is answered with the default region of the installation and nothing is written. An admin with factory.data.admin selects the region through RetentionResidencyService/SetResidency on PUT /factory/data/residency, a production-class operation; the body names the region, the allowed regions and engines and the model data residency. The first selection of a tenant creates the ResidencyRule and answers 200, and the same body again answers 200 and changes nothing. A region that the installation does not offer, an allowed region list that does not contain the region, an engine that is not a store profile of its class or an unknown model data residency is refused with 422 and the rule named. The model says that a later change of region issues a migration order, but no order kind carries a migration and residency migration orders are a later capability of the service; until the owner decides, a change of region of a tenant that already has one is refused with 422 naming that rule and no data moves, while a change of the allowed engines or of the model data residency in the same region is applied. Every applied change writes RetentionResidencyService/ResidencyRuleChanged with tenantId, region and modelDataResidency in the same transaction. A caller without the scope is refused with 403. StudioBff serves the view retention-residency.

Acceptance criteria

AC1 Given a tenant with a residency rule and a caller with factory.data.read, when RetentionResidencyService/GetResidency is called, then the response is 200 with region, allowed regions, allowed engines per class and model data residency, and nothing is written; a caller without the scope is refused with 403 (SCN-RetentionResidencyService-003).
AC2 Given a tenant without a residency rule and an admin with factory.data.admin, when RetentionResidencyService/SetResidency selects westeurope, then the response is 200, the RetentionResidencyService/ResidencyRule exists and RetentionResidencyService/ResidencyRuleChanged is written in the same transaction; the same body again answers 200 and writes nothing (SCN-RetentionResidencyService-004, ADR-0019).
AC3 Given a region the installation does not offer, an allowed list without the region, an engine that is not a profile of its class, or a change of region of a tenant that already has one, when RetentionResidencyService/SetResidency is called, then the response is 422 naming the rule and no data moves; a caller without the scope is refused with 403; no refusal writes a row or an event (SCN-RetentionResidencyService-004).
AC4 Given a residency change applied, when the outbox dispatcher publishes RetentionResidencyService/ResidencyRuleChanged on data-foundations.residency.v1.residency-rule-changed, then the event is sent under the canonical envelope with tenantId, region and modelDataResidency, and a transport outage is retried with backoff so the event is neither lost nor duplicated under its event id (SCN-RetentionResidencyService-010, ADR-0012).
Traces: services RetentionResidencyService
Traces: aggregates RetentionResidencyService/ResidencyRule
Traces: apis RetentionResidencyService/GetResidency, RetentionResidencyService/SetResidency
Traces: events RetentionResidencyService/ResidencyRuleChanged
Traces: adrs ADR-0012, ADR-0019
Traces: requirements FR-12, NFR-15
Traces: scenarios SCN-RetentionResidencyService-003, SCN-RetentionResidencyService-004, SCN-RetentionResidencyService-010
Relates: screens retention-residency
Sources model/services/data-event/RetentionResidencyService.yaml, docs/planes/data-event/services/retention-residency-service/index.md#later-capabilities

Tasks

Task Kind Expected output Repository
AIFACTORY-TASK-5877 GetResidency and SetResidency with the first selection, the same-region changes and the ResidencyRuleChanged outbox record implementation GetResidency returns the rule of the tenant or the installation default; SetResidency creates the rule on the first selection, applies engine and model data residency changes in the same region, writes ResidencyRuleChanged in the same transaction, changes nothing on an unchanged repeat and refuses with 422 an unknown region, an inconsistent allowed list, an engine outside its class and a change of region of a tenant that has one, and with 403 a missing scope. ConnectSoft.AI.SoftwareFactory.RetentionResidencyService
AIFACTORY-TASK-5878 Verify residency through the acceptance suite verification Run dotnet test -c Release --filter "Category=Acceptance&(Scenario=SCN-RetentionResidencyService-003\|Scenario=SCN-RetentionResidencyService-004\|Scenario=SCN-RetentionResidencyService-010)"; a zero-match filter counts as a failure; the tests prove AC1 to AC4 of AIFACTORY-US-1453, including the refused change of region and the publication and payload of ResidencyRuleChanged. ConnectSoft.AI.SoftwareFactory.RetentionResidencyService

AIFACTORY-US-1454: Evaluate a store binding, model deployment or connector region against the residency of its tenant

behavior · persona platform-admin As a platform admin who relies on StoreProfileService and the model router to check residency, I want each of them to ask whether a candidate region and engine satisfy the residency of a tenant before it binds or selects it, so that no data of a tenant is placed outside the regions it allows.

StoreProfileService before it binds a store and the model router before it selects a deployment call the internal gRPC method RetentionResidencyService/Retention.EvaluateResidency with a workload identity and the request residency-evaluation-request-v1, which names the tenant, which must be the one the workload forwards under its service scope, and the candidate: its kind (store-binding, model-deployment or connector), its id, its region and, for a store, its store class and engine. The reply residency-evaluation-v1 carries the tenant, the candidate, the verdict allowed and the rule it applied: the region of the tenant, its allowed regions, its model data residency and, for a refusal, the reason (D137); these dedicated descriptors replace the borrowed execution-scope-v1 and ack-v1. The service reads the residency rule of that tenant and accepts the candidate when the region is in the allowed regions and the engine is allowed for the class, and refuses it otherwise, naming the rule that refused it in the reply. Every refusal increments connectsoft.factory.data_event.residency_violations by tenant and kind; the method is of class read and writes nothing else. A tenant without a residency rule is evaluated against the default region of the installation. A caller without a workload identity is refused with UNAUTHENTICATED and an invalid request with INVALID_ARGUMENT. The service also consumes StoreBindingChanged of StoreProfileService through its handler CheckResidency, idempotent on the event id through the inbox: it evaluates the binding of the event against the rule of its tenant in the same way, and a binding that violates the rule increments the same metric and is recorded as evidence with AuditService, so a binding made while this service was unavailable is still found. The event itself is traced by the feature of StoreProfileService; this PBI does not depend on that feature, because StoreProfileService depends on this one.

Acceptance criteria

AC1 Given a tenant whose rule allows westeurope and a workload identity, when RetentionResidencyService/Retention.EvaluateResidency is called for a store binding in westeurope with an allowed engine, then the reply residency-evaluation-v1 is allowed and nothing is written; for a binding in another region or with an engine not allowed for its class, the reply is not allowed with the region, the allowed regions and the reason of the refusing rule, and connectsoft.factory.data_event.residency_violations is incremented by tenant and kind (SCN-RetentionResidencyService-008, ADR-0019, D137).
AC2 Given a caller without workload identity or an invalid request, when the method is called, then it is refused with UNAUTHENTICATED or INVALID_ARGUMENT and no state changes (SCN-RetentionResidencyService-008, ADR-0015).
AC3 Given a delivery of StoreBindingChanged for a binding that violates the residency of its tenant, when CheckResidency handles it, then the violation is counted and recorded as evidence once, and a redelivery of the same event changes nothing (model/services/data-event/RetentionResidencyService.yaml, ADR-0012).
Traces: services RetentionResidencyService, StoreProfileService, ModelRouterService
Traces: aggregates RetentionResidencyService/ResidencyRule
Traces: apis RetentionResidencyService/Retention.EvaluateResidency
Traces: descriptors residency-evaluation-request-v1, residency-evaluation-v1
Traces: adrs ADR-0012, ADR-0015, ADR-0019
Traces: requirements NFR-15
Traces: scenarios SCN-RetentionResidencyService-008
Depends on AIFACTORY-US-1453, feature:audit-service-complete
Sources model/services/data-event/RetentionResidencyService.yaml, docs/reference/schemas/residency-evaluation.schema.json, docs/planes/data-event/services/retention-residency-service/index.md#apis

Tasks

Task Kind Expected output Repository
AIFACTORY-TASK-5879 Retention.EvaluateResidency against the residency rule of the forwarded tenant implementation EvaluateResidency takes residency-evaluation-request-v1, checks its tenant against the tenant the workload forwards under its service scope, evaluates the candidate region and engine against the rule or the installation default and answers residency-evaluation-v1 with the verdict, the region, allowed regions and model data residency of the rule it applied and the reason of a refusal (D137), increments connectsoft.factory.data_event.residency_violations on a refusal and refuses callers without workload identity and invalid requests with UNAUTHENTICATED and INVALID_ARGUMENT. ConnectSoft.AI.SoftwareFactory.RetentionResidencyService
AIFACTORY-TASK-5880 CheckResidency handler of StoreBindingChanged implementation The inbox handler CheckResidency evaluates the binding of each StoreBindingChanged against the rule of its tenant, counts a violation and records it as evidence with AuditService once per event id, and a redelivery changes nothing; a test uses a fixture event of the published contract of StoreProfileService. ConnectSoft.AI.SoftwareFactory.RetentionResidencyService
AIFACTORY-TASK-5881 Verify residency evaluation through the acceptance suite verification Run dotnet test -c Release --filter "Category=Acceptance&Scenario=SCN-RetentionResidencyService-008"; a zero-match filter counts as a failure; the tests prove AC1 to AC3 of AIFACTORY-US-1454 with an allowed and a refused binding, a refused deployment region, a call without workload identity and a redelivered StoreBindingChanged. ConnectSoft.AI.SoftwareFactory.RetentionResidencyService

AIFACTORY-US-1455: Issue a deletion, purge, export or legal-hold order for a scope, with tenant deletion gated by its approval

behavior · persona workspace-admin As a workspace admin or a platform admin, I want to issue an order that deletes, purges, exports or holds the data of a scope, so that the tenant can leave, clean up or keep data on legal grounds with one act that every owner follows.

An admin with factory.data.admin calls RetentionResidencyService/IssueGovernanceOrder on POST /factory/data/orders with an Idempotency-Key. The body names the kind (TenantDeletion, ProjectDeletion, RunPurge, Export or LegalHold), the scope (the tenant, a project, a run set or a classification, always inside the tenant of the token) and, for an export, the format (JsonLines, Parquet, Markdown or Zip). As the model gives factory.data.admin to the Workspace admin for the tenant, a Workspace admin of the tenant issues any order kind for a scope of the tenant, a tenant deletion included, and a Platform admin may do the same; a TenantDeletion is additionally gated by its approval. The service creates the GovernanceOrder in state Issued with issuedBy and dueAt at the issue plus DataEvent:Retention:DeletionWindowDays, and answers 202 with the order id; the order then runs asynchronously (AIFACTORY-US-1456). A deletion, purge or export writes RetentionResidencyService/DeletionOrderIssued with orderId, tenantId, kind, scope and dueAt; a legal hold writes RetentionResidencyService/LegalHoldChanged with orderId, tenantId, scope and active true; each in the same transaction as the order. A tenant deletion is a production-class action: the body names the approval bound to it, the service checks it with RunControlService, a required dependency that fails fast, and records it as approvalId; a tenant deletion without an approval, or with one that is not granted for this order, is refused with 412. A legal hold suspends deletion and expiry, not reading, so a deletion or purge of a scope under an active legal hold is refused with 409 naming the hold, while an export of a held scope, which deletes nothing, is accepted; a key reused with a different body is refused with 409; a repeat with the same key and body returns the first 202 and changes nothing. A hold placed after a deletion order was issued does not cancel that order: as the reading of D137 states, a deletion task stays open while a legal hold holds it, so the owner whose records are held leaves them in place and keeps its task open, not acknowledged, until the hold is lifted (AIFACTORY-US-1459 to AIFACTORY-US-1465), and the order does not complete while held data remains. A scope outside the tenant of the token is not found for the caller and refused with 404 in line with ADR-0015; a caller without the scope, or without the Workspace admin or Platform admin role, is refused with 403. Every order is recorded as evidence with AuditService. RunControlService (for a TenantDeletion) and AuditService are required dependencies that fail fast: when either does not answer, no order, task or event is written, the caller receives 503 with a problem response that names the dependency (D137), and a repeat under the same Idempotency-Key once the dependency answers is applied once. StudioBff serves the views governance-orders and offboardings.

Acceptance criteria

AC1 Given a Workspace admin with factory.data.admin, when RetentionResidencyService/IssueGovernanceOrder issues a ProjectDeletion with an Idempotency-Key, then the response is 202 with the order id, the RetentionResidencyService/GovernanceOrder is Issued with dueAt at the issue plus DataEvent:Retention:DeletionWindowDays, and RetentionResidencyService/DeletionOrderIssued is written in the same transaction; the same key and body again returns the first 202 and writes nothing (SCN-RetentionResidencyService-005, ADR-0019).
AC2 Given a Workspace admin of the tenant and a TenantDeletion without an approval, or with one RunControlService does not report as granted for it, when the order is issued, then the response is 412 and nothing is written; with a granted approval it is 202 and the order records approvalId (SCN-RetentionResidencyService-005, ADR-0015).
AC3 Given a deletion or purge of a scope under an active legal hold, a key reused with a different body, a caller without the scope or without the Workspace admin or Platform admin role, or a scope of another tenant, when RetentionResidencyService/IssueGovernanceOrder is called, then the response is 409, 409, 403 or 404 respectively with a problem response and no row or event is written; given an Export of a held scope, then it is accepted with 202 (SCN-RetentionResidencyService-005, ADR-0015).
AC4 Given RunControlService does not answer for a TenantDeletion, or AuditService does not answer, when RetentionResidencyService/IssueGovernanceOrder is called, then no order, task or event is written, the response is 503 with a problem response that names the dependency, and a repeat under the same Idempotency-Key once the dependency answers is applied once (SCN-RetentionResidencyService-005, D137, model/services/data-event/RetentionResidencyService.yaml).
AC5 Given a deletion order and a legal hold issued, when the outbox dispatcher publishes RetentionResidencyService/DeletionOrderIssued on data-foundations.orders.v1.deletion-order-issued and RetentionResidencyService/LegalHoldChanged on data-foundations.orders.v1.legal-hold-changed, then each is sent under the canonical envelope, the first with orderId, tenantId, kind, scope and dueAt and the second with orderId, tenantId, scope and active true, and a transport outage is retried with backoff so neither is lost or duplicated under its event id (SCN-RetentionResidencyService-011, SCN-RetentionResidencyService-014, ADR-0012).
Traces: services RetentionResidencyService, RunControlService, AuditService
Traces: aggregates RetentionResidencyService/GovernanceOrder
Traces: apis RetentionResidencyService/IssueGovernanceOrder
Traces: events RetentionResidencyService/DeletionOrderIssued, RetentionResidencyService/LegalHoldChanged
Traces: adrs ADR-0012, ADR-0015, ADR-0019
Traces: requirements FR-12, NFR-16
Traces: scenarios SCN-RetentionResidencyService-005, SCN-RetentionResidencyService-011, SCN-RetentionResidencyService-014
Relates: screens governance-orders, offboardings
Depends on AIFACTORY-US-1452, feature:run-control-service, feature:audit-service-complete
Sources model/services/data-event/RetentionResidencyService.yaml, docs/architecture/data-governance.md#retention-and-deletion

Tasks

Task Kind Expected output Repository
AIFACTORY-TASK-5882 IssueGovernanceOrder with the approval gate, the hold check and the DeletionOrderIssued and LegalHoldChanged outbox records implementation IssueGovernanceOrder creates an Issued order with dueAt from DataEvent:Retention:DeletionWindowDays, answers 202, writes DeletionOrderIssued or LegalHoldChanged in the same transaction and records the order as evidence; a Workspace admin of the tenant may issue every kind, a tenant deletion included; a tenant deletion is checked with RunControlService and refused with 412 without a granted approval; a deletion or purge of a held scope and a reused key with another body are 409 while an export of a held scope is accepted, another tenant 404 and a missing scope or a caller without the Workspace admin or Platform admin role 403; a repeat under the same key returns the first answer; with a fake of RunControlService and a fake of AuditService that do not answer, nothing is written, the answer is 503 with a problem response naming the dependency (D137) and a repeat under the same Idempotency-Key after the fake answers is applied once. ConnectSoft.AI.SoftwareFactory.RetentionResidencyService
AIFACTORY-TASK-5883 Verify order issuing through the acceptance suite verification Run dotnet test -c Release --filter "Category=Acceptance&(Scenario=SCN-RetentionResidencyService-005\|Scenario=SCN-RetentionResidencyService-011\|Scenario=SCN-RetentionResidencyService-014)"; a zero-match filter counts as a failure; the tests prove AC1 to AC5 of AIFACTORY-US-1455 with fakes of RunControlService and AuditService, including fakes that do not answer, the export of a held scope and the publication and payload of both events. ConnectSoft.AI.SoftwareFactory.RetentionResidencyService

AIFACTORY-US-1456: Dispatch an order to every owner, record their acknowledgements, complete or mark it Overdue, and read it

behavior · persona workspace-admin As a workspace admin, I want an order to reach every service that holds data of its scope and to complete only when each acknowledged, so that I can prove that a deletion happened and see which owner is late.

The worker OrderDispatcher starts on DeletionOrderIssued. It creates one row of GovernanceOrderTasks per owning service of the order, as the consumers of the event in the model list them for the services deployed in the installation, moves the order from Issued to InProgress (TasksDispatched) and, once every task is created, to AwaitingAcknowledgements (AllTasksSent); it is idempotent on order plus owner service and retries five times with an exponential backoff. For a TenantDeletion the TenantDeletionSaga keeps the dependency order of the model: its first step verifies the approval bound to the order with RunControlService, and when RunControlService no longer reports it as granted, the compensation of that step applies: the order moves from Issued to Cancelled (trigger Cancel), no task is dispatched, the evidence of the refusal is recorded with AuditService and connectsoft.factory.data_event.orders counts the order as Cancelled. With the approval verified, it opens the tasks of the derived stores first (projections, indexes, memory, cache), then ArtifactService and the authoritative stores, then the governance services, with AuditService redacting and never purging the evidence of the scope, and records completion evidence. An owning service calls RetentionResidencyService/AcknowledgeOrderTask on POST /factory/data/orders/{orderId}/acknowledge with its workload token under factory.data.acknowledge; the owner is taken from the workload identity of the caller, never from the body, and the body carries the reference of its receipt, which is all that GovernanceOrderTasks holds of it besides the moment (ReceiptRef, AcknowledgedAt). The task is marked acknowledged with its receipt and moment and the answer is 200; a repeated acknowledgement returns 200 and changes nothing; an order of another tenant, or one with no task for the calling owner, is answered 404. When the last task is acknowledged, the order moves to Completed (AllAcknowledged) with completedAt and RetentionResidencyService/DeletionOrderCompleted with orderId, tenantId and completedAt is written in the same transaction. Besides its start on the event, OrderDispatcher runs a scheduled due check over the orders AwaitingAcknowledgements, the reading of D137. When dueAt passes first, the order moves to Overdue (DueElapsed), the missing owners are named in the order and in the evidence, the task of each missing owner is dispatched again, and, as the failure mode of the model requires, the overdue order is handed to AlertRuleService on its queued path (an optional dependency of kind event that queues) with the order id and the missing owners so the Operator is alerted; while AlertRuleService is unavailable the alert stays queued and is not lost. The model names no event or operation that carries this alert, which is reported to the owner. connectsoft.factory.data_event.orders counts the order by state Overdue, and a later acknowledgement of the last owner still completes it (Overdue to Completed). A caller with factory.data.read reads RetentionResidencyService/GetGovernanceOrder on GET /factory/data/orders/{orderId} and receives the state, the tasks with their owners, states and receipts, the due moment and, for an export, the bundle reference; an order of another tenant is answered 404 in line with ADR-0015. connectsoft.factory.data_event.order_completion_days records the time to completion by kind.

Acceptance criteria

AC1 Given a ProjectDeletion Issued, when OrderDispatcher handles RetentionResidencyService/DeletionOrderIssued, then one task per owning service exists, the RetentionResidencyService/GovernanceOrder is AwaitingAcknowledgements, and a redelivery creates no second task; given an owning service with factory.data.acknowledge, when it calls RetentionResidencyService/AcknowledgeOrderTask with a receipt reference, then the response is 200 and its task holds the receipt reference and moment; a repeat answers 200 and changes nothing; an order of another tenant or without a task for that owner is answered 404, and a caller without the scope 403 (SCN-RetentionResidencyService-007, ADR-0015).
AC2 Given the last task acknowledged, when the acknowledgement commits, then the order is Completed with completedAt and RetentionResidencyService/DeletionOrderCompleted is written in the same transaction; when the outbox dispatcher publishes it on data-foundations.orders.v1.deletion-order-completed, the event carries orderId, tenantId and completedAt under the canonical envelope and a transport outage is retried without loss or duplicate (SCN-RetentionResidencyService-012, ADR-0012).
AC3 Given one owner that never acknowledges, when the scheduled due check of OrderDispatcher (D137) runs after dueAt, then the order is Overdue naming that owner in the order and in the evidence, the task of that owner is dispatched again, the overdue order is handed to AlertRuleService on its queued path with the order id and the missing owner so the Operator is alerted, connectsoft.factory.data_event.orders counts it as Overdue, and a late acknowledgement still completes it; given AlertRuleService unavailable, then the alert is queued and delivered once it is back, not lost (model/services/data-event/RetentionResidencyService.yaml, ADR-0019).
AC4 Given a TenantDeletion whose bound approval RunControlService no longer reports as granted when the saga starts, then the order moves from Issued to Cancelled, no task is dispatched, evidence of the refusal is recorded with AuditService and connectsoft.factory.data_event.orders counts it as Cancelled; given a TenantDeletion with its approval granted, when the saga runs, then no authoritative task opens before every derived-store task is acknowledged, the AuditService task redacts and opens last, and a failing owner stops the remaining dispatches and leaves the order Overdue with acknowledged deletions kept (ADR-0019, docs/planes/data-event/services/retention-residency-service/index.md#sagas-and-long-running-flows).
AC5 Given an order with acknowledged and open tasks and a caller with factory.data.read, when RetentionResidencyService/GetGovernanceOrder is called, then the response is 200 with state, tasks, owners, receipts and due moment; an order of another tenant or an unknown id is answered 404 and a caller without the scope 403 (SCN-RetentionResidencyService-006, ADR-0015).
Traces: services RetentionResidencyService, AuditService, RunControlService, AlertRuleService
Traces: aggregates RetentionResidencyService/GovernanceOrder
Traces: apis RetentionResidencyService/GetGovernanceOrder, RetentionResidencyService/AcknowledgeOrderTask
Traces: events RetentionResidencyService/DeletionOrderIssued, RetentionResidencyService/DeletionOrderCompleted
Traces: adrs ADR-0012, ADR-0015, ADR-0019
Traces: requirements FR-12, NFR-16
Traces: scenarios SCN-RetentionResidencyService-006, SCN-RetentionResidencyService-007, SCN-RetentionResidencyService-012
Relates: screens governance-orders, offboardings
Depends on AIFACTORY-US-1455
Sources model/services/data-event/RetentionResidencyService.yaml, docs/planes/data-event/services/retention-residency-service/index.md#sagas-and-long-running-flows

Tasks

Task Kind Expected output Repository
AIFACTORY-TASK-559 Order dispatch with acknowledgements implementation OrderDispatcher creates one task per owning service of an order once per order and owner and moves the order to AwaitingAcknowledgements; AcknowledgeOrderTask records the receipt reference of the owner taken from the workload identity and completes the order with DeletionOrderCompleted when the last task is acknowledged; the scheduled due check of OrderDispatcher, the reading of D137, moves an order whose dueAt passed to Overdue, names the missing owners in the order and the evidence, dispatches the task of each missing owner again and hands the overdue order with its id and missing owners to AlertRuleService on its queued path, keeping the alert queued while AlertRuleService is unavailable. ConnectSoft.AI.SoftwareFactory.RetentionResidencyService
AIFACTORY-TASK-560 Contract of the acknowledgement and receipt used by the owning services contract The request of AcknowledgeOrderTask (order id in the path, the receipt reference in the body, which is what GovernanceOrderTasks holds as ReceiptRef, owner taken from the workload identity) is published in the OpenAPI document of the service with a test fixture the handlers of AIFACTORY-US-1459 to AIFACTORY-US-1465 build against; a contract test fails when the body changes incompatibly. ConnectSoft.AI.SoftwareFactory.RetentionResidencyService
AIFACTORY-TASK-5884 TenantDeletionSaga with the dependency order, the approval check and GetGovernanceOrder implementation The saga correlated by order id verifies the approval of a TenantDeletion with RunControlService and, when it is no longer granted, moves the order from Issued to Cancelled, dispatches no task, records the evidence of the refusal with AuditService and counts the order as Cancelled in connectsoft.factory.data_event.orders; otherwise it opens the derived-store tasks first, then ArtifactService and the authoritative owners, then the governance owners with AuditService last, stops on a failing owner leaving the order Overdue, and records completion evidence; GetGovernanceOrder returns state, tasks, receipts, due moment and export reference and answers 404 for another tenant. ConnectSoft.AI.SoftwareFactory.RetentionResidencyService
AIFACTORY-TASK-5885 Verify dispatch, acknowledgement, completion and the saga through the acceptance suite verification Run dotnet test -c Release --filter "Category=Acceptance&(Scenario=SCN-RetentionResidencyService-006\|Scenario=SCN-RetentionResidencyService-007\|Scenario=SCN-RetentionResidencyService-012)"; a zero-match filter counts as a failure; the tests prove AC1 to AC5 of AIFACTORY-US-1456 with a controlled clock and fake owners, including an Overdue order whose missing task is dispatched again and handed to a fake of AlertRuleService that is first unavailable, an Overdue order completed late, a tenant deletion cancelled because its approval is no longer granted, and a tenant deletion whose derived owner fails. ConnectSoft.AI.SoftwareFactory.RetentionResidencyService

AIFACTORY-US-1457: Collect the export bundles of the owners into one archive in an open format with a manifest, announced by ExportCompleted

behavior · persona workspace-admin As a workspace admin, I want an export of my scope in an open format with a manifest of what is and is not in it, so that the tenant can take its data with it and audit what was left out.

The worker Exporter starts on DeletionOrderIssued and acts only on orders of kind Export; it is idempotent on the order id and retries three times with an exponential backoff. As the owning services acknowledge the tasks of an export order, each receipt references the bundle of that owner. The exporter collects the bundles into one archive in the format of the order (JsonLines, Parquet, Markdown or Zip) with a manifest that lists every owner, what it exported and what it did not, including that audit evidence is exported redacted; it stores the archive through ArtifactService, records the reference as exportRef of the order and writes RetentionResidencyService/ExportCompleted with orderId, tenantId, exportRef and format in the same transaction. ArtifactService is a required dependency that degrades: while it does not answer, the archive is kept pending and retried, and the order stays open. An export deletes nothing. How an owning service produces its bundle for an export order is not stated by the model; the handlers of AIFACTORY-US-1459 to AIFACTORY-US-1465 acknowledge an export task with the reference of a bundle, and the owner is asked to confirm that contract.

Acceptance criteria

AC1 Given an Export order in JsonLines whose owners acknowledged with bundle references, when Exporter runs, then one archive in JsonLines with a manifest of every owner and its exported and omitted content is stored through ArtifactService, exportRef is set on the RetentionResidencyService/GovernanceOrder and RetentionResidencyService/ExportCompleted is written in the same transaction; a second run for the same order writes nothing (SCN-RetentionResidencyService-013, ADR-0019).
AC2 Given an export completed, when the outbox dispatcher publishes RetentionResidencyService/ExportCompleted on data-foundations.orders.v1.export-completed, then the event is sent under the canonical envelope with orderId, tenantId, exportRef and format, and a transport outage is retried with backoff so the event is neither lost nor duplicated (SCN-RetentionResidencyService-013, ADR-0012).
AC3 Given ArtifactService does not answer, when Exporter runs, then the archive is not lost, the order stays open and the worker retries, and no record of any owner is deleted by the export (model/services/data-event/RetentionResidencyService.yaml).
Traces: services RetentionResidencyService, ArtifactService
Traces: aggregates RetentionResidencyService/GovernanceOrder
Traces: events RetentionResidencyService/ExportCompleted
Traces: adrs ADR-0012, ADR-0019
Traces: requirements FR-12
Traces: scenarios SCN-RetentionResidencyService-013
Relates: screens offboardings
Depends on AIFACTORY-US-1456, feature:artifact-service
Sources model/services/data-event/RetentionResidencyService.yaml, docs/architecture/data-governance.md#retention-and-deletion

Tasks

Task Kind Expected output Repository
AIFACTORY-TASK-561 Export archive in open formats implementation The Exporter collects the bundles referenced by the receipts of an Export order into one archive in the format of the order with a manifest of exported and omitted content, stores it through ArtifactService, records exportRef and writes ExportCompleted in the same transaction, once per order, and keeps the archive pending while ArtifactService does not answer. ConnectSoft.AI.SoftwareFactory.RetentionResidencyService
AIFACTORY-TASK-5886 Verify export through the acceptance suite verification Run dotnet test -c Release --filter "Category=Acceptance&Scenario=SCN-RetentionResidencyService-013"; a zero-match filter counts as a failure; the tests prove AC1 to AC3 of AIFACTORY-US-1457 with a fake of ArtifactService that first does not answer, including the manifest content and the publication and payload of ExportCompleted. ConnectSoft.AI.SoftwareFactory.RetentionResidencyService

AIFACTORY-US-1458: Sweep expired data by rule into run purge orders, sparing held scopes

behavior · persona workspace-admin As a workspace admin, I want data past its retention to be purged, redacted or archived without a manual order, so that the tenant keeps no data longer than its rules allow.

The worker RetentionSweeper runs daily at the hour the model schedules, partitioned by tenant, two at a time, retrying twice with a fixed backoff and idempotent on rule plus day. The key is applied within the tenant partition the model gives the worker (TenantId), so the effective key is tenant plus rule plus day: a platform default is one rule under the platform tenant, and two tenants that rely on the same default on the same day each receive their own order. The class artifacts is not swept by order: ArtifactService applies the tenant rule in its own sweep, which runs from the first increment, spares the artifacts that audit evidence or an unexpired run references and keeps metadata and lineage (D125, AIFACTORY-US-1462), so RetentionSweeper issues no RunPurge for that class. Every consumer of RetentionRuleChanged has an ApplyRetentionRule handler in the model, which may mean that other owners also expire their records themselves; which other classes are left to the sweep of their owner is not stated by the model and is reported to the owner, and until it decides this PBI sweeps by order every class except artifacts. For every other active retention rule of a tenant, or the platform default where the tenant has none, it computes the expiry moment of the class and issues one GovernanceOrder of kind RunPurge whose scope names the store class, the classification, the expiry moment and the expiry action of the rule (delete, redact or archive); the order is created and RetentionResidencyService/DeletionOrderIssued written in the same transaction, and from there it is dispatched and acknowledged like any other order (AIFACTORY-US-1456). Scopes under an active legal hold are excluded from the order, so expiry is suspended for them, and a rule marked exempt from legal holds is swept as usual. Audit evidence is never purged: for the class audit the action is always redact and the expiry never earlier than 2555 days. A second run on the same day issues no second order for the same rule.

Acceptance criteria

AC1 Given a tenant rule for runs of 180 days and a platform default for traces of 30 days, when RetentionSweeper runs, then one RunPurge RetentionResidencyService/GovernanceOrder per rule is created with the class, classification, expiry moment and action, and RetentionResidencyService/DeletionOrderIssued is written for each in the same transaction; a second run on the same day creates nothing; given two tenants without a rule for traces, then each tenant receives its own RunPurge order for the platform default and a second run that day creates none; given a tenant rule for the class artifacts, then no RunPurge order is issued for that class (ADR-0019, model/services/data-event/RetentionResidencyService.yaml).
AC2 Given a project under an active legal hold and a rule that is not exempt, when the sweeper runs, then that project is excluded from the scope of the order; given an exempt rule, it is included (ADR-0019).
AC3 Given the class audit, when the sweeper runs, then its order carries the action redact and no expiry earlier than 2555 days, and no purge of audit evidence is ordered (docs/architecture/data-governance.md#retention-and-deletion).
Traces: services RetentionResidencyService
Traces: aggregates RetentionResidencyService/RetentionRule, RetentionResidencyService/GovernanceOrder
Traces: events RetentionResidencyService/DeletionOrderIssued
Traces: adrs ADR-0019
Traces: requirements NFR-14
Depends on AIFACTORY-US-1452, AIFACTORY-US-1456
Sources model/services/data-event/RetentionResidencyService.yaml, docs/planes/data-event/services/retention-residency-service/index.md#workers-and-jobs

Tasks

Task Kind Expected output Repository
AIFACTORY-TASK-5887 RetentionSweeper issuing RunPurge orders by rule implementation RetentionSweeper computes the expiry per active rule or platform default per tenant, issues one RunPurge order per tenant, rule and day, the idempotency key applied within the TenantId partition so a platform default yields one order per tenant, with class, classification, expiry moment and action and DeletionOrderIssued in the same transaction, issues no RunPurge for the class artifacts, which ArtifactService sweeps itself (D125, AIFACTORY-US-1462), excludes scopes under an active hold unless the rule is exempt, and never orders a purge of audit evidence. ConnectSoft.AI.SoftwareFactory.RetentionResidencyService
AIFACTORY-TASK-5888 Verify the retention sweep against AC1 to AC3 verification Run dotnet test -c Release --filter "Category=Acceptance&FullyQualifiedName~RetentionSweeper"; a zero-match filter counts as a failure; the tests prove AC1 to AC3 of AIFACTORY-US-1458 with a controlled clock, two tenants on the same platform default, a tenant rule for artifacts, a held project, an exempt rule and the audit class, and two runs on the same day. ConnectSoft.AI.SoftwareFactory.RetentionResidencyService

AIFACTORY-US-1459: Deletion-order handlers of ProjectService, EnvironmentService and RunControlService, and the legal-hold handlers of ProjectService and RunControlService

behavior · persona workspace-admin As a workspace admin, I want the control plane services to delete an ordered scope from their stores and acknowledge it, so that a deletion order completes for projects, environments and runs.

ProjectService, EnvironmentService and RunControlService consume RetentionResidencyService/DeletionOrderIssued through their handler ExecuteDeletionOrder; the model delivers these handlers in this increment with RetentionResidencyService, so this PBI builds them in the repository of each service. Each handler enters through the inbox of its service, idempotent on the event id, and acts only on the scope of the order inside its tenant: a ProjectDeletion removes the project and everything the service holds for it, a TenantDeletion removes every record of the tenant, a RunPurge removes, redacts or archives the run records the scope names, and an Export produces the bundle of the service and deletes nothing. The issue of a deletion order is refused for a scope that is held at that moment (AIFACTORY-US-1455); a legal hold placed after the order was issued, which each of these services learns through its own ApplyLegalHold handler of LegalHoldChanged, leaves the held records in place and keeps the task of the service open, not acknowledged, until LegalHoldChanged lifts the hold; then the handler deletes them and acknowledges, so the order never completes while held data remains. After the deletion commits, the handler calls RetentionResidencyService/AcknowledgeOrderTask with the workload token of its service under factory.data.acknowledge and the reference of its receipt; a repeated order changes nothing and acknowledges again, which the service answers 200 without change. A deletion that fails is retried by the inbox and not acknowledged, so the order becomes Overdue naming the service. As D137 decides, this PBI also builds the legal-hold handler ApplyLegalHold of LegalHoldChanged in the repositories of ProjectService and RunControlService: once per event id it records the hold of the scope inside its tenant on the records the service owns, suspends deletion and retention expiry for that scope while the hold is active and resumes them when a later LegalHoldChanged lifts it; the deletion handler reads that hold state, and a deletion task stays open while a hold holds it, the reading of D137. The ApplyLegalHold handler of EnvironmentService is built by its own feature environment-service, and the retention handlers stay with the feature of each service, except the handler ApplyRetentionRule of RunControlService and the retention sweep of its recovery journal, which feature run-control-service defers to this feature (D140) and this PBI builds in the repository of RunControlService. The table RecoveryJournal is partitioned by month and append-only for the service: its service identity keeps UPDATE and DELETE denied. ApplyRetentionRule records, once per event id, the effective retention that RetentionRuleChanged announces for the store class of the journal within its tenant, and RunControl:Journal RetentionDays, 365 days by default, applies where no rule is announced; the sweep runs under a separate retention identity, which may only drop whole monthly partitions whose newest entry is older than that retention, never deletes or updates a row, and leaves a partition that holds an entry of a run under an active legal hold in place until the hold is lifted (D141).

Acceptance criteria

AC1 Given a ProjectDeletion for a project with environments and runs, when RetentionResidencyService/DeletionOrderIssued is delivered to ProjectService, EnvironmentService and RunControlService, then each deletes the records of that project from the stores it owns, keeps the records of other projects and tenants, and acknowledges through RetentionResidencyService/AcknowledgeOrderTask with a receipt (ADR-0019).
AC2 Given the same order delivered twice, a hold placed by RetentionResidencyService/LegalHoldChanged on the scope after the order was issued, or an Export order, when the handlers run, then a redelivery changes nothing, held records stay and the task of the service stays open, not acknowledged as deleted, until the hold is lifted, after which the records are deleted and the task acknowledged; an export deletes nothing and acknowledges with a bundle reference; a failing deletion is not acknowledged (ADR-0019, ADR-0012).
AC3 Given RetentionResidencyService/LegalHoldChanged placing a hold on a scope and a later one lifting it, when the ApplyLegalHold handler of ProjectService and of RunControlService runs, then the hold is recorded once per event id on the records of that scope inside the tenant, their deletion and retention expiry are suspended while it is active and resumed when it is lifted, and the records of other scopes are untouched (RetentionResidencyService/LegalHoldChanged, D137, ADR-0019).
AC4 Given the table RecoveryJournal of RunControlService partitioned by month with partitions older and newer than RunControl:Journal RetentionDays and a partition that holds an entry of a run under an active legal hold, when RetentionResidencyService/RetentionRuleChanged is handled by ApplyRetentionRule of RunControlService and the journal sweep runs under its separate retention identity, then only the whole partitions older than the effective retention and free of held entries are dropped, no row of a kept partition is deleted or updated, a DELETE or UPDATE of a row under the service identity of RunControlService is refused, and a redelivered event changes nothing (D140, D141, ADR-0019).
Traces: services ProjectService, EnvironmentService, RunControlService
Traces: apis RetentionResidencyService/AcknowledgeOrderTask
Traces: events RetentionResidencyService/DeletionOrderIssued, RetentionResidencyService/LegalHoldChanged, RetentionResidencyService/RetentionRuleChanged
Traces: adrs ADR-0012, ADR-0019
Depends on AIFACTORY-US-1455, AIFACTORY-US-1456, feature:project-service, feature:environment-service, feature:run-control-service
Sources model/services/control-plane/ProjectService.yaml, model/services/control-plane/EnvironmentService.yaml, model/services/control-plane/RunControlService.yaml

Tasks

Task Kind Expected output Repository
AIFACTORY-TASK-5889 ExecuteDeletionOrder handler of ProjectService implementation The inbox handler deletes the ordered scope from the stores of ProjectService once per event id, leaves records held after issue in place with its task open, not acknowledged, until the hold is lifted, produces a bundle for an export, and acknowledges with a receipt through AcknowledgeOrderTask with the workload token of the service. ConnectSoft.AI.SoftwareFactory.ProjectService
AIFACTORY-TASK-5890 ExecuteDeletionOrder handler of EnvironmentService implementation The inbox handler deletes the ordered scope from the stores of EnvironmentService once per event id, leaves records held after issue in place with its task open, not acknowledged, until the hold is lifted, produces a bundle for an export, and acknowledges with a receipt through AcknowledgeOrderTask with the workload token of the service. ConnectSoft.AI.SoftwareFactory.EnvironmentService
AIFACTORY-TASK-5891 ExecuteDeletionOrder handler of RunControlService implementation The inbox handler deletes, redacts or archives the run records of the ordered scope from the stores of RunControlService once per event id, leaves records held after issue in place with its task open, not acknowledged, until the hold is lifted, produces a bundle for an export, and acknowledges with a receipt through AcknowledgeOrderTask with the workload token of the service. ConnectSoft.AI.SoftwareFactory.RunControlService
AIFACTORY-TASK-5892 Verify the deletion handler of ProjectService verification Run dotnet test -c Release --filter "Category=Acceptance&FullyQualifiedName~ExecuteDeletionOrder" in ConnectSoft.AI.SoftwareFactory.ProjectService; a zero-match filter counts as a failure; the tests prove AC1 and AC2 of AIFACTORY-US-1459 for ProjectService against the acknowledgement fixture of AIFACTORY-TASK-560, including a hold placed after issue that keeps the task open until it is lifted. ConnectSoft.AI.SoftwareFactory.ProjectService
AIFACTORY-TASK-5926 Verify the deletion handler of EnvironmentService verification Run dotnet test -c Release --filter "Category=Acceptance&FullyQualifiedName~ExecuteDeletionOrder" in ConnectSoft.AI.SoftwareFactory.EnvironmentService; a zero-match filter counts as a failure; the tests prove AC1 and AC2 of AIFACTORY-US-1459 for EnvironmentService against the acknowledgement fixture of AIFACTORY-TASK-560, including a hold placed after issue that keeps the task open until it is lifted. ConnectSoft.AI.SoftwareFactory.EnvironmentService
AIFACTORY-TASK-5927 Verify the deletion handler of RunControlService verification Run dotnet test -c Release --filter "Category=Acceptance&FullyQualifiedName~ExecuteDeletionOrder" in ConnectSoft.AI.SoftwareFactory.RunControlService; a zero-match filter counts as a failure; the tests prove AC1 and AC2 of AIFACTORY-US-1459 for RunControlService against the acknowledgement fixture of AIFACTORY-TASK-560, including a hold placed after issue that keeps the task open until it is lifted. ConnectSoft.AI.SoftwareFactory.RunControlService
AIFACTORY-TASK-6281 ApplyLegalHold handler of ProjectService implementation The inbox handler of LegalHoldChanged records, once per event id, the hold of the scope inside its tenant on the records ProjectService owns, suspends their deletion and retention expiry while the hold is active and resumes them when a later LegalHoldChanged lifts it; ExecuteDeletionOrder reads that hold state (D137). ConnectSoft.AI.SoftwareFactory.ProjectService
AIFACTORY-TASK-6282 ApplyLegalHold handler of RunControlService implementation The inbox handler of LegalHoldChanged records, once per event id, the hold of the scope inside its tenant on the run records RunControlService owns, suspends their deletion, redaction and retention expiry while the hold is active and resumes them when a later LegalHoldChanged lifts it; ExecuteDeletionOrder reads that hold state (D137). ConnectSoft.AI.SoftwareFactory.RunControlService
AIFACTORY-TASK-6283 Verify the legal-hold handler of ProjectService verification Run dotnet test -c Release --filter "Category=Acceptance&FullyQualifiedName~ApplyLegalHold" in ConnectSoft.AI.SoftwareFactory.ProjectService; a zero-match filter counts as a failure; the tests prove AC3 of AIFACTORY-US-1459 for ProjectService with a hold placed, redelivered and lifted on one project while another project of the tenant is untouched (SCN-RetentionResidencyService-014). ConnectSoft.AI.SoftwareFactory.ProjectService
AIFACTORY-TASK-6284 Verify the legal-hold handler of RunControlService verification Run dotnet test -c Release --filter "Category=Acceptance&FullyQualifiedName~ApplyLegalHold" in ConnectSoft.AI.SoftwareFactory.RunControlService; a zero-match filter counts as a failure; the tests prove AC3 of AIFACTORY-US-1459 for RunControlService with a hold placed, redelivered and lifted on the runs of one project while the runs of another project are untouched (SCN-RetentionResidencyService-014). ConnectSoft.AI.SoftwareFactory.RunControlService
AIFACTORY-TASK-6672 ApplyRetentionRule handler of RunControlService and the partition sweep of the recovery journal implementation The inbox of RunControlService registers RetentionRuleChanged with idempotency on the event id; ApplyRetentionRule records the effective retention of the store class of the journal within its tenant, RunControl:Journal RetentionDays applying where no rule is announced; the sweep runs under a separate retention identity of run-control-sql that may only drop a whole monthly partition of RecoveryJournal whose newest entry is older than that retention, holds no UPDATE, no DELETE of rows and no other right, and skips a partition that holds an entry of a run under an active legal hold kept by ApplyLegalHold; the service identity keeps UPDATE and DELETE denied on RecoveryJournal, so the journal stays append-only for the service (D140, D141). ConnectSoft.AI.SoftwareFactory.RunControlService
AIFACTORY-TASK-6673 Verify the journal retention sweep of RunControlService verification Run dotnet test -c Release --filter "Category=Acceptance&FullyQualifiedName~ApplyRetentionRule" in ConnectSoft.AI.SoftwareFactory.RunControlService; a zero-match filter counts as a failure; the tests prove AC4 of AIFACTORY-US-1459 against an isolated test database with monthly partitions on both sides of the retention, a partition holding an entry of a held run, a controlled clock, a redelivered RetentionRuleChanged, and a DELETE and an UPDATE attempted under the service identity that are refused (D141). ConnectSoft.AI.SoftwareFactory.RunControlService

AIFACTORY-US-1460: Deletion-order handlers of CostUsageService, PolicyEngineService and SecretBrokerService, and the legal-hold handler of CostUsageService

behavior · persona workspace-admin As a workspace admin, I want usage records, policy bundles and secret references of an ordered scope deleted and acknowledged, so that a deletion order completes for cost, policy and secret data.

CostUsageService, PolicyEngineService and SecretBrokerService consume RetentionResidencyService/DeletionOrderIssued through their handler ExecuteDeletionOrder, delivered by this PBI in the repository of each service. Each handler enters through the inbox of its service, idempotent on the event id, and acts only on the scope of the order inside its tenant: usage records and budgets of the scope, the policy bundle and decisions of the scope, and the secret references of the scope with the secret material they point at in the vault the broker owns. A TenantDeletion removes the policy bundle of the tenant as well, so a later decision for that tenant would seed a new one as ADR-0015 states. The issue of a deletion order is refused for a scope held at that moment (AIFACTORY-US-1455). CostUsageService learns of a hold placed after issue through its own ApplyLegalHold handler of LegalHoldChanged, which this PBI builds in its repository as D137 decides: once per event id it records the hold of the scope on the usage records and budgets the service owns, suspends their deletion and retention expiry while it is active and resumes them when a later LegalHoldChanged lifts it; the held records stay and the task stays open, not acknowledged, until the hold is lifted, then the deletion handler deletes and acknowledges. PolicyEngineService and SecretBrokerService do not consume LegalHoldChanged in the model, so their handlers cannot see a hold placed after issue; this is reported to the owner. An Export produces the bundle of the service and deletes nothing, and after the deletion commits the handler acknowledges through RetentionResidencyService/AcknowledgeOrderTask with its workload token and a receipt; a redelivery changes nothing and a failing deletion is not acknowledged.

Acceptance criteria

AC1 Given a ProjectDeletion, when RetentionResidencyService/DeletionOrderIssued is delivered to CostUsageService, PolicyEngineService and SecretBrokerService, then each deletes the records of that project from the stores it owns, keeps those of other projects and tenants, and acknowledges through RetentionResidencyService/AcknowledgeOrderTask with a receipt (ADR-0019).
AC2 Given the same order delivered twice, a hold placed by RetentionResidencyService/LegalHoldChanged on the scope after the order was issued, or an Export order, when the handlers run, then a redelivery changes nothing, the held records of CostUsageService stay and its task stays open, not acknowledged as deleted, until the hold is lifted, an export deletes nothing, and a failing deletion is not acknowledged (ADR-0019, ADR-0015).
AC3 Given RetentionResidencyService/LegalHoldChanged placing a hold on a scope and a later one lifting it, when the ApplyLegalHold handler of CostUsageService runs, then the hold is recorded once per event id on the usage records and budgets of that scope inside the tenant, their deletion and retention expiry are suspended while it is active and resumed when it is lifted, and the records of other scopes are untouched (RetentionResidencyService/LegalHoldChanged, D137, ADR-0019).
Traces: services CostUsageService, PolicyEngineService, SecretBrokerService
Traces: apis RetentionResidencyService/AcknowledgeOrderTask
Traces: events RetentionResidencyService/DeletionOrderIssued, RetentionResidencyService/LegalHoldChanged
Traces: adrs ADR-0015, ADR-0019
Depends on AIFACTORY-US-1455, AIFACTORY-US-1456, feature:cost-usage-service-complete, feature:policy-engine-service, feature:secret-broker-service
Sources model/services/control-plane/CostUsageService.yaml, model/services/governance/PolicyEngineService.yaml, model/services/governance/SecretBrokerService.yaml

Tasks

Task Kind Expected output Repository
AIFACTORY-TASK-5893 ExecuteDeletionOrder handler of CostUsageService implementation The inbox handler deletes the usage records and budgets of the ordered scope once per event id, leaves records held after issue in place with its task open, not acknowledged, until the hold is lifted, produces a bundle for an export, and acknowledges with a receipt through AcknowledgeOrderTask. ConnectSoft.AI.SoftwareFactory.CostUsageService
AIFACTORY-TASK-5894 ExecuteDeletionOrder handler of PolicyEngineService implementation The inbox handler deletes the policy bundle and decisions of the ordered scope once per event id, produces a bundle for an export, and acknowledges with a receipt through AcknowledgeOrderTask; it does not consume LegalHoldChanged in the model and relies on the refusal of a held scope at issue. ConnectSoft.AI.SoftwareFactory.PolicyEngineService
AIFACTORY-TASK-5895 ExecuteDeletionOrder handler of SecretBrokerService implementation The inbox handler deletes the secret references of the ordered scope and the secret material they point at once per event id, never exports secret material, and acknowledges with a receipt through AcknowledgeOrderTask; it does not consume LegalHoldChanged in the model and relies on the refusal of a held scope at issue. ConnectSoft.AI.SoftwareFactory.SecretBrokerService
AIFACTORY-TASK-5896 Verify the deletion handler of CostUsageService verification Run dotnet test -c Release --filter "Category=Acceptance&FullyQualifiedName~ExecuteDeletionOrder" in ConnectSoft.AI.SoftwareFactory.CostUsageService; a zero-match filter counts as a failure; the tests prove AC1 and AC2 of AIFACTORY-US-1460 for CostUsageService against the acknowledgement fixture of AIFACTORY-TASK-560, including a hold placed after issue that keeps the task open until it is lifted. ConnectSoft.AI.SoftwareFactory.CostUsageService
AIFACTORY-TASK-5928 Verify the deletion handler of PolicyEngineService verification Run dotnet test -c Release --filter "Category=Acceptance&FullyQualifiedName~ExecuteDeletionOrder" in ConnectSoft.AI.SoftwareFactory.PolicyEngineService; a zero-match filter counts as a failure; the tests prove AC1 and AC2 of AIFACTORY-US-1460 for PolicyEngineService against the acknowledgement fixture of AIFACTORY-TASK-560. ConnectSoft.AI.SoftwareFactory.PolicyEngineService
AIFACTORY-TASK-5929 Verify the deletion handler of SecretBrokerService verification Run dotnet test -c Release --filter "Category=Acceptance&FullyQualifiedName~ExecuteDeletionOrder" in ConnectSoft.AI.SoftwareFactory.SecretBrokerService; a zero-match filter counts as a failure; the tests prove AC1 and AC2 of AIFACTORY-US-1460 for SecretBrokerService against the acknowledgement fixture of AIFACTORY-TASK-560, including that no secret material is exported. ConnectSoft.AI.SoftwareFactory.SecretBrokerService
AIFACTORY-TASK-6285 ApplyLegalHold handler of CostUsageService implementation The inbox handler of LegalHoldChanged records, once per event id, the hold of the scope inside its tenant on the usage records and budgets CostUsageService owns, suspends their deletion and retention expiry while the hold is active and resumes them when a later LegalHoldChanged lifts it; ExecuteDeletionOrder reads that hold state (D137). ConnectSoft.AI.SoftwareFactory.CostUsageService
AIFACTORY-TASK-6286 Verify the legal-hold handler of CostUsageService verification Run dotnet test -c Release --filter "Category=Acceptance&FullyQualifiedName~ApplyLegalHold" in ConnectSoft.AI.SoftwareFactory.CostUsageService; a zero-match filter counts as a failure; the tests prove AC3 of AIFACTORY-US-1460 with a hold placed, redelivered and lifted on the usage of one project while another project of the tenant is untouched (SCN-RetentionResidencyService-014). ConnectSoft.AI.SoftwareFactory.CostUsageService

AIFACTORY-US-1461: Deletion-order handlers of AgentRuntimeService, WorkflowEngineService and ModelRouterService

behavior · persona workspace-admin As a workspace admin, I want agent executions, workflow state and routing records of an ordered scope deleted and acknowledged, so that a deletion order completes for the agent runtime and model platforms.

AgentRuntimeService, WorkflowEngineService and ModelRouterService consume RetentionResidencyService/DeletionOrderIssued through their handler ExecuteDeletionOrder; the model delivers the first two in this increment with RetentionResidencyService, and this PBI builds all three in the repository of each service. Each handler enters through the inbox of its service, idempotent on the event id, and acts only on the scope of the order inside its tenant: the executions, attempts and transcripts of the agent runtime, the workflow instances and their state, and the routing decisions and usage the router records. The issue of a deletion order is refused for a scope held at that moment (AIFACTORY-US-1455); none of these three services consumes LegalHoldChanged in the model, so their handlers cannot see a hold placed after issue, which is reported to the owner. An Export produces the bundle of the service and deletes nothing, and after the deletion commits the handler acknowledges through RetentionResidencyService/AcknowledgeOrderTask with its workload token and a receipt; a redelivery changes nothing and a failing deletion is not acknowledged.

Acceptance criteria

AC1 Given a RunPurge for a run set, when RetentionResidencyService/DeletionOrderIssued is delivered to AgentRuntimeService, WorkflowEngineService and ModelRouterService, then each deletes, redacts or archives the records of those runs from the stores it owns, keeps every other run, and acknowledges through RetentionResidencyService/AcknowledgeOrderTask with a receipt (ADR-0019).
AC2 Given the same order delivered twice, an Export order, or a deletion that fails, when the handlers run, then a redelivery changes nothing, an export deletes nothing and acknowledges with a bundle reference, and a failing deletion is not acknowledged, so the order is never reported complete for a scope these services did not delete (ADR-0019, ADR-0012).
Traces: services AgentRuntimeService, WorkflowEngineService, ModelRouterService
Traces: apis RetentionResidencyService/AcknowledgeOrderTask
Traces: events RetentionResidencyService/DeletionOrderIssued
Traces: adrs ADR-0012, ADR-0019
Depends on AIFACTORY-US-1455, AIFACTORY-US-1456, feature:agent-runtime-service, feature:workflow-engine-service, feature:model-router-service
Sources model/services/agent-mesh/AgentRuntimeService.yaml, model/services/agent-mesh/WorkflowEngineService.yaml, model/services/model-compute/ModelRouterService.yaml

Tasks

Task Kind Expected output Repository
AIFACTORY-TASK-5897 ExecuteDeletionOrder handler of AgentRuntimeService implementation The inbox handler deletes, redacts or archives the executions, attempts and transcripts of the ordered scope once per event id, produces a bundle for an export, and acknowledges with a receipt through AcknowledgeOrderTask. ConnectSoft.AI.SoftwareFactory.AgentRuntimeService
AIFACTORY-TASK-5898 ExecuteDeletionOrder handler of WorkflowEngineService implementation The inbox handler deletes the workflow instances and state of the ordered scope once per event id, produces a bundle for an export, and acknowledges with a receipt through AcknowledgeOrderTask. ConnectSoft.AI.SoftwareFactory.WorkflowEngineService
AIFACTORY-TASK-5899 ExecuteDeletionOrder handler of ModelRouterService implementation The inbox handler deletes the routing decisions and usage of the ordered scope once per event id, produces a bundle for an export, and acknowledges with a receipt through AcknowledgeOrderTask. ConnectSoft.AI.SoftwareFactory.ModelRouterService
AIFACTORY-TASK-5900 Verify the deletion handler of AgentRuntimeService verification Run dotnet test -c Release --filter "Category=Acceptance&FullyQualifiedName~ExecuteDeletionOrder" in ConnectSoft.AI.SoftwareFactory.AgentRuntimeService; a zero-match filter counts as a failure; the tests prove AC1 and AC2 of AIFACTORY-US-1461 for AgentRuntimeService against the acknowledgement fixture of AIFACTORY-TASK-560. ConnectSoft.AI.SoftwareFactory.AgentRuntimeService
AIFACTORY-TASK-5930 Verify the deletion handler of WorkflowEngineService verification Run dotnet test -c Release --filter "Category=Acceptance&FullyQualifiedName~ExecuteDeletionOrder" in ConnectSoft.AI.SoftwareFactory.WorkflowEngineService; a zero-match filter counts as a failure; the tests prove AC1 and AC2 of AIFACTORY-US-1461 for WorkflowEngineService against the acknowledgement fixture of AIFACTORY-TASK-560. ConnectSoft.AI.SoftwareFactory.WorkflowEngineService
AIFACTORY-TASK-5931 Verify the deletion handler of ModelRouterService verification Run dotnet test -c Release --filter "Category=Acceptance&FullyQualifiedName~ExecuteDeletionOrder" in ConnectSoft.AI.SoftwareFactory.ModelRouterService; a zero-match filter counts as a failure; the tests prove AC1 and AC2 of AIFACTORY-US-1461 for ModelRouterService against the acknowledgement fixture of AIFACTORY-TASK-560. ConnectSoft.AI.SoftwareFactory.ModelRouterService

AIFACTORY-US-1462: Retention, legal-hold and deletion handlers of ArtifactService and the redaction handler of AuditService

behavior · persona workspace-admin As a workspace admin, I want artifacts kept, held and deleted by the rules of my tenant and the audit evidence of a deleted scope redacted, so that artifacts follow the same rules as every other store and the evidence survives without personal data.

ArtifactService consumes RetentionResidencyService/RetentionRuleChanged through ApplyRetentionRule, RetentionResidencyService/LegalHoldChanged through ApplyLegalHold and RetentionResidencyService/DeletionOrderIssued through ExecuteDeletionOrder; by owner decision all three are built by this feature in the repository of ArtifactService. ArtifactService runs its own retention sweep from the first increment with a default retention of one year (Knowledge:Artifacts:DefaultRetentionDays, ADR-0019 as amended by D125); the sweep removes only the content of artifacts past retention that no audit evidence record and no unexpired run references, as its ArtifactReferences record, keeps metadata and lineage marked Deleted, and never takes a tenant-level artifact as a candidate. RetentionSweeper of RetentionResidencyService issues no purge order for the class artifacts (AIFACTORY-US-1458), so this sweep is the one expiry path of artifacts. ApplyRetentionRule records the rule of a tenant for the store class artifacts and its classification, and from then on that rule replaces the default for the artifacts of that tenant, while tenants without a rule keep the default. ApplyLegalHold marks the artifacts of the held scope so the sweep and every deletion skip them, and lifts the mark when the event says the hold is no longer active. ExecuteDeletionOrder deletes the artifacts and their blobs of the ordered scope and acknowledges through RetentionResidencyService/AcknowledgeOrderTask; when a hold placed after the order was issued covers part of the scope, the held artifacts stay and the task of ArtifactService stays open, not acknowledged, until the hold is lifted, then the handler deletes them and acknowledges. An artifact of a tenant without a project belongs to its tenant (D125): it is deleted only by a TenantDeletion of that tenant, never by a ProjectDeletion or a RunPurge, and it is not a candidate of the retention sweep of a project; the artifacts of the platform tenant are never deleted by an order of a customer tenant. AuditService consumes DeletionOrderIssued through RedactOnDeletionOrder: it records the order as evidence and redacts the personal data of the scope in the evidence that must be kept, never purging it, then acknowledges with its receipt. All handlers enter through the inbox of their service and are idempotent on the event id.

Acceptance criteria

AC1 Given ArtifactService with the default retention of one year and a delivery of RetentionResidencyService/RetentionRuleChanged for the class artifacts of a tenant at 90 days, when the sweep of ArtifactService runs, then the artifacts of that tenant past 90 days whose content no audit evidence record and no unexpired run references lose their content with metadata and lineage kept, an artifact past 90 days that audit evidence or an unexpired run references stays, a tenant-level artifact stays, and a tenant without a rule follows Knowledge:Artifacts:DefaultRetentionDays; a redelivery changes nothing (ADR-0019, model/services/knowledge/ArtifactService.yaml).
AC2 Given a delivery of RetentionResidencyService/LegalHoldChanged with active true for a project, when the sweep runs and a ProjectDeletion of that project issued before the hold is handled, then no held artifact is deleted and the task of ArtifactService stays open, not acknowledged as deleted; after the hold is lifted by the event, the held artifacts are deleted and the task is acknowledged, and artifacts of a lifted hold that no order covers are again candidates of the sweep (ADR-0019).
AC3 Given a ProjectDeletion and an artifact of the same tenant without a project, when RetentionResidencyService/DeletionOrderIssued is handled, then the artifacts and blobs of the project are deleted, the tenant-level artifact stays, and ArtifactService acknowledges through RetentionResidencyService/AcknowledgeOrderTask; a TenantDeletion of that tenant deletes the tenant-level artifact too, and no artifact of the platform tenant is deleted (ADR-0019, ADR-0015).
AC4 Given a TenantDeletion, when AuditService handles the order, then the evidence of the scope is redacted, never purged, the order itself is recorded as evidence, and AuditService acknowledges with its receipt; a redelivery changes nothing (ADR-0019, docs/architecture/data-governance.md#retention-and-deletion).
Traces: services ArtifactService, AuditService
Traces: apis RetentionResidencyService/AcknowledgeOrderTask
Traces: events RetentionResidencyService/DeletionOrderIssued, RetentionResidencyService/RetentionRuleChanged, RetentionResidencyService/LegalHoldChanged
Traces: adrs ADR-0015, ADR-0019
Depends on AIFACTORY-US-1452, AIFACTORY-US-1455, AIFACTORY-US-1456, feature:artifact-service, feature:audit-service-complete
Sources model/services/knowledge/ArtifactService.yaml, model/services/governance/AuditService.yaml, docs/architecture/adr/0019-data-governance.md

Tasks

Task Kind Expected output Repository
AIFACTORY-TASK-5901 ApplyRetentionRule and ApplyLegalHold handlers of ArtifactService implementation ApplyRetentionRule records the tenant rule of the class artifacts so the sweep of ArtifactService uses it in place of Knowledge:Artifacts:DefaultRetentionDays for that tenant, while the sweep still removes only content past retention that no audit evidence record and no unexpired run references, keeps metadata and lineage, and spares tenant-level artifacts; ApplyLegalHold marks and unmarks the artifacts of the held scope so the sweep and deletions skip them; both once per event id. ConnectSoft.AI.SoftwareFactory.ArtifactService
AIFACTORY-TASK-5902 ExecuteDeletionOrder handler of ArtifactService with tenant-level artifacts implementation The inbox handler deletes the artifacts and blobs of the ordered scope once per event id, deletes tenant-level artifacts only on a TenantDeletion of their tenant, never deletes artifacts of the platform tenant on a customer order, leaves artifacts held after issue in place with its task open until the hold is lifted, produces a bundle for an export, and acknowledges with a receipt through AcknowledgeOrderTask. ConnectSoft.AI.SoftwareFactory.ArtifactService
AIFACTORY-TASK-5903 RedactOnDeletionOrder handler of AuditService implementation The inbox handler records the order as evidence, redacts the personal data of the scope in the retained evidence without purging it, once per event id, and acknowledges with a receipt through AcknowledgeOrderTask. ConnectSoft.AI.SoftwareFactory.AuditService
AIFACTORY-TASK-5904 Verify the retention, legal-hold and deletion handlers of ArtifactService verification Run dotnet test -c Release --filter "Category=Acceptance&(FullyQualifiedName~ApplyRetentionRule\|FullyQualifiedName~ApplyLegalHold\|FullyQualifiedName~ExecuteDeletionOrder)" in ConnectSoft.AI.SoftwareFactory.ArtifactService; a zero-match filter counts as a failure; the tests prove AC1 to AC3 of AIFACTORY-US-1462 with a controlled clock, an artifact referenced by audit evidence, one referenced by an unexpired run, a tenant-level artifact and a hold placed after issue. ConnectSoft.AI.SoftwareFactory.ArtifactService
AIFACTORY-TASK-5932 Verify the redaction handler of AuditService verification Run dotnet test -c Release --filter "Category=Acceptance&FullyQualifiedName~RedactOnDeletionOrder" in ConnectSoft.AI.SoftwareFactory.AuditService; a zero-match filter counts as a failure; the tests prove AC4 of AIFACTORY-US-1462 against the acknowledgement fixture of AIFACTORY-TASK-560. ConnectSoft.AI.SoftwareFactory.AuditService

AIFACTORY-US-1463: Deletion-order and legal-hold handlers of ContextBuilderService, KnowledgeIngestionService and RepositoryIntelligenceService

behavior · persona workspace-admin As a workspace admin, I want context packs, ingested sources and repository indexes of an ordered scope deleted and acknowledged, so that no derived knowledge of a deleted scope survives its source.

ContextBuilderService, KnowledgeIngestionService and RepositoryIntelligenceService, delivered thin before this increment, consume RetentionResidencyService/DeletionOrderIssued through their handler ExecuteDeletionOrder, built by this PBI in the repository of each service. They hold derived stores, which a tenant deletion empties first. Each handler enters through the inbox of its service, idempotent on the event id, and removes the context packs and caches, the ingested sources and their chunks, and the repository indexes and graphs of the scope inside its tenant, including every derived index, as ADR-0019 requires. The issue of a deletion order is refused for a scope held at that moment (AIFACTORY-US-1455); each of these services learns of a hold placed after issue through its own ApplyLegalHold handler of LegalHoldChanged, which this PBI builds in the repository of each service as D137 decides: once per event id it records the hold of the scope on the records and derived indexes the service owns, suspends their deletion and retention expiry while it is active and resumes them when a later LegalHoldChanged lifts it. The held records stay and the task stays open, not acknowledged, until the hold is lifted, then the deletion handler deletes them and acknowledges. An Export produces the bundle of the service and deletes nothing, and after the deletion commits the handler acknowledges through RetentionResidencyService/AcknowledgeOrderTask with its workload token and a receipt; a redelivery changes nothing and a failing deletion is not acknowledged.

Acceptance criteria

AC1 Given a ProjectDeletion, when RetentionResidencyService/DeletionOrderIssued is delivered to ContextBuilderService, KnowledgeIngestionService and RepositoryIntelligenceService, then each removes the derived records and indexes of that project, keeps those of other projects and tenants, and acknowledges through RetentionResidencyService/AcknowledgeOrderTask with a receipt (ADR-0019).
AC2 Given the same order delivered twice, a hold placed by RetentionResidencyService/LegalHoldChanged on the scope after the order was issued, or an Export order, when the handlers run, then a redelivery changes nothing, held records stay and the task of the service stays open, not acknowledged as deleted, until the hold is lifted, an export deletes nothing, and a failing deletion is not acknowledged (ADR-0019, ADR-0012).
AC3 Given RetentionResidencyService/LegalHoldChanged placing a hold on a scope and a later one lifting it, when the ApplyLegalHold handler of ContextBuilderService, KnowledgeIngestionService and RepositoryIntelligenceService runs, then each records the hold once per event id on the records and derived indexes of that scope inside the tenant, suspends their deletion and retention expiry while it is active and resumes them when it is lifted, and leaves the records of other scopes untouched (RetentionResidencyService/LegalHoldChanged, D137, ADR-0019).
Traces: services ContextBuilderService, KnowledgeIngestionService, RepositoryIntelligenceService
Traces: apis RetentionResidencyService/AcknowledgeOrderTask
Traces: events RetentionResidencyService/DeletionOrderIssued, RetentionResidencyService/LegalHoldChanged
Traces: adrs ADR-0012, ADR-0019
Depends on AIFACTORY-US-1455, AIFACTORY-US-1456, feature:context-builder-service-thin, feature:knowledge-ingestion-service-thin, feature:repository-intelligence-service-thin
Sources model/services/knowledge/ContextBuilderService.yaml, model/services/knowledge/KnowledgeIngestionService.yaml, model/services/knowledge/RepositoryIntelligenceService.yaml

Tasks

Task Kind Expected output Repository
AIFACTORY-TASK-5905 ExecuteDeletionOrder handler of ContextBuilderService implementation The inbox handler removes the context packs and caches of the ordered scope once per event id, leaves records held after issue in place with its task open, not acknowledged, until the hold is lifted, produces a bundle for an export, and acknowledges with a receipt through AcknowledgeOrderTask. ConnectSoft.AI.SoftwareFactory.ContextBuilderService
AIFACTORY-TASK-5906 ExecuteDeletionOrder handler of KnowledgeIngestionService implementation The inbox handler removes the ingested sources and chunks of the ordered scope once per event id, leaves records held after issue in place with its task open, not acknowledged, until the hold is lifted, produces a bundle for an export, and acknowledges with a receipt through AcknowledgeOrderTask. ConnectSoft.AI.SoftwareFactory.KnowledgeIngestionService
AIFACTORY-TASK-5907 ExecuteDeletionOrder handler of RepositoryIntelligenceService implementation The inbox handler removes the repository indexes and graphs of the ordered scope once per event id, leaves records held after issue in place with its task open, not acknowledged, until the hold is lifted, produces a bundle for an export, and acknowledges with a receipt through AcknowledgeOrderTask. ConnectSoft.AI.SoftwareFactory.RepositoryIntelligenceService
AIFACTORY-TASK-5908 Verify the deletion handler of ContextBuilderService verification Run dotnet test -c Release --filter "Category=Acceptance&FullyQualifiedName~ExecuteDeletionOrder" in ConnectSoft.AI.SoftwareFactory.ContextBuilderService; a zero-match filter counts as a failure; the tests prove AC1 and AC2 of AIFACTORY-US-1463 for ContextBuilderService against the acknowledgement fixture of AIFACTORY-TASK-560, including a hold placed after issue that keeps the task open until it is lifted. ConnectSoft.AI.SoftwareFactory.ContextBuilderService
AIFACTORY-TASK-5933 Verify the deletion handler of KnowledgeIngestionService verification Run dotnet test -c Release --filter "Category=Acceptance&FullyQualifiedName~ExecuteDeletionOrder" in ConnectSoft.AI.SoftwareFactory.KnowledgeIngestionService; a zero-match filter counts as a failure; the tests prove AC1 and AC2 of AIFACTORY-US-1463 for KnowledgeIngestionService against the acknowledgement fixture of AIFACTORY-TASK-560, including a hold placed after issue that keeps the task open until it is lifted. ConnectSoft.AI.SoftwareFactory.KnowledgeIngestionService
AIFACTORY-TASK-5934 Verify the deletion handler of RepositoryIntelligenceService verification Run dotnet test -c Release --filter "Category=Acceptance&FullyQualifiedName~ExecuteDeletionOrder" in ConnectSoft.AI.SoftwareFactory.RepositoryIntelligenceService; a zero-match filter counts as a failure; the tests prove AC1 and AC2 of AIFACTORY-US-1463 for RepositoryIntelligenceService against the acknowledgement fixture of AIFACTORY-TASK-560, including a hold placed after issue that keeps the task open until it is lifted. ConnectSoft.AI.SoftwareFactory.RepositoryIntelligenceService
AIFACTORY-TASK-6287 ApplyLegalHold handler of ContextBuilderService implementation The inbox handler of LegalHoldChanged records, once per event id, the hold of the scope inside its tenant on the context packs and caches ContextBuilderService owns, suspends their deletion and retention expiry while the hold is active and resumes them when a later LegalHoldChanged lifts it; ExecuteDeletionOrder reads that hold state (D137). ConnectSoft.AI.SoftwareFactory.ContextBuilderService
AIFACTORY-TASK-6288 ApplyLegalHold handler of KnowledgeIngestionService implementation The inbox handler of LegalHoldChanged records, once per event id, the hold of the scope inside its tenant on the ingested sources and chunks KnowledgeIngestionService owns, suspends their deletion and retention expiry while the hold is active and resumes them when a later LegalHoldChanged lifts it; ExecuteDeletionOrder reads that hold state (D137). ConnectSoft.AI.SoftwareFactory.KnowledgeIngestionService
AIFACTORY-TASK-6289 ApplyLegalHold handler of RepositoryIntelligenceService implementation The inbox handler of LegalHoldChanged records, once per event id, the hold of the scope inside its tenant on the repository indexes and graphs RepositoryIntelligenceService owns, suspends their deletion and retention expiry while the hold is active and resumes them when a later LegalHoldChanged lifts it; ExecuteDeletionOrder reads that hold state (D137). ConnectSoft.AI.SoftwareFactory.RepositoryIntelligenceService
AIFACTORY-TASK-6290 Verify the legal-hold handler of ContextBuilderService verification Run dotnet test -c Release --filter "Category=Acceptance&FullyQualifiedName~ApplyLegalHold" in ConnectSoft.AI.SoftwareFactory.ContextBuilderService; a zero-match filter counts as a failure; the tests prove AC3 of AIFACTORY-US-1463 for ContextBuilderService with a hold placed, redelivered and lifted on one project while another project of the tenant is untouched (SCN-RetentionResidencyService-014). ConnectSoft.AI.SoftwareFactory.ContextBuilderService
AIFACTORY-TASK-6291 Verify the legal-hold handler of KnowledgeIngestionService verification Run dotnet test -c Release --filter "Category=Acceptance&FullyQualifiedName~ApplyLegalHold" in ConnectSoft.AI.SoftwareFactory.KnowledgeIngestionService; a zero-match filter counts as a failure; the tests prove AC3 of AIFACTORY-US-1463 for KnowledgeIngestionService with a hold placed, redelivered and lifted on one project while another project of the tenant is untouched (SCN-RetentionResidencyService-014). ConnectSoft.AI.SoftwareFactory.KnowledgeIngestionService
AIFACTORY-TASK-6292 Verify the legal-hold handler of RepositoryIntelligenceService verification Run dotnet test -c Release --filter "Category=Acceptance&FullyQualifiedName~ApplyLegalHold" in ConnectSoft.AI.SoftwareFactory.RepositoryIntelligenceService; a zero-match filter counts as a failure; the tests prove AC3 of AIFACTORY-US-1463 for RepositoryIntelligenceService with a hold placed, redelivered and lifted on one project while another project of the tenant is untouched (SCN-RetentionResidencyService-014). ConnectSoft.AI.SoftwareFactory.RepositoryIntelligenceService

AIFACTORY-US-1464: Deletion-order handlers of VectorMemoryService, McpServerRegistryService and ToolAdapterService, and the legal-hold handler of VectorMemoryService

behavior · persona workspace-admin As a workspace admin, I want vector memory, MCP registrations and tool records of an ordered scope deleted and acknowledged, so that no memory or tool data of a deleted scope survives.

VectorMemoryService, McpServerRegistryService and ToolAdapterService consume RetentionResidencyService/DeletionOrderIssued through their handler ExecuteDeletionOrder, built by this PBI in the repository of each service. Each handler enters through the inbox of its service, idempotent on the event id, and removes the vectors and memory entries, the MCP server registrations and the tool bindings and invocation records of the scope inside its tenant; vector memory is a derived store and is emptied with its source, as ADR-0019 requires. The issue of a deletion order is refused for a scope held at that moment (AIFACTORY-US-1455). VectorMemoryService learns of a hold placed after issue through its own ApplyLegalHold handler of LegalHoldChanged, which this PBI builds in its repository as D137 decides: once per event id it records the hold of the scope on the vectors and memory entries the service owns, suspends their deletion and retention expiry while it is active and resumes them when a later LegalHoldChanged lifts it; its held records stay and its task stays open, not acknowledged, until the hold is lifted. McpServerRegistryService and ToolAdapterService do not consume LegalHoldChanged in the model, so their handlers cannot see a hold placed after issue; this is reported to the owner. An Export produces the bundle of the service and deletes nothing, and after the deletion commits the handler acknowledges through RetentionResidencyService/AcknowledgeOrderTask with its workload token and a receipt; a redelivery changes nothing and a failing deletion is not acknowledged.

Acceptance criteria

AC1 Given a ProjectDeletion, when RetentionResidencyService/DeletionOrderIssued is delivered to VectorMemoryService, McpServerRegistryService and ToolAdapterService, then each removes the records of that project from the stores it owns, keeps those of other projects and tenants, and acknowledges through RetentionResidencyService/AcknowledgeOrderTask with a receipt (ADR-0019, ADR-0013).
AC2 Given the same order delivered twice, a hold placed by RetentionResidencyService/LegalHoldChanged on the scope after the order was issued, or an Export order, when the handlers run, then a redelivery changes nothing, the held records of VectorMemoryService stay and its task stays open, not acknowledged as deleted, until the hold is lifted, an export deletes nothing, and a failing deletion is not acknowledged (ADR-0019, ADR-0012).
AC3 Given RetentionResidencyService/LegalHoldChanged placing a hold on a scope and a later one lifting it, when the ApplyLegalHold handler of VectorMemoryService runs, then the hold is recorded once per event id on the vectors and memory entries of that scope inside the tenant in every collection of its vector store profile, their deletion and retention expiry are suspended while it is active and resumed when it is lifted, and the records of other scopes are untouched (RetentionResidencyService/LegalHoldChanged, D137, ADR-0013).
Traces: services VectorMemoryService, McpServerRegistryService, ToolAdapterService
Traces: apis RetentionResidencyService/AcknowledgeOrderTask
Traces: events RetentionResidencyService/DeletionOrderIssued, RetentionResidencyService/LegalHoldChanged
Traces: adrs ADR-0012, ADR-0013, ADR-0019
Depends on AIFACTORY-US-1455, AIFACTORY-US-1456, feature:vector-memory-service-thin, feature:mcp-server-registry-service-thin, feature:tool-adapter-service
Sources model/services/knowledge/VectorMemoryService.yaml, model/services/tools-mcp/McpServerRegistryService.yaml, model/services/tools-mcp/ToolAdapterService.yaml

Tasks

Task Kind Expected output Repository
AIFACTORY-TASK-5909 ExecuteDeletionOrder handler of VectorMemoryService implementation The inbox handler removes the vectors and memory entries of the ordered scope from every collection of its vector store profile once per event id, leaves records held after issue in place with its task open, not acknowledged, until the hold is lifted, produces a bundle for an export, and acknowledges with a receipt through AcknowledgeOrderTask. ConnectSoft.AI.SoftwareFactory.VectorMemoryService
AIFACTORY-TASK-5910 ExecuteDeletionOrder handler of McpServerRegistryService implementation The inbox handler removes the MCP server registrations of the ordered scope once per event id, relies on the refusal of a held scope at issue because it does not consume LegalHoldChanged in the model, produces a bundle for an export, and acknowledges with a receipt through AcknowledgeOrderTask. ConnectSoft.AI.SoftwareFactory.McpServerRegistryService
AIFACTORY-TASK-5911 ExecuteDeletionOrder handler of ToolAdapterService implementation The inbox handler removes the tool bindings and invocation records of the ordered scope once per event id, relies on the refusal of a held scope at issue because it does not consume LegalHoldChanged in the model, produces a bundle for an export, and acknowledges with a receipt through AcknowledgeOrderTask. ConnectSoft.AI.SoftwareFactory.ToolAdapterService
AIFACTORY-TASK-5912 Verify the deletion handler of VectorMemoryService verification Run dotnet test -c Release --filter "Category=Acceptance&FullyQualifiedName~ExecuteDeletionOrder" in ConnectSoft.AI.SoftwareFactory.VectorMemoryService; a zero-match filter counts as a failure; the tests prove AC1 and AC2 of AIFACTORY-US-1464 for VectorMemoryService against the acknowledgement fixture of AIFACTORY-TASK-560, including a hold placed after issue that keeps the task open until it is lifted. ConnectSoft.AI.SoftwareFactory.VectorMemoryService
AIFACTORY-TASK-5935 Verify the deletion handler of McpServerRegistryService verification Run dotnet test -c Release --filter "Category=Acceptance&FullyQualifiedName~ExecuteDeletionOrder" in ConnectSoft.AI.SoftwareFactory.McpServerRegistryService; a zero-match filter counts as a failure; the tests prove AC1 and AC2 of AIFACTORY-US-1464 for McpServerRegistryService against the acknowledgement fixture of AIFACTORY-TASK-560. ConnectSoft.AI.SoftwareFactory.McpServerRegistryService
AIFACTORY-TASK-5936 Verify the deletion handler of ToolAdapterService verification Run dotnet test -c Release --filter "Category=Acceptance&FullyQualifiedName~ExecuteDeletionOrder" in ConnectSoft.AI.SoftwareFactory.ToolAdapterService; a zero-match filter counts as a failure; the tests prove AC1 and AC2 of AIFACTORY-US-1464 for ToolAdapterService against the acknowledgement fixture of AIFACTORY-TASK-560. ConnectSoft.AI.SoftwareFactory.ToolAdapterService
AIFACTORY-TASK-6293 ApplyLegalHold handler of VectorMemoryService implementation The inbox handler of LegalHoldChanged records, once per event id, the hold of the scope inside its tenant on the vectors and memory entries of every collection of its vector store profile, suspends their deletion and retention expiry while the hold is active and resumes them when a later LegalHoldChanged lifts it; ExecuteDeletionOrder reads that hold state (D137). ConnectSoft.AI.SoftwareFactory.VectorMemoryService
AIFACTORY-TASK-6294 Verify the legal-hold handler of VectorMemoryService verification Run dotnet test -c Release --filter "Category=Acceptance&FullyQualifiedName~ApplyLegalHold" in ConnectSoft.AI.SoftwareFactory.VectorMemoryService; a zero-match filter counts as a failure; the tests prove AC3 of AIFACTORY-US-1464 with a hold placed, redelivered and lifted on one project while another project of the tenant is untouched (SCN-RetentionResidencyService-014). ConnectSoft.AI.SoftwareFactory.VectorMemoryService

AIFACTORY-US-1465: Deletion-order handlers of ConnectorRegistryService and IntegrationService

behavior · persona workspace-admin As a workspace admin, I want connector registrations and integration records of an ordered scope deleted and acknowledged, so that a deletion order completes for the integration platform.

ConnectorRegistryService and IntegrationService, delivered thin before this increment, consume RetentionResidencyService/DeletionOrderIssued through their handler ExecuteDeletionOrder, built by this PBI in the repository of each service. Each handler enters through the inbox of its service, idempotent on the event id, and removes the connector registrations and their settings, and the integration subscriptions, deliveries and logs of the scope inside its tenant; credentials of a connector are secret references, and the secret material is removed by SecretBrokerService under its own handler. The issue of a deletion order is refused for a scope held at that moment (AIFACTORY-US-1455); neither service consumes LegalHoldChanged in the model, so their handlers cannot see a hold placed after issue, which is reported to the owner. An Export produces the bundle of the service and deletes nothing, and after the deletion commits the handler acknowledges through RetentionResidencyService/AcknowledgeOrderTask with its workload token and a receipt; a redelivery changes nothing and a failing deletion is not acknowledged.

Acceptance criteria

AC1 Given a ProjectDeletion, when RetentionResidencyService/DeletionOrderIssued is delivered to ConnectorRegistryService and IntegrationService, then each removes the records of that project from the stores it owns, keeps those of other projects and tenants, and acknowledges through RetentionResidencyService/AcknowledgeOrderTask with a receipt (ADR-0019).
AC2 Given the same order delivered twice, an Export order, or a deletion that fails, when the handlers run, then a redelivery changes nothing, an export deletes nothing and carries no secret material, and a failing deletion is not acknowledged, so the order is never reported complete for a scope these services did not delete (ADR-0019, ADR-0012).
Traces: services ConnectorRegistryService, IntegrationService
Traces: apis RetentionResidencyService/AcknowledgeOrderTask
Traces: events RetentionResidencyService/DeletionOrderIssued
Traces: adrs ADR-0012, ADR-0019
Depends on AIFACTORY-US-1455, AIFACTORY-US-1456, feature:connector-registry-service-thin, feature:integration-service-thin
Sources model/services/integration/ConnectorRegistryService.yaml, model/services/integration/IntegrationService.yaml

Tasks

Task Kind Expected output Repository
AIFACTORY-TASK-5913 ExecuteDeletionOrder handler of ConnectorRegistryService implementation The inbox handler removes the connector registrations and settings of the ordered scope once per event id, produces a bundle for an export without secret material, and acknowledges with a receipt through AcknowledgeOrderTask. ConnectSoft.AI.SoftwareFactory.ConnectorRegistryService
AIFACTORY-TASK-5914 ExecuteDeletionOrder handler of IntegrationService implementation The inbox handler removes the integration subscriptions, deliveries and logs of the ordered scope once per event id, produces a bundle for an export, and acknowledges with a receipt through AcknowledgeOrderTask. ConnectSoft.AI.SoftwareFactory.IntegrationService
AIFACTORY-TASK-5915 Verify the deletion handler of ConnectorRegistryService verification Run dotnet test -c Release --filter "Category=Acceptance&FullyQualifiedName~ExecuteDeletionOrder" in ConnectSoft.AI.SoftwareFactory.ConnectorRegistryService; a zero-match filter counts as a failure; the tests prove AC1 and AC2 of AIFACTORY-US-1465 for ConnectorRegistryService against the acknowledgement fixture of AIFACTORY-TASK-560. ConnectSoft.AI.SoftwareFactory.ConnectorRegistryService
AIFACTORY-TASK-5937 Verify the deletion handler of IntegrationService verification Run dotnet test -c Release --filter "Category=Acceptance&FullyQualifiedName~ExecuteDeletionOrder" in ConnectSoft.AI.SoftwareFactory.IntegrationService; a zero-match filter counts as a failure; the tests prove AC1 and AC2 of AIFACTORY-US-1465 for IntegrationService against the acknowledgement fixture of AIFACTORY-TASK-560. ConnectSoft.AI.SoftwareFactory.IntegrationService