Skip to content

Optimize HEAD export generation using previous export plus updated resources diff #2572

Description

@filiperochalopes

User story

As a CIEL Lab maintainer, I want HEAD exports to be generated faster by reusing the previous HEAD export and applying only changed resources so nightly jobs and manual test refreshes do not depend on a full export processing every time.

Use case

CIEL Lab currently uses HEAD export to populate/update its local data in a nightly job. In staging/production, generating a HEAD export can take at least ~2 hours, which creates a bottleneck when the refresh must be triggered manually multiple times during testing.

Requirements

  • Optimize HEAD export generation by building from the previous HEAD export when possible.
  • Use the existing export content as the cold data baseline.
  • Detect whether HEAD changed since the previous export.
  • Reuse IDs, timestamps, and checksums already present in the previous export.
  • Fetch only resources updated since the previous export timestamp using OCL API.
  • Apply changed concepts and mappings to the previous export content to generate a new HEAD export ZIP.
  • Preserve existing IDs and checksums correctly in the generated export.
  • Identify and document any missing OCL API capabilities needed to fetch changed resources efficiently.
  • Keep the current full HEAD export path as a fallback when no previous export exists or incremental generation is not possible.

Acceptance criteria

  • Given a previous HEAD export exists and HEAD has changed, when a new HEAD export is requested, then the system generates it by reusing the previous export and fetching only updated resources.
  • Given no previous HEAD export exists, when a HEAD export is requested, then the system falls back to the full export process.
  • Given updated concepts or mappings exist since the previous export, then the new export includes those updates.
  • Given unchanged resources exist in the previous export, then they are preserved without being rehydrated unnecessarily.
  • The optimized process is measurably faster than the current full HEAD export process for CIEL in staging/production.
  • Any API gaps required for efficient incremental export generation are documented as follow-up tasks.

If I had a webhook available, I could already handle some of these updates locally instead of depending on a refresh process based on the export file.

More details (collapsible)

Context

CIEL Lab currently uses HEAD export to populate local data through a nightly job. This creates a bottleneck, especially during testing when the refresh must be triggered manually more than once.

Recent observed timing:

  • staging HEAD export on 2026-05-31 01:44:06 UTC: 7218s
  • production/staging: currently at least ~2h
  • local environment: ~20min

Related permission improvements:

Slack reference:

Implementation direction discussed:

  • The first export remains expensive.
  • Subsequent exports should be generated from an existing export plus changed resources.
  • Timestamps, IDs, and checksums are already present in exports.
  • OCL API should be used to fetch resources updated since a timestamp.
  • Any gaps in the API should be handled as small follow-up enhancements.

Metadata

Metadata

Assignees

Labels

signal/large-scopeAffects multiple areas or systemsstage/triagedAI triage complete — scored and classifiedtype/featureNew or improved functionality

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions