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
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ publication follows the [release checklist](Documentation/Reference/Release.md).

## Unreleased

## 0.3.3

### Fixed

- Materialize only the Git files needed by the resolved ledger. Combined updates
retire oversized and expired pins in the same transaction as deployments.
- Preserve live-edit skill paths during filtered updates and pin maintenance.
- Store exact Git instruction and include coordinates for Antigravity rules.
Existing self-contained locks can still restore their outputs offline.
- Check locked instruction bodies, includes and prompt inputs independently of
deployed files during doctor audits.

## 0.3.2

### Added
Expand Down
95 changes: 63 additions & 32 deletions Documentation/Architecture/State.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ the denial. Existing user content and metadata are preserved.

### Journal records

Journal format version 3 is independent of the manifest language, lock and watch
Journal format version 4 is independent of the manifest language, lock and watch
versions.
The root records its version, transaction UUID, scope identity, registered root
identities, transaction phase, operations, private containers, disposal
Expand Down Expand Up @@ -361,6 +361,7 @@ terminal disposal evidence after their expected distribution has been verified.
| `restoring` | Undo and temporary directory-write intent; installed or reverted objects can be present. |
| `restored` | Undo parents and original modes synced; restored target and remaining slot objects verified. |
| `cancelled` | Original modes restored; publication did not consume private staging. |
| `skipped` | Deferred ledger evidence matched its preimage. No replacement is staged. Commit and committed recovery require the original ledger. |

One operation-type/progress table defines every expected target and recovery
slot. Publication validation, rollback classification and disposal preparation
Expand Down Expand Up @@ -731,15 +732,22 @@ consumer error contract.

## Materialization and Installation

Git materializations, downloaded artifact bytes and expanded artifact trees use
private journal-owned staging. Exact Git commits are extracted there; expanded
artifacts are checked against their locked tree hash. Copied trees are hashed
through pinned directory descriptors and verified before publication. Files,
metadata and directory entries are synced before atomic publication of the final
cache name. Git extraction work also belongs to the journal, so recovery
cleans an incomplete copy or extraction without retaining a partial final
directory just because the lock references its pin. Cache publication completes
before the installation transaction references that content.
Git pins, downloaded artifacts and expanded artifact trees use private
journal-owned staging. The ledger groups Git resources by root source identity
and exact commit. The resulting pin includes the selected trees, link targets,
traversed links, and structural directories required to reach them. Structural
directories can be empty. Cache replacements and deletions publish in the same
transaction as deployments and the ledger.

The transaction streams file evidence for an ordinary directory preimage at an
admitted materialized pin. Recovery uses the journal's destination, the legal
slot layout and the recorded inode to identify that preimage. The same tree
and format limits apply to both evidence paths. Before the first publication,
the transaction removes prepared work and admits the terminal container reads
and journal encoding, including space to persist conflicts. Partial disposal
accepts surviving directories at their original mode or with owner access
added by disposal. It verifies every surviving entry through its opened
parent before unlinking it.

Each scope's cache contains:

Expand All @@ -752,13 +760,22 @@ cache/
locks/
```

A source key combines a readable prefix and the SHA-256 of its normalized ID. A
source has one bare mirror; requirement resolution reads its refs and tags.
Exact trees are extracted with Git archive and contain no repository metadata.
Read-only revision inspection uses local Git reads or remote ref advertisements
with the same requirement selection policy, without fetching or populating
caches. Consumers of the same source and revision share a materialized
directory.
A source key combines a readable prefix and the SHA-256 of its normalized ID.
A source has one bare mirror. Local discovery freezes the transport's ref and
HEAD advertisement and borrows the local object store in a temporary catalog.
Catalog refs retain their own namespace. Exact trees use a private archive
repository with a fixed unborn HEAD and committed attributes. The archive reader
walks committed tree entries before selecting paths. Stateful substitutions use
the full archive order, while extraction retains only the selected entries.
Replay checks selected hashes and compares coordinate-only support files with
their exact archive bytes.

A source session expands an address-stable workspace when discovery or replay
requires another path at the same pin. Looking up the repository root for
containment leaves the selection unchanged. Explicit root discovery and root
directory resources select the root recursively. Read-only operations keep
temporary acquisition disposable and leave mirrors and materialized pins
unchanged.

`link` points an agent's skill entry at verified cached content. `copy` installs
that content as a directory and rejects links escaping the installed subtree.
Expand Down Expand Up @@ -789,12 +806,23 @@ once. The synchronous prepared handle retains these borrowed resources and write
locks while the consumer renders its report and applies it. Live edit content stays
live; its identity and usable metadata are checked instead of a content pin.

Apply validates state, targets and source evidence, retains the complete ledger/watch
reference closure, and validates again. One transaction stages resource trees and
capsules, selected physical targets, declaration, ledger, receipts and cache pruning.
No-change apply returns receipts without rewriting state. Exiting before apply
publishes no targets, state or retained trees; writer lock containers may remain.
Temporary source and replay resources are released at closure exit.
Preparation decides which pins will be created, replaced, kept or deleted.
The report fingerprint binds those decisions, the candidate closure and the
recorded generation of each pin that will move. A combined update can retire
expired pins or shrink an older pin to its verified closure. Filtered updates
prepare pins needed by the selected changes. Restore can recreate a missing
pin even when the deployed target already matches. The active and pending
closures protect authored live-edit links and verified editable directories
from pin deletion and replacement.

Apply revalidates state, targets and source evidence. It acquires required
Git objects and applies a single object-store barrier per mirror before
publishing the retention refs. One transaction stages pin changes, resource
capsules, selected targets, declaration, ledger, receipts and artifact pruning.
Private native outputs can seal final ledger evidence during staging. The
transaction then compares the final ledger to the captured preimage and skips
construction when they match. An equivalent ledger retains its bytes and inode.
A no-change apply returns receipts without an object-store barrier or transaction.

Commit outcome tracking is bound to the combined journal's UUID. Recovering a
separate cache publication cannot claim that the combined generation committed.
Expand All @@ -806,15 +834,15 @@ death the next writer recovers and raises `CoreError.transactionRecovered`;
consumers retry the whole preparation. Previews reject pending recovery without
replay. See [Updates](Updates.md) for the public handle and error contracts.

Pruning participates in that transaction. Pins referenced by skills, instruction
sections or prompt sections remain cached, as do artifact contents referenced by
watch state and trees containing live edit sources. Pruning opens directory
ancestry without following symlinks and uses directory-relative enumeration,
rename and deletion. It rejects symlinked cache containers and never recursively
follows a link during deletion. Mirrors remain available for source history and
future resolution. Watch-owned Git refs retain only revisions still referenced
by watch state or installed pins; obsolete histories can be collected by Git
after those refs are released.
Git object retention and materialized paths follow separate ledger edges.
Watch baselines and empty groups retain objects without creating pin
directories. Legacy self-contained Antigravity inputs retain their recorded
Git provenance and protect existing refs while replaying from the embedded
bytes. New Antigravity freezes use the same coordinate-only Git records as
other instruction targets. Filtered updates preserve an equivalent legacy
ledger when its rendered contributions and the selected state are unchanged.
The pending reference marker includes both deployed and pending generations
until recovery has selected a consistent ledger.

Both doctors inspect cached objects, local Git refs or remote ref advertisements
without fetching or populating caches. Local Git status disables optional locks
Expand All @@ -823,6 +851,9 @@ to avoid index refresh writes. Skill doctor reports pending recovery as a
transaction uses `unresolved-transaction` and lists retained recovery locations.
It also reports missing installs, changed content and broken links, newer
matching Git resolutions and uncommitted changes in selected local source paths.
Instruction doctor verifies each locked input, including nested includes and
prompt inputs, separately from deployed output drift. Each ordinary target
uses its own input health to decide whether to inspect Markdown links.
`install` restores all recorded recipients and modes without changing lock
bytes. The consuming CLI controls presentation and user interaction.

Expand Down
27 changes: 10 additions & 17 deletions Sources/AgentsCore/AcquisitionCache/GitAcquisition.swift
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,12 @@ struct GitAcquisition {
let root = repository.deletingLastPathComponent()
// Scope paths may carry ordinary config. Run init from a clean external workspace.
try workspace { clean in
_ = try initialize(named: repository.path, in: clean, object: object)
let format = object.utf8.count == 64 ? "sha256" : "sha1"
_ = try git(
[
"init", "--bare", "--template=", "--initial-branch=unborn", "--object-format=" + format,
repository.path,
], in: clean, .extractRevision)
_ = try git(
["-C", repository.path, "config", "remote.origin.url", url], in: clean, .readOrigin)
_ = try git(
Expand All @@ -292,23 +297,11 @@ struct GitAcquisition {
try DirectoryHandle(at: root).sync()
}

func archive(_ revision: String, repository: URL, to archive: URL) throws {
try workspace { root in
_ = try git(
["-C", repository.path, "archive", "--format=tar", "--output=" + archive.path, revision],
in: root, .extractRevision)
}
}

private func initialize(named name: String = "repository", in root: URL, object: String) throws
-> URL
{
private func initialize(in root: URL, object: String) throws -> URL {
let format = object.utf8.count == 64 ? "sha256" : "sha1"
_ = try git(
["init", "--bare", "--template=", "--object-format=" + format, name], in: root, .clone)
return URL(
fileURLWithPath: name, relativeTo: URL(fileURLWithPath: root.path, isDirectory: true)
).standardizedFileURL
let repository = root.appendingPathComponent("repository", isDirectory: true)
try GitObjectDirectory.initializeBare(at: repository, format: format)
return repository
}

private func workspace<T>(_ body: (URL) throws -> T) throws -> T {
Expand Down
Loading
Loading