Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 24 additions & 29 deletions .replworks/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ Task Ledger Reader and Unverified Mark Scanner → Document Line Classifier
- Recognize the command and its options.
- Reject an unknown command or option before any coordinator runs.
- Resolve the base branch name for check (the given value, otherwise the default defined in PRODUCT_SPEC.md).
- For init and sync, prompt for and validate the selected published AGENTS.md document.
- Use the single canonical AGENTS.md source for init and sync without reading stdin.
- Produce assistance output (usage help and similar) itself, without a coordinator.
- Render each Outcome into output lines.
- Apply presentation colors to sync difference lines only when the output writer is a terminal.
- Map each Outcome to an exit status.
- Inputs: command-line arguments and, for init, the user's document selection.
- Inputs: command-line arguments.
- Outputs: output lines, exit status, one Request to one Coordinator.
- Ownership boundaries:
- Owns all printed text, line layout, line order, and the exit status.
Expand All @@ -81,15 +81,14 @@ Task Ledger Reader and Unverified Mark Scanner → Document Line Classifier
### C2. Init Coordinator

- Responsibilities:
- Obtain the Canonical Text for the selected init document first.
- When automatic-run is selected, obtain Helper Script Text before any write.
- Obtain the Canonical Text and Helper Script Text before any write.
- Make no write when required source text is `Failed`.
- Process items in this order: AGENTS.md, then the `.replworks/` directory, then `.replworks/PRODUCT_SPEC.md`, `.replworks/TECH_STACK.md`, `.replworks/ARCHITECTURE.md`, `.replworks/TASKS.md`, then the helper-script state.
- Mark an item `skipped` when it is present. Otherwise create it (AGENTS.md with the Canonical Text, the directory, and each document as an empty file).
- For standard selection, remove an existing helper script. For automatic-run selection, create the helper-script directory and file only when absent; never replace an existing helper script, and ensure the helper script has execute permission.
- Create the helper-script directory when absent, replace the helper script with Helper Script Text whether absent or present, and ensure it has execute permission.
- Stop at the first write failure.
- Inputs: Request with the selected document source, Canonical Text fact, optional Helper Script Text fact, and Workspace presence facts.
- Outputs: Outcome with one `(item path, created | skipped)` entry per processed item, and execution errors.
- Inputs: Request with the canonical document source, Canonical Text fact, Helper Script Text fact, and Workspace presence facts.
- Outputs: Outcome with one `(item path, created | skipped | replaced)` entry per processed item, and execution errors.
- Ownership boundaries:
- Owns the item order and the created/skipped decision.
- Does not perform I/O itself, print, or compare content.
Expand Down Expand Up @@ -131,13 +130,14 @@ Task Ledger Reader and Unverified Mark Scanner → Document Line Classifier

- Responsibilities:
- Read the local AGENTS.md fact first. Record an execution error and stop when it is `Absent` or `Failed`.
- Only after that, obtain the Canonical Text for the selected sync document. Record an execution error and stop when it is `Failed`.
- Only after that, obtain the Canonical Text. Record an execution error and stop when it is `Failed`.
- Compare local text and Canonical Text for exact equality.
- When equal: return `UpToDate` and make no write.
- When different: obtain the difference from the Difference Calculator, obtain Helper Script Text only for automatic-run selection, then replace AGENTS.md and adjust helper-script state, including ensuring execute permission on the automatic-run helper script.
- When equal: mark `UpToDate` and make no AGENTS.md write.
- Obtain Helper Script Text for every sync after confirming AGENTS.md exists and the canonical AGENTS.md was retrieved.
- When different, obtain the difference and replace AGENTS.md. Whether AGENTS.md is equal or different, replace the helper script with Helper Script Text and ensure execute permission.
- When replacement fails: keep the computed difference in the Outcome and record an execution error.
- Inputs: Request with the selected document source, local AGENTS.md fact, Canonical Text fact, optional Helper Script Text fact, and helper-script presence fact.
- Outputs: Outcome with `UpToDate | Replaced(difference) | ReplaceFailed(difference)`, and execution errors.
- Inputs: Request with the canonical document source, local AGENTS.md fact, Canonical Text fact, Helper Script Text fact, and helper-script presence fact.
- Outputs: Outcome with AGENTS.md up-to-date/replaced state, optional difference, helper-script created/replaced state, and execution errors.
- Ownership boundaries:
- Owns the order of local check, retrieval, comparison, difference, replacement.
- Does not perform I/O itself, compute the difference itself, or print.
Expand All @@ -162,12 +162,12 @@ Task Ledger Reader and Unverified Mark Scanner → Document Line Classifier
### C7. Canonical Document Provider

- Responsibilities:
- Obtain Canonical Text from the source selected by the request, and Helper Script Text from its published source when requested. The allowed sources are those listed in PRODUCT_SPEC.md.
- Obtain Canonical Text from the source defined by PRODUCT_SPEC.md, and Helper Script Text from its published source when requested. The allowed sources are those listed in PRODUCT_SPEC.md.
- Return each text exactly as the source content, with no normalization.
- Retrieve each requested source at most once per invocation. Later requests in the same invocation reuse the first result, including a failure.
- Treat these as `Failed`: source unreachable, unsuccessful response, or an empty response from the source.
- Keep the source's representation private. Other components never see it.
- Inputs: a source selection and, when needed, the helper-script URL. Init and sync supply the user's selection; commands without a selection use PRODUCT_SPEC.md's default canonical document.
- Inputs: a canonical source and, when needed, the helper-script URL. Init, sync, and check use the canonical source defined in PRODUCT_SPEC.md.
- Outputs: `Present(text) | Failed(reason)`.
- Ownership boundaries:
- Owns all network access and the extraction of the Canonical Text.
Expand Down Expand Up @@ -321,11 +321,9 @@ Task Ledger Reader and Unverified Mark Scanner → Document Line Classifier

```text
Request → Init Coordinator
Command Interface → validated document selection
Canonical Document Provider(selection) → Canonical Text fact
[automatic-run] → Helper Script Text fact
Canonical Document Provider → Canonical Text fact + Helper Script Text fact
[Failed] → Outcome(error), no write
[Present] → Workspace presence and writes for the standard items and helper-script state
[Present] → Workspace presence and writes for standard items and replaced helper script
→ Outcome(items, errors) → Command Interface → lines + status
```

Expand Down Expand Up @@ -357,16 +355,14 @@ Request(base branch) → Check Coordinator
```text
Request → Sync Coordinator
Workspace Read(AGENTS.md) → fact
Command Interface → validated document selection
[Absent | Failed] → Outcome(error), no write
Canonical Document Provider(selection) → Canonical Text fact
Canonical Document Provider → Canonical Text fact
[Failed] → Outcome(error), no write
exact comparison
equal → Outcome(UpToDate)
different → Difference Calculator → difference
→ [automatic-run] Helper Script Text fact
→ Workspace Write: replace AGENTS.md and adjust helper-script state
→ Outcome(Replaced | ReplaceFailed, difference)
equal → Outcome(UpToDate) + Helper Script Text fact
different → Difference Calculator → difference + Helper Script Text fact
[both] → Workspace Write: replace helper script; when different, replace AGENTS.md
→ Outcome(UpToDate | Replaced | ReplaceFailed, difference, script state)
→ Command Interface → lines + status
```

Expand Down Expand Up @@ -405,7 +401,6 @@ Request → Sync Coordinator
| Failure | Detected by | Contained by | Effect |
| ------------------------------------------------------------- | ------------------------------------------- | ------------------ | ----------------------------------------------------------------------------------------------------------------------- |
| Unknown command or option | Command Interface | Command Interface | Error line, no coordinator runs, no file touched |
| Init or sync input ends or fails before a valid selection | Command Interface | Command Interface | Error line, exit 2, no coordinator runs, no file touched |
| Canonical Text cannot be obtained or extracted | Canonical Document Provider | Coordinator in use | init and sync: stop, no write. check: agents-canonical not evaluated, other rules still run |
| Project Directory not in a repository, or base branch missing | Base Branch Reader | Check Coordinator | task-ids-unchanged, single-task-completion, no-unverified not evaluated. documents-exist and agents-canonical still run |
| TASKS.md absent in working tree (check) | Project Workspace | Check Coordinator | Not an error. The three ledger-dependent rules are not evaluated |
Expand All @@ -430,7 +425,7 @@ Request → Sync Coordinator
- No rollback or transaction across multiple writes.
- No automatic repair of rule violations by check.
- No resolution or ranking of conflicts between documents.
- No interactive prompting during an invocation except the required document selection for init and sync.
- No interactive prompting during an invocation.
- No pluggable output renderers or alternative output encodings.

## 11. Architectural Invariants
Expand All @@ -441,7 +436,7 @@ Request → Sync Coordinator
- Every repository access is performed by the Base Branch Reader and is read-only.
- Every printed line and every exit status is produced by the Command Interface.
- Every violation is produced by the Rule Evaluator from facts, and every execution error from a `Failed` fact or failed write.
- The Canonical Text used within one invocation is always one single retrieved result from the selected or default source.
- The Canonical Text used within one invocation is always one single retrieved result from the canonical source.
- Rule evaluation order and output order are always the fixed orders defined here.
- Task Entry and Mark recognition always follow the single shared line and fence definition.
- No component retains information between invocations.
Expand All @@ -456,7 +451,7 @@ Each entry: ambiguity → decision → why.
- RD-04: Duplicate task IDs and "absent or incomplete on base" are ambiguous → entries are counted individually, and an ID is complete in base when any base entry with that ID is complete; task-ids-unchanged compares distinct IDs → keeps counts per entry (status totals) while keeping ID identity stable across branches.
- RD-05: Whether agents-canonical normalizes content is undefined → exact comparison with no normalization, also used by sync → confirmed by the user; matches "identical" in sync.
- RD-06: The canonical source's representation is not defined by this architecture → the Canonical Document Provider hides the response representation and returns the exact response text; "cannot be obtained" includes an unsuccessful response or unavailable response → source-specific representation handling stays inside the provider.
- RD-07: When the canonical text is retrieved is undefined → exactly once per invocation, using init's or sync's validated selection or the default document for check, and always attempted by init, sync (after the local check), and check → ERR-001 requires an error line from check in every case where retrieval fails, so retrieval cannot be skipped.
- RD-07: When the canonical text is retrieved is undefined → exactly once per invocation from the canonical source, and always attempted by init, sync (after the local check), and check → ERR-001 requires an error line from check in every case where retrieval fails, so retrieval cannot be skipped.
- RD-08: init may meet an existing AGENTS.md while the canonical text is unobtainable → init obtains the Canonical Text first and writes nothing on failure, even when AGENTS.md already exists → ERR-001 applies unconditionally to init.
- RD-09: sync with both an absent AGENTS.md and an unobtainable canonical source would produce two errors → the local check runs first and stops, so exactly one error line is produced and no network access is spent → keeps ERR-004 and ERR-001 each satisfied with one error line.
- RD-10: Repository validity in check is only tied to TASKS.md → check always verifies repository and base branch validity, even when TASKS.md is absent in the working tree → confirmed by the user; ERR-002 is unconditional.
Expand Down
Loading
Loading