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
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Implementation Plan: Legacy artifact receive cutoff (issue #4459)

See the dated design record: [legacy artifact receive cutoff](../../doc/2026-11-05T15-10-00Z_architecture_legacy_artifact_receive_cutoff/2026-11-05T15-10-00Z_architecture_legacy_artifact_receive_cutoff.md).

## Task
Implement the accepted ruling on [#4459](https://github.com/developing-today/code/issues/4459) so peer pulls can continue across pre-upgrade `home_declared` artifacts that violate the #3187 world-ID rules.

## Accepted ruling summary
- Cutoff: artifact/journal format version
- Legacy entries (before cutoff): scoped leniency for over-bound `home_declared` only, recorded with a legacy note; pull continues
- At/after cutoff: strict `parsed()` applies; over-bound declarations are hard errors
- Unmarked artifacts: per-author chain position fallback (entries before first strict artifact are legacy)
- Corrupt entries: hard errors at any version

## Implementation scope
- The signed artifact format and `Directory::receive_artifact` as needed to make the format cutoff trustworthy
- Add regression coverage exercising a pre-upgrade `home_declared` entry through the peer-pull path
- Do not reuse local replay leniency wholesale; do not relax new receipts

## Steps

1. Add a signed artifact format marker
- Preserve legacy hash/signature bytes when the marker is absent
- Mark new artifacts at the strict format version
- Treat unmarked artifacts as legacy only before the author's first strict-version artifact

2. Implement version-scoped leniency in `Directory::receive_artifact`
- If artifact version < cutoff: allow `home_declared` parsing to succeed with a legacy note; continue pull
- If artifact version >= cutoff: call strict `artifact.parsed()?`; hard error on violation
- If no version marker: fallback to per-author chain position (first strict artifact in author's chain)
- Corrupt entries: hard errors always

3. Add a typed legacy receive outcome
- Surface the scoped leniency to the pull caller without treating the accepted artifact as an error

4. Add regression coverage
- Create a test that constructs a pre-upgrade `home_declared` artifact violating #3187 rules
- Exercise the peer pull path through `Directory::receive_artifact`
- Assert the pull completes with a legacy outcome and continues to later artifacts
- Assert strict-version invalid entries and genuinely corrupt entries remain hard errors

5. Verify the targeted artifact/directory suites pass on the laptop
- Run the narrow `pkgs/id` tests first, then the broader library tests if time permits

## Acceptance criteria
- A peer pull over a journal containing pre-upgrade `home_declared` entries completes (entries applied with a recorded legacy note, or surfaced as a typed non-halting outcome)
- Regression coverage exercises a pre-upgrade `home_declared` entry through the pull path
- Behavior for genuinely corrupt entries remains a hard error; strictness for at/after-cutoff artifacts is unchanged
- `pkgs/id` targeted suites pass

## References
- [#4459 ruling](https://github.com/developing-today/code/issues/4459#issuecomment-6634862794)
- [#3187 PR #4432](https://github.com/developing-today/code/pull/4432)
- `pkgs/id/src/artifact.rs`
- `pkgs/id/src/directory.rs`

## Change log
- 2026-11-05: Initial plan created; implementation detail narrowed to signed format marker and typed receive outcome.
- 2026-11-11: Superseded in part by the task 12788 decision on #4459 (see the design record's Revision 2026-11-11): the signed format marker was dropped after the accepted Codex P2 on PR #6407; the cutoff is now receive-side per-account chain position, implemented in the id-sync crate after the #4406 split (task 15019).

## Change log
- 2026-11-05: Initial plan created
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Legacy artifact receive cutoff

See [the implementation plan](../../.opencode/plans/2026-11-05T15-10-00Z-legacy-artifact-receive-cutoff.md).

Request: implement the accepted ruling on [#4459](https://github.com/developing-today/code/issues/4459) so peer pulls can continue across pre-upgrade `home_declared` artifacts that violate the #3187 world-ID rules.

## Intent and initial plan

The cutoff is trusted artifact/journal format version, not peer provenance. Artifacts before the strict format remain chain history: accept only the scoped legacy `home_declared` case needed for continuity and surface that leniency as a recorded/typed note. Artifacts at or after the cutoff use the full current parser. Invalid signatures, malformed envelopes, chain conflicts, and genuinely corrupt entries remain hard errors at every version.

For artifacts without a version marker, use the author's chain position relative to that author's first strict-version artifact: earlier entries are legacy; the first strict artifact and later entries are strict. Keep the exception local to peer receive; do not reuse local replay leniency wholesale or relax new receipts.

Implementation will keep the public pull path non-halting for the accepted legacy case and add regression coverage that exercises the peer-pull path, while retaining a strict-version rejection and corrupt-artifact rejection oracle. The implementation detail for carrying/versioning the marker will follow the existing signed-artifact and journal contracts discovered in code.

## References

- [#4459 ruling](https://github.com/developing-today/code/issues/4459#issuecomment-6634862794)
- [#3187 strict-receipt PR #4432](https://github.com/developing-today/code/pull/4432)
- `pkgs/id/src/artifact.rs`
- `pkgs/id/src/directory.rs`
- [Implementation plan](../../.opencode/plans/2026-11-05T15-10-00Z-legacy-artifact-receive-cutoff.md)

## Revision 2026-11-11 (task 12788 decision, implemented by task 15019)

The format-version cutoff above was superseded before merge: an accepted
Codex P2 on PR #6407 showed that putting `format_version` inside
`signed_bytes` makes unupgraded peers reject every newly signed artifact
(the push/pull protocols have no version negotiation). The recorded
decision on issue #4459 replaces the marker with a receive-side-only
cutoff derived from per-account chain position:

- The signed format does not change; nothing about what signers emit
changes, so unupgraded peers keep verifying new artifacts as today.
- The legacy world-ID exception applies only to an artifact that extends
its author's held chain at a position before the first artifact the
receiver itself accepted under strict receipt for that author.
- The position comes only from the chain's signed links and the
receiver's own strict-receipt history — never a sender-asserted field.
When a position cannot be established, validation stays strict.
- Signature and all other structural checks stay strict at every
position; the typed legacy note is still recorded during pulls.

Implementation note: the artifact wire layer moved to the `id-sync`
crate in the #4406 crate split, so the receive path lives in
`pkgs/id/crates/id-sync/src/artifact.rs` (`ArtifactLog::insert_received`),
with the pull-path regression tests in the facade tests in
`pkgs/id/src/artifact.rs`.
Loading