BccCode.Privacy.Jobs 0.24.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package BccCode.Privacy.Jobs --version 0.24.0
                    
NuGet\Install-Package BccCode.Privacy.Jobs -Version 0.24.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BccCode.Privacy.Jobs" Version="0.24.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BccCode.Privacy.Jobs" Version="0.24.0" />
                    
Directory.Packages.props
<PackageReference Include="BccCode.Privacy.Jobs" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BccCode.Privacy.Jobs --version 0.24.0
                    
#r "nuget: BccCode.Privacy.Jobs, 0.24.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package BccCode.Privacy.Jobs@0.24.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BccCode.Privacy.Jobs&version=0.24.0
                    
Install as a Cake Addin
#tool nuget:?package=BccCode.Privacy.Jobs&version=0.24.0
                    
Install as a Cake Tool

BccCode.Privacy.Jobs

The privacy job (LIB-24). Per row it works out what each process keeps, and then:

  • blanks exactly the fields of the categories no process keeps, in the row and, with ChangeHistory, in every version of its history (nested fields and the mapped fields of every collection item included);
  • replaces the person with the org's pseudonym when no keeping process needs them identified;
  • erases the row, its children, and its history when nothing keeps anything in it, and leaves a tombstone;
  • deletes the pseudonym's key with the person's last pseudonymised row.

A process keeps its categories in a row while its where: matches, a basis covers the data subject (consent, a group's membership, or a legal basis the application writes; everyone, with no data-subject groups), its period runs, and no upheld objection stops it. Rows of a person with a restriction (Art. 18) or an objection being assessed are left alone and counted; a pseudonymised row matches its person's restrictions through privacy.pseudonym. Reduction never goes back.

This is one definition, PrivacyKeeps in BccCode.Privacy.EntityFrameworkCore: every save derives allowed_processes with it too, loading the navigations it reads. So a save never widens a row the job reduced, and a basis given again (a renewed consent) brings its process back at the next save.

The job does not erase a row that another row still points at through a foreign key, when something keeps that row (or it is not a personal row): erasing it would cascade to that row, or be refused. It counts it as {Entity}.EraseBlocked and tries again at the next run. Avoid cascading foreign keys on personal entities: the job then erases only what nothing keeps, and children (PartOf) are erased with their parent anyway.

builder.Services.AddPrivacy<AppDbContext>(models);
builder.Services.AddPrivacyChangeHistory();          // optional: rewrite history too
builder.Services.AddPrivacyJobs<AppDbContext>(o => o.ControllerOrg = controllerOrg);

var jobs = app.Services.GetRequiredService<IPrivacyJobs>();
var pending = await jobs.GetPendingAsync();
var result = await jobs.RunDueAsync(reason: "nightly");
var plan = await jobs.PlanErasureAsync(orgUid, personUid);
IPrivacyJobs Does
GetPendingAsync(entity:, personUid:, orgUid:, kind:, dueBefore:, limit:) What is due; never writes
PreviewAsync(operation) Exactly what applying would change; never writes
ApplyAsync(operation(s), reason:) Applies, narrowed with ForRows or ForPersons
PlanErasureAsync(orgUid, personUid) An erasure request: what may be erased, and refusals with reasons
RunDueAsync(dryRun:, maximumRows:, reason:) Everything due now, queued erasure requests, package-table retention, verify
GetLogAsync(from:, to:, entity:, kind:, limit:) What was done, as counts; no person uids

The job runs through IPrivacyContextFactory<TContext>.ForJob(reason): mapped straight to the tables, and the save keeps the allowed_processes the job sets. Batches hold at most 500 rows; each is loaded fresh and saved once through a new context (pseudonyms and tombstones first). Without ChangeHistory the rows are saved through that context too, and the privacy columns are concurrency tokens, so a row the application changed meanwhile fails the batch, which the next run redoes.

With ChangeHistory (AddPrivacyChangeHistory()), the job sets a business event context (privacy-job, with the reason) for its save, which ChangeHistory requires. ChangeHistory allows one business action per context and maintenance only on a fresh one, so each further step opens a fresh job context: RewriteAsync (blanks, and the person replaced with the pseudonym, in the row and every version), then the privacy columns (not versioned) by ExecuteUpdate, then EraseByIdAsync (rows with their history), children before parents. The rewrite records one version of its own.

Metrics (meter BccCode.Privacy.Jobs): privacy_job.seconds_since_success, privacy_job.overdue_rows, privacy_job.drift_rows, privacy_job.child_lag_rows. Verify counts drift (All.Verify) and child rows that still hold a process their parent row no longer has (Children.Verify).

Running it

The runners are in BccCode.Privacy.Hosting, which already depends on EF Core, ASP.NET Core and Wolverine (the AspNetCore and Wolverine packages do not depend on EF Core, so they stay without the job):

Runner Use
app.MapPrivacyJobs("/internal/privacy", policy: "scheduler") POST /jobs/run?dryRun=&maximumRows=&reason=, GET /jobs/pending, GET /jobs/log, for Cloud Scheduler. Counts only, no person uids. Without a policy: any authenticated caller.
bus.InvokeAsync<PrivacyRunResult>(new RunPrivacyJobs()) Wolverine; include the assembly: opts.Discovery.IncludeAssembly(typeof(RunPrivacyJobs).Assembly). Without it, start-up logs a warning (PrivacyJobsWolverineCheck, added by Hosting's AddPrivacy, or services.AddPrivacyJobsWolverineCheck()).
services.AddPrivacyJobsSchedule(o => o.Interval = TimeSpan.FromHours(1)) In the process, for a long-running host. Each run takes a PostgreSQL advisory lock per application database (pg_try_advisory_lock(hashtext('bcc_privacy_job:' \|\| current_database()))), so two instances never run at once; an instance that finds it taken skips that run and logs it.

On Cloud Run, use the endpoint and Cloud Scheduler, not the hosted service: instances scale to zero and are throttled between requests, so a timer in the process does not run reliably.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on BccCode.Privacy.Jobs:

Package Downloads
BccCode.Privacy.Hosting

One AddPrivacy() for BCC Privacy: the EF Core, ASP.NET Core and Wolverine packages wired together, defaults per environment, the privacy document at /.well-known/bcc-privacy, and the application's processes and data items pushed to the Privacy API at deploy.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.27.1 0 11/24/2026
0.27.0 0 11/24/2026
0.26.0 0 11/24/2026
0.25.1 0 11/24/2026
0.25.0 7 11/24/2026
0.24.0 9 11/24/2026
0.23.6 8 11/24/2026
0.23.5 9 11/24/2026
0.23.4 10 11/24/2026
0.23.3 45 11/24/2026
0.23.2 56 11/24/2026
0.23.1 49 11/24/2026
0.23.0 45 11/24/2026
0.22.0 47 11/24/2026