# How Iteration Mode Manages Disclosure Revisions with Timestamped Versioning in Patent-Disclosure-Skill

> Discover how iteration mode manages disclosure revisions with timestamped versioning in patent-disclosure-skill. Explore the three-step workflow for immutable audit trails and accurate logging.

- Repository: [handsomestWei/patent-disclosure-skill](https://github.com/handsomestWei/patent-disclosure-skill)
- Tags: internals
- Published: 2026-09-02

---

**The patent-disclosure-skill implements a three-step iteration workflow: capture user intent in [`disclosure/iteration_context.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/disclosure/iteration_context.md), execute merge or correction via dedicated handlers, and log every revision with precise timestamps to create an immutable audit trail.**

The **iteration mode** in [handsomestWei/patent-disclosure-skill](https://github.com/handsomestWei/patent-disclosure-skill) provides a non-destructive way to extend or correct patent disclosure documents while preserving complete revision history. Built around explicit intent capture and timestamped versioning, this system ensures no draft is ever overwritten and every change remains traceable.

## Core Components of the Iteration Workflow

The iteration mode operates through three coordinated stages, each defined by specific files in the repository.

### Step 1: Capture Intent in iteration_context.md

All user modifications begin with a structured record of intent. The file [`prompts/disclosure/iteration_context.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/prompts/disclosure/iteration_context.md) stores the user's request, the path to the current source draft, and any contextual notes.

This explicit capture prevents ambiguous changes and gives the merge/correction handlers a clear directive. According to the skill's documentation in [`SKILL.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/SKILL.md), this step is mandatory: the iteration workflow always starts with [`disclosure/iteration_context.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/disclosure/iteration_context.md) before any processing occurs.

### Step 2: Execute Merge or Correction with Timestamped Output

Depending on the nature of the request, one of two handlers processes the change:

- **[`merger.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/merger.md)** ([`prompts/disclosure/merger.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/prompts/disclosure/merger.md)): Adds new material to the existing draft
- **[`correction_handler.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/correction_handler.md)** ([`prompts/disclosure/correction_handler.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/prompts/disclosure/correction_handler.md)): Fixes errors in the current draft

Both handlers read [`iteration_context.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/iteration_context.md), perform the appropriate operation on the *current* draft, and **save a completely new file** with a timestamped filename. The naming convention follows the pattern:

```

案件名_YYYYMMDDHHmmss.md
案件名_YYYYMMDDHHmmss.docx

```

For example: [`MyPatentCase_20240615123000.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/MyPatentCase_20240615123000.md)

This guarantees **immutable versioning** — no previous file is ever overwritten, and every revision exists as a distinct artifact.

### Step 3: Log the Revision with Dual Timestamps

After the new draft is written, [`tools/shared/iteration_dialog_log.py`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/tools/shared/iteration_dialog_log.py) appends an entry to `交底书修订对话记录.md` in the case folder.

Each log entry contains:

- **Local time** and **UTC** timestamps
- A summary of the user's instruction
- The name of the newly saved draft
- A brief excerpt of the merge or correction result

This creates a reversible audit trail that chronicles the complete evolution of the disclosure document.

## Practical Usage Example

```bash

# 1. Record the iteration intent

echo "Add new experimental data to Chapter 3" >> disclosure/iteration_context.md

# 2. Run the merge handler

python -m tools.shared.merger \
    --case MyPatentCase \
    --context disclosure/iteration_context.md

# Creates: MyPatentCase_20240615123000.md and .docx

# 3. Log the revision (typically auto-invoked by the handler)

python tools/shared/iteration_dialog_log.py --kind merge \
    --case MyPatentCase \
    --new-file MyPatentCase_20240615123000.md

```

**For corrections**, substitute `correction_handler` for `merger` and use `--kind correct` when invoking the logger.

## Key Files Supporting Iteration Mode

| File | Role |
|------|------|
| [`prompts/disclosure/iteration_context.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/prompts/disclosure/iteration_context.md) | Stores user-level iteration instructions and current draft reference |
| [`prompts/disclosure/merger.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/prompts/disclosure/merger.md) | Logic for merging new material into the current draft |
| [`prompts/disclosure/correction_handler.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/prompts/disclosure/correction_handler.md) | Logic for correcting errors in the current draft |
| [`tools/shared/iteration_dialog_log.py`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/tools/shared/iteration_dialog_log.py) | Appends timestamped entries to `交底书修订对话记录.md` |
| [`SKILL.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/SKILL.md) | High-level workflow documentation |

## Design Guarantees of Timestamped Versioning

The iteration mode architecture ensures three critical properties:

- **Explicit intent capture** — Every change is first recorded in structured form before execution
- **Immutable versioning** — Timestamped filenames (`YYYYMMDDHHmmss`) prevent any overwrite of prior drafts
- **Traceable history** — The dialogue log provides a complete, time-ordered record with both local and UTC timestamps

As implemented in handsomestWei/patent-disclosure-skill, this system transforms patent disclosure iteration from a risky overwrite operation into a fully auditable, reversible process.

## Summary

- **Three-step workflow**: intent capture ([`iteration_context.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/iteration_context.md)) → merge/correction execution → revision logging
- **Non-destructive saving**: Every revision receives a unique timestamped filename; originals remain intact
- **Dual-timezone logging**: [`iteration_dialog_log.py`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/iteration_dialog_log.py) records both local and UTC timestamps for audit precision
- **Handler specialization**: [`merger.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/merger.md) handles additions, [`correction_handler.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/correction_handler.md) handles fixes
- **Complete traceability**: The `交底书修订对话记录.md` log enables full reconstruction of document evolution

## Frequently Asked Questions

### What prevents a user from accidentally overwriting a previous disclosure draft?

The timestamped versioning system in [`merger.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/merger.md) and [`correction_handler.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/correction_handler.md) automatically appends `YYYYMMDDHHmmss` to every output filename. No configuration allows in-place modification — the code explicitly creates new files, making accidental overwrites impossible.

### How does the system handle both additions and corrections in iteration mode?

Two specialized handlers provide dedicated paths: **[`merger.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/merger.md)** ([`prompts/disclosure/merger.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/prompts/disclosure/merger.md)) for adding new material, and **[`correction_handler.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/correction_handler.md)** ([`prompts/disclosure/correction_handler.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/prompts/disclosure/correction_handler.md)) for fixing errors. Both consume the same [`iteration_context.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/iteration_context.md) format but apply different transformation logic to the source draft.

### Can I reconstruct the complete history of a disclosure document from the logs alone?

Yes. The `交底书修订对话记录.md` file contains sequential entries with UTC timestamps, user instructions, output filenames, and content excerpts. By following the log chronologically and retrieving each referenced timestamped file, you can fully reconstruct the document's evolution.

### Why does iteration_dialog_log.py record both local time and UTC?

Dual timestamps ensure **audit reliability across time zones** and daylight saving transitions. The UTC timestamp provides an unambiguous absolute reference, while local time preserves user-contextual understanding of when changes occurred.