Skip to content

feat(assets): static asset cache optimizer, sri fingerprinter, and compression profiler - #34

Merged
ATLURI0001 merged 1 commit into
mainfrom
feat/static-asset-pipeline-sri-and-compression
Nov 21, 2026
Merged

ATLURI0001 merged 1 commit into
mainfrom
feat/static-asset-pipeline-sri-and-compression

Conversation

@ATLURI0001

Copy link
Copy Markdown
Owner

Architecture Topology & System Design

+---------------------------------------------------------------------------------+
|                   BuildSite Static Asset Compilation Pipeline                   |
+---------------------------------------------------------------------------------+
                                         |
                            [Raw Artifacts Map: Path -> Bytes]
                                         |
                                         v
                           +----------------------------+
                           |       AssetPipeline        |
                           +----------------------------+
                             /           |            \
                            /            |             \
                           v             v              v
        +---------------------+  +-----------------+  +----------------------+
        | 8-Char SHA-256 Hash |  |  W3C SHA-384    |  | Byte Shannon Entropy |
        | Content Addressable |  |  Subresource    |  | & Gzip Efficiency    |
        | Filename Generator  |  |  Integrity (SRI)|  | Compression Profiler |
        +---------------------+  +-----------------+  +----------------------+
                           \             |             /
                            \            |            /
                             v           v           v
                           +----------------------------+
                           | Production Asset Manifest  |
                           |  (Immutable Cache Headers) |
                           +----------------------------+

Problem Statement & Architectural Motivation

Modern web delivery requires static assets to be cached indefinitely via CDN edge points (Cache-Control: public, max-age=31536000, immutable). To guarantee fresh updates without cache poisoning, assets must incorporate cryptographic content digests directly into filenames. Concurrently, security standards require W3C Subresource Integrity (SRI) hashes to prevent CDN supply chain tampering, alongside pre-compression profiling.

Diagnostic & Mathematical Formulation

  1. Content-Addressable Slug Generation:
    $$\text{Digest}_8 = \text{hex}(\text{SHA256}(\text{data}))[0:8]$$
    Transforms assets/app.js $\to$ assets/app.<digest8>.js.

  2. W3C Subresource Integrity (SRI):
    $$\text{SRI} = \text{"sha384-"} \mathbin{\Vert} \text{Base64}(\text{SHA384}(\text{data}))$$

  3. Byte Shannon Entropy & Compression Savings:
    $$H(B) = -\sum_{i=0}^{255} p(b_i) \log_2(p(b_i))$$
    $$\text{SavingsRatio} = 1.0 - \frac{S_{\text{gzip}}}{S_{\text{raw}}}$$
    Assets with $\text{SavingsRatio} \ge 0.15$ are flagged is_compressible: true.

  4. Traversal Security Guard:
    Relative paths are verified using PurePosixPath; any parent directory breakouts (..) or absolute paths (/) are rejected with ValueError.

Component Verification & Telemetry

  • src/buildsite/asset_pipeline.py: Complete implementation of AssetPipeline.
  • tests/test_asset_pipeline.py: 6 automated tests verifying deterministic fingerprinting, traversal blocks, SRI format, entropy calculation, and manifest generation.
  • Test pass rate: 100% (6/6 tests passing in 0.26s; full 75/75 suite green).

@ATLURI0001
ATLURI0001 merged commit 55ad41a into main Nov 21, 2026
9 checks passed
@ATLURI0001
ATLURI0001 deleted the feat/static-asset-pipeline-sri-and-compression branch November 21, 2026 01:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant