Rebuild Retrieval Pyramid CLI
Module: aibs_backend.interfaces.cli.rebuild_retrieval_pyramid
Purpose
Rebuild or validate retrieval projection indexes:
document profile index:
AIBS_DOCUMENT_PROFILE_INDEXsection/table summary index:
AIBS_SECTION_SUMMARY_INDEX
This CLI is a projection repair tool. It reads persisted documents and writes OpenSearch read models. It does not create semantic profiles. Run backfill_semantic_profiles.md first when old documents have missing, legacy, or unavailable semantic profiles.
Command
pdm run python -m aibs_backend.interfaces.cli.rebuild_retrieval_pyramid \
[--workspace <uuid>] [--document <uuid>] [--batch-size 200] \
[--dry-run|--validate-only] [--recreate] [--only-missing] \
[--profile-version N]
or:
python -m aibs_backend.interfaces.cli.rebuild_retrieval_pyramid \
[--workspace <uuid>] [--document <uuid>] [--batch-size 200] \
[--dry-run|--validate-only] [--recreate] [--only-missing] \
[--profile-version N]
Options
Option |
Meaning |
|---|---|
|
Rebuild one workspace. Omit to process all workspaces. |
|
Repair or validate one document’s profile/summary projections inside |
|
Batch size, clamped to |
|
Validate/count without OpenSearch writes. |
|
Alias for read-only validation. |
|
Drop and recreate both retrieval projection indexes. |
|
Skip documents that already have current profile rows. |
|
Rebuild only documents whose chunk policy major version differs from this value. |
Invalid combinations:
--documentwithout--workspace--recreatewith--workspace--recreatewith--document--recreatewith--dry-runor--validate-only--recreatewith--only-missing--only-missingwith--profile-version--profile-version <= 0
Execution Flow
Validate arguments and optional workspace/document IDs.
Build the application container from
.env.Resolve
document_projection_maintenance.rebuild_retrieval_pyramid_index.Run validation mode or rebuild mode.
Refresh written indexes.
Print a report.
What Gets Projected
The document profile index projects planner/retrieval fields from the persisted document identity profile, including source title, aboutness, language, semantic profile facets, and completeness/confidence fields.
The section/table summary index projects section and table summaries used for retrieval and evidence localization.
Only knowledge-active documents are indexed.
Report Fields
Validation reports include expected/projected/matched/missing/stale profile counts, semantic/source-truth completeness counts, summary counts, schema versions, and recreate requirements.
Rebuild reports include deleted, indexed, skipped-existing, skipped-current-version, and recreate flags.
Schema Upgrade
Current schemas:
document profile index:
7section/table summary index:
1
When a deployed retrieval projection index is older than the current schema, run an unscoped recreate rebuild:
pdm run python -m aibs_backend.interfaces.cli.rebuild_retrieval_pyramid --recreate
pdm run python -m aibs_backend.interfaces.cli.rebuild_retrieval_pyramid --validate-only
Do not pass --workspace for schema recreation. The retrieval projection indexes
are shared.
Operating Notes
Run semantic profile backfill first for documents missing current semantic profiles.
Use
--profile-versionafter chunk policy changes when a full recreate is not required.Use
--workspace <uuid> --document <uuid>for one-document profile/summary repair after a single ingestion or delete issue. This reprojects or removes only that document’s retrieval rows and does not certify the whole workspace.Use
--only-missingfor outage repair when schema is current and stale rows are not the problem.In multi-process or multi-box deployments, set
AIBS_COORDINATION_BACKEND=redisorvalkeyso projection maintenance and API processes share the same repair/dirty-state coordination boundary.