﻿LOGIC OR NOT — Seguimiento de cambios en un documento
Monitor Runtime — v0.1.1
Canonical Product Key: SP-GEN:P071
Governance Class: GOV-TEMPORAL
Modifiers: PERSISTENT_STATE | TOOL_REQUIRED


PURPOSE
Observar un documento autoritativo identificable a lo largo del tiempo, distinguir cambios de identidad/metadata/formato/contenido/semántica, alertar sólo deltas materiales y preservar un baseline trazable sin confundir la última observación con una versión adoptada.


RUN TRANSACTION
1. Load exact MONITOR_CONFIG + MONITOR_STATE.
2. Capture config_revision, expected_state_revision and baseline_revision.
3. Verify task/trigger/delivery, document identity and retrieval route.
4. Retrieve the configured document and record source_revision_ref + observed_at.
5. Validate identity_match before comparing.
6. Produce enabled diff layers: EXACT_TEXT, STRUCTURAL and/or SEMANTIC.
7. Classify each change record by type and materiality.
8. Separate DOCUMENT_REPLACED / SOURCE_METADATA_CHANGE / FORMAT_ONLY / CONTENT_CHANGE / SEMANTIC_CHANGE.
9. Compute change_fingerprint for each material delta.
10. Decide alert/silence/failure.
11. Prepare runtime-state delta.
12. Recheck expected_state_revision before write; mismatch => WRITE_CONFLICT.
13. Write once/read back.
14. Baseline replacement follows configured policy/authority only.


DOCUMENT IDENTITY
document_id/canonical_locator is stable identity. Title/path/filename alone is insufficient when a stronger ID exists.
If retrieved object identity differs from configured identity, run_status = DOCUMENT_IDENTITY_MISMATCH unless replacement was explicitly authorized.
A moved/renamed document with same stable ID is metadata/config context, not automatically content change.


DIFF SEMANTICS
EXACT_TEXT: lexical/textual change.
STRUCTURAL: headings/sections/tables/order/schema/layout structure where observable.
SEMANTIC: meaning-level change to facts, obligations, decisions, requirements, numbers, dates, modality, uncertainty, attribution or operational interpretation.
FORMAT_ONLY never escalates to semantic change without evidence.
SEMANTIC diff must retain source locators and before/after statements.


RUN STATUS
SUCCESS_NO_MATERIAL_CHANGE
SUCCESS_MATERIAL_CHANGE
FORMAT_ONLY_CHANGE
SOURCE_METADATA_CHANGE
DOCUMENT_IDENTITY_MISMATCH
PARTIAL_SOURCE_FAILURE
SOURCE_FAILURE
NOT_CONFIGURED
BLOCKED
WRITE_CONFLICT


BASELINE
baseline_current records document identity + source_revision_ref + baseline snapshot/fingerprints + authority/effective_at.
A successful observation may yield baseline_candidate. Replace baseline_current only per baseline_update_policy/authority.
Preserve baseline_history; do not rewrite prior diffs after baseline change.


SILENCE / FAILURE
Silence only after successful retrieval, identity match and all diff layers required by config complete with no material delta.
Partial/unavailable diff layer must surface a bounded failure/coverage receipt if it affects conclusion.


WRITEBACK
Runtime state only. If no direct write access, return DELTA_TO_APPLY with expected_state_revision.
This monitor does not alter the source document unless a separate authorized editing product/surface governs that action.


OUTPUT
run_id; document identity/revision; diff coverage; material change records; evidence/locators; change_fingerprint; baseline/writeback result; limits/conflicts.
