A procedure should be registered once without making every project inherit every later edit. I built an independent example that separates taking an initial catalog snapshot from modifying a project-owned definition. It operates entirely in memory so the preservation rule can be examined before adding files or execution.
One registration, separately retained project state
Register adds a textual procedure under one catalog identity and rejects duplicate registration. Synchronize imports only entries absent from a project. Calling it again does not overwrite existing definitions. That differs from keeping one shared mutable reference under several project names.
Each snapshot stores source, current hash and its initial base hash. The local-modification flag compares against that original project snapshot, not the present catalog version. Mixing those comparisons would make a catalog update look like a local edit. The example retains the comparison baseline explicitly instead of leaving readers to infer it.
A catalog update does not automatically promote old snapshots
Catalog update requires the expected old digest to match the current catalog before storing new text. A newly synchronized project then receives the new definition, while existing projects retain their earlier snapshots. There is no background propagation or global promotion button in this example.
Preservation has a cost: old versions can remain in use. Production operations need version visibility, reasons for changes and project-specific review status. Automatically overwriting snapshots for convenience would defeat the preservation contract. Distributing an available update and applying it to an established project therefore remain separate decisions.
Compare the present definition before editing or reusing it
Edit accepts project, procedure identity, replacement text and expected digest. A concurrent change makes that expectation stale and is rejected rather than overwritten by an edit prepared from an older view. Inspection returns a separate flat dictionary whose immutable values cannot mutate the internal record.
Require-current also checks only equality with the retained snapshot. Its result always says that no execution occurred here. Supplying a digest does not prove a human actually reviewed or authorized the definition. An adapter must retain who examined which content and what they permitted; this small comparison cannot manufacture that evidence.
Explore the implementation
Complete independent synthetic implementation
"""Independent in-memory example of catalog registration and project snapshots."""
from hashlib import sha256
from threading import RLock
import re
class DefinitionError(ValueError):pass
def label(value):
if not isinstance(value,str) or not re.fullmatch(r'[A-Za-z0-9][A-Za-z0-9._-]{0,79}',value):raise DefinitionError('INVALID_LABEL')
def digest(source):
if not isinstance(source,str) or not source.strip() or len(source)>64000:raise DefinitionError('INVALID_SOURCE')
return sha256(source.encode('utf-8')).hexdigest()
class DefinitionStore:
def __init__(self):
self._lock=RLock()
self._catalog={}
self._projects={}
def register(self,identifier,source):
label(identifier);hash_=digest(source)
with self._lock:
if identifier in self._catalog:raise DefinitionError('ALREADY_REGISTERED')
self._catalog[identifier]={'source':source,'hash':hash_}
return hash_
def update_catalog(self,identifier,source,expected_hash):
label(identifier);hash_=digest(source)
with self._lock:
current=self._catalog.get(identifier)
if not current:raise DefinitionError('CATALOG_NOT_FOUND')
if current['hash']!=expected_hash:raise DefinitionError('CATALOG_CHANGED')
self._catalog[identifier]={'source':source,'hash':hash_}
return hash_
def synchronize(self,project):
label(project)
with self._lock:
local=self._projects.setdefault(project,{})
created=[]
for identifier,entry in self._catalog.items():
if identifier in local:continue
local[identifier]={**entry,'base_hash':entry['hash']}
created.append(identifier)
return created
def _entry(self,project,identifier):
label(project);label(identifier)
entry=self._projects.get(project,{}).get(identifier)
if not entry:raise DefinitionError('SNAPSHOT_NOT_FOUND')
return entry
def inspect(self,project,identifier):
with self._lock:
entry=self._entry(project,identifier)
return {'project':project,'identifier':identifier,**entry,
'locally_modified':entry['hash']!=entry['base_hash'],
'executed_here':False}
def edit(self,project,identifier,source,expected_hash):
hash_=digest(source)
with self._lock:
entry=self._entry(project,identifier)
if entry['hash']!=expected_hash:raise DefinitionError('SNAPSHOT_CHANGED')
entry.update(source=source,hash=hash_)
return self.inspect(project,identifier)
def require_current(self,project,identifier,expected_hash):
with self._lock:
entry=self._entry(project,identifier)
if entry['hash']!=expected_hash:raise DefinitionError('SNAPSHOT_CHANGED')
return self.inspect(project,identifier)
Detect exact text changes rather than guessing equivalent meaning
The digest is SHA-256 over exact UTF-8 text, including whitespace and line endings. Different newline forms have different digests; similar meaning is not guessed into equality. Source must be a nonempty bounded string, and project and procedure labels follow a restricted short identifier format.
Twenty-one tests cover registration, first synchronization, independent local edits, preserved old snapshots, new catalog versions for new projects and stale changes. Eight concurrent threads must create only one initial snapshot. The lock protects metadata in one manager instance; it does not solve competition between processes writing a shared persistent store.
Compare retained definitions through five generated records
The examples retain two initial snapshots, an isolated edit, the difference between old and newly created projects after a catalog update, rejection of an old digest and a matching definition with no execution. The viewer displays synthetic records generated by local Python, without reading or editing a visitor project.
The ZIP is extracted separately, compared with source hashes and tested with the same twenty-one cases. Both language record selectors are checked with DOM stubs. Those checks are distinct from rerunning the original application or inspecting a current service screen. Digests in the records identify retained text, not successful work.
A real file deployment needs an additional storage contract
The original browser uses file-backed project definitions and copies the manifest last as a completion marker. This synthetic module implements no folders, manifest, filesystem atomicity or crash recovery. It extracts the registration and preservation decision rather than serving as a production program replacement tool.
Full code, tests, record generation and README are available for modification and reuse. Operational integration needs durable storage, authentication, definition validation, trust or signature checks, activation state and change history. Matching bytes do not establish safe or correct content. Preserving independent edits and granting execution authority remain different contracts.