app.services.seed_synthetic¶
Synthetic dataset seeding for benchmarking (adriano seed-synthetic).
A twelve-factor “admin process”: a one-off command that shares the
app’s code and config, run against a throwaway dev/bench database. It
generates a deterministic synthetic ADR corpus
(app.services.seed_synthetic_gen) and ingests it through the
same shared path poll and push use
(app.services.ingest.prepare_document(),
app.services.ingest.ingest_document()), under
lock_registration(), in
batches – never raw SQL. Decision events are appended directly
through the store port
(append_decision()) for a share
of identities, using a synthetic reviewer identity and the configured
(or a documented fallback) policy id/version.
The target registration must already be configured in catalog.yaml
(see bench/catalog.bench.yaml: a filesystem registration whose
root never needs to exist, because seeding never calls the
adapter – it writes rows directly through the store port, the same
way the push intake path never calls an adapter either).
seed_catalog() syncs registrations itself, exactly like
adriano poll.
Safety: refuses to run against a database whose name does not look
like a dev/test/bench database unless the caller passes force=True
(see looks_like_dev_database()); the CLI wires this to
--force.
Public API: SeedConfig, SeedSummary,
DEFAULT_BATCH_SIZE, SYNTHETIC_REVIEWER_ISSUER,
SYNTHETIC_REVIEWER_SUBJECT, looks_like_dev_database(),
resolve_source(), seed_catalog().
- app.services.seed_synthetic.DEFAULT_BATCH_SIZE = 500¶
Documents (or decisions) ingested per unit of work.
- app.services.seed_synthetic.SYNTHETIC_REVIEWER_ISSUER = 'adriano-synthetic'¶
Identity asserted for seeded decision events. Never a real token’s issuer/subject, so it can never collide with an actual reviewer.
- class app.services.seed_synthetic.SeedConfig(*, records, projects, source_id, seed=42, candidates_ratio=0.1, decisions_ratio=0.3, batch_size=500)¶
Bases:
objectParameters of one seeding run.
- Parameters:
records (
int) – Number of published records to generate.projects (
int) – Number of projects to spread them across.source_id (
str) – Target registration id (must be configured and enabled in the loadedcatalog.yaml).seed (
int) – Random seed; a run is fully determined by(records, projects, source_id, seed, candidates_ratio, decisions_ratio).candidates_ratio (
float) – Share of identities that also get a competing candidate row.decisions_ratio (
float) – Share of identities that get an accept/reject decision event.batch_size (
int) – Documents/decisions per database transaction.
- class app.services.seed_synthetic.SeedSummary(*, published, candidates, decisions)¶
Bases:
objectOutcome of one seeding run.
- Parameters:
- app.services.seed_synthetic.looks_like_dev_database(database_url)¶
Heuristically tell whether a database looks safe to seed.
- app.services.seed_synthetic.resolve_source(config, source_id)¶
Find the enabled registration seeding will write to.
- Parameters:
config (
CatalogConfig) – Loaded catalog configuration.source_id (
str) – Requested registration id.
- Return type:
- Returns:
The registration.
- Raises:
ValueError – If it is not configured or disabled.
- app.services.seed_synthetic.seed_catalog(provider, config, seed_config, *, progress=None)¶
Generate and ingest a deterministic synthetic ADR corpus.
- Parameters:
provider (
CatalogStoreProvider) – Storage provider for the target database.config (
CatalogConfig) – Loaded catalog configuration; thesource_idof seed_config must be one of its enabled registrations.seed_config (
SeedConfig) – Generation and batching parameters.progress (
Callable[[str],None] |None) – Called with a short status line after each batch and generation step; defaults to a no-op.
- Return type:
- Returns:
Counts of what was written.
- Raises:
ValueError – If the source is not configured or disabled.