KnowledgeWriter class final

The one write path for a knowledge bundle: prepare builds the candidate a change describes and judges it, commit writes exactly what was judged.

prepare maps the change onto okf's change set and calls okf's prepare with a reserved-file projection. For indexes, the projection writes only the files whose text the selected Profile's fixable rules generate differently for the base and for the candidate, with exactly the generated text (ProfileProjection.generatedFiles), so an index the change does not affect keeps its text even when it is stale. Without a fixable rule, okf's own regeneration of the changed concept's ancestor indexes stands. For the root log, it writes what KnowledgeLog names. The candidate is then judged in memory by the KnowledgeAssessor, with ProfileValidator.validateLoaded, never read back from disk.

okf's bundle lock covers the file access: prepare holds a shared claim while it reads the bundle and okf prepares the candidate, releases it before the Profile assessment, and writes nothing; commit holds the exclusive claim, and okf refuses a bundle that changed since prepare. Run every write of a process on the isolate that does its other okf bundle I/O (ADR-0018); only the assessment may run elsewhere.

Constructors

KnowledgeWriter({WayfinderProfileResolver? resolver, ProfileValidator validator = const ProfileValidator(), KnowledgeAssessor assess = assessOnCallingIsolate, DateTime clock() = DateTime.now})
resolver selects the bundle's Profile when prepare is given no selection; validator generates the Profile's indexes and judges the base and the candidate; assess runs that judgment, by default on the calling isolate; clock dates stamps and log entries.

Properties

hashCode → int
The hash code for this object.
no setterinherited
resolver → WayfinderProfileResolver?
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
validator → ProfileValidator
final

Methods

commit(KnowledgeWritePlan plan, {WayfinderCancellation? cancel}) → Future<KnowledgeCommitResult>
Writes plan under okf's exclusive bundle lock: exactly the bytes prepare judged, or nothing.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
prepare(String bundle, KnowledgeChange change, {required KnowledgeStamp stamp, KnowledgeLog logEntry = KnowledgeLog.lifecycle, ProfileSelection? selection, KnowledgeProjectFiles? projectFiles, String? projectRoot, WayfinderCancellation? cancel}) → Future<KnowledgeWritePlan>
Prepares change to the bundle at bundle, stamped with stamp, and returns the plan commit writes. Writes nothing.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited