OpenZeppelin / OpenZeppelin/compact-tools

Artifact Structure Mismatch Detection

Open
#41 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

  • #42 by @0xisk — closed without merging
Dominant language
TypeScript
Stars
4
Forks
5
Avg merge
15h 28m
Merged PRs (30d)
31

Description

Problem

When switching between --hierarchical and flattened (default) artifact structures, stale artifacts from the previous structure remain in the output directory:

# First compile (flattened)
compact-compiler
# artifacts/AccessControl/
# artifacts/Token/

# Later, switch to hierarchical
compact-compiler --hierarchical
# artifacts/AccessControl/        ← STALE
# artifacts/Token/                ← STALE
# artifacts/access/AccessControl/ ← current
# artifacts/token/Token/          ← current

This can cause:

  • Import confusion (wrong artifact path)
  • Inflated artifact directory size
  • Test failures from stale artifacts
Proposed Solution
  1. Artifact manifest file (.compact-manifest.json) in the output directory:

    {
      "structure": "flattened",
      "toolchainVersion": "0.26.0",
      "createdAt": "2025-12-11T15:30:00Z",
      "artifacts": ["AccessControl", "Token"]
    }
    
  2. Structure mismatch detection: On compile, read the manifest and compare with current options.

  3. Interactive prompt when structure differs:

    ⚠ [COMPILE] Existing artifacts use "flattened" structure.
    ⚠ [COMPILE] You are compiling with "hierarchical" structure.
    ? Delete existing artifacts and recompile? (y/N)
    
  4. Non-interactive mode: Add --force flag to auto-confirm deletion (for CI/CD).

  5. Same structure = no prompt: If structure matches, proceed normally (overwrite in-place).

Implementation
Component Changes
types/manifest.ts New ArtifactManifest interface
Compiler.ts Read/write manifest, detect mismatch
parseArgs Add --force flag
runCompiler.ts Handle interactive prompt (readline)
Tests Manifest read/write, mismatch detection, prompt behavior
README Document new behavior and --force flag

Originally posted by @andrew-fleming in https://github.com/OpenZeppelin/compact-tools/pull/27#discussion_r2607997472

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading types/manifest.ts, Compiler.ts, parseArgs, and runCompiler.ts to trace artifact output and argument handling. Review the existing tests and README sections related to compilation and options before defining the manifest and prompt behavior. Done means structure mismatches are detected, interactive and --force flows are covered by tests, and the new behavior is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
build-system, cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.