Hashes in LogicStamp
LogicStamp uses three complementary hash types to track file changes, semantic changes, and bundle-level changes:fileHash, semanticHash, and bundleHash.
📄 fileHash: Raw File Content Hash
Answers: “Did the raw source file change?”
fileHash is a hash of the normalized file contents and is used as a lock to ensure that a stored contract still reflects the actual file on disk.
How it is computed
- Take the raw file contents.
- Strip the
@uifmetadata header block. - Normalize line endings (
\r\n → \n). - SHA-256 hash the text.
- Truncate to 24 hex characters.
- Prefix with
uif:.
Example: uif:1f0fa0e2c8958d7fc1696036
What changes / does not change it
Changes fileHash
- Any code change
- Comment changes
- Formatting or whitespace changes
- Structural edits
- Line ending differences (after normalization)
Does not change fileHash
- Editing only the
@uifheader - Purely changing metadata outside the hashed body
Use when: you want strict detection of any file content modification, even if it is purely cosmetic.
🧠 semanticHash: Logical / Contract Hash
Answers: “Did the component’s semantics or public API change?”
semanticHash tracks meaningful changes only—ignoring superficial edits like comments or formatting.
Based on AST structure and logic signature
LogicStamp derives semanticHash from:
- Structural footprint:
- variables
- hooks
- components
- functions
- Logic signature:
- props
- emits/events
- state
- A stable
schemaVersion(e.g.,"0.3").
All arrays/objects are sorted deterministically via stableStringify and sortObject to make the hash order-independent.
How it is computed
- Extract AST structure and logic signature.
- Build payload:
{
"schemaVersion": "0.3",
"structure": { "...": "..." },
"signature": { "...": "..." }
}- Stable-stringify the payload and compute SHA-256.
- Truncate to 24 hex characters.
- Prefix with
uif:.
What changes semanticHash
- Adding/removing/renaming props
- Changing events (emits)
- Changing state structure
- Adding/removing named functions, hooks, or child components
- Any structural AST shift that affects the contract shape
What does not change it
- Comments
- Whitespace or formatting
- Most implementation details inside functions
- Internal refactors that do not affect:
- props
- events
- state
- component/hook/function footprint
🗂 bundleHash: LLM Bundle Hash
Answers: “Has the entire context bundle changed?”
bundleHash is used for caching embeddings and prepared LLM contexts. It summarizes the semantic footprint of an entire bundle.
Based on
A bundle’s hash includes:
- Sorted list of nodes (by
entryId):
{
"schemaVersion": "0.1",
"depth": 1,
"nodes": [
{ "entryId": "src/Button.tsx", "semanticHash": "uif:..." },
{ "entryId": "src/Card.tsx", "semanticHash": "uif:..." }
]
}- Bundle depth
- Bundle
schemaVersion(default"0.1")
How it is computed
- Build the bundle payload (schemaVersion, depth, sorted nodes).
- Stable-stringify the payload.
- Compute SHA-256.
- Truncate to 24 hex characters.
- Prefix with
uifb:.
Example: uifb:abc123e4f99aa01deef02bb1
What changes bundleHash
- Any component’s
semanticHashchanged - Adding/removing a component from the bundle
- Different bundle depth
- Different bundle schema version
What does not change it
- Cosmetic file edits that keep all
semanticHashvalues identical - Reordering components in memory (sorting by
entryIdensures stability)
🧬 Relationship Between All Three Hashes
Think of the three hashes as layers of change detection:
| Layer | Hash | Detects |
|---|---|---|
| File-level | fileHash | Any file content modification |
| Component-level | semanticHash | Logic & public API changes only |
| Bundle-level | bundleHash | Changes in the semantic footprint of a context bundle |
🔎 Practical Scenarios
1. Only comments / formatting change
fileHash: changessemanticHash: stays the samebundleHash: stays the same
→ Cosmetic edit.
2. A prop or state field is added
fileHash: changessemanticHash: changesbundleHash: changes for all bundles involving that component
→ Meaningful contract change.
3. Dependency graph changes (component import added/removed)
semanticHash: may stay the same (if contracts are unchanged)bundleHash: changes, because the node set changed
→ Bundle must be regenerated or recached for LLM use.