diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ec65427 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +node_modules/ +bin/ +*.zip \ No newline at end of file diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..1055efe --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,185 @@ +# Development Philosophy + +## Simplicity is the default + +Speculative architecture always has negative value. + +The cost of writing code is small compared with the cost of carrying it. Every abstraction, hook, compatibility layer, option, fallback, extension point, and anticipated future feature becomes something the project must understand and preserve. Worse, later work begins building on guesses about a future that has not arrived yet. + +If we understand A and B, partly understand C and D, and only imagine E, build A and B. Do not pour foundations for C, D, or E. When C becomes real, A and B will have taught us things we could not know beforehand. That evidence lets us build C once and integrate it with what actually exists. Premature preparation for E can occupy the very ground the real E eventually needs and can force A through D to depend on a mistaken future. + +The only reliable speculation is that simplicity will pay off. + +Build the smallest thing that fully serves the need we concretely understand. Do not future-proof by predicting the future. Preserve the future by refusing to obstruct it. + +## Discussion before action + +A problem report is information, not an instruction to patch the nearest code. + +When something breaks, first understand what happened, why it happened, which behavior was intentional, and what solution landscape the evidence supports. A clear path is not necessarily the right path. The right path tends to reveal itself when investigation and discussion converge on an obvious next step. + +This is not ceremony. The discussion may be brief. The rule is simply that action follows understanding rather than replacing it. + +Do not make meaningful behavioral or architectural changes merely because they appear straightforward. Surface the evidence, alternatives, and consequences first and agree on direction. + +## Beauty over perfection + +We are not building machinery to eliminate every imperfect judgment, irregular case, or possible mistake. Predictably good, useful, approachable work is more valuable than elaborate systems designed to force perfection. + +An occasional exception is allowed to remain an exception. Do not immediately turn anomalies into rules, validation systems, abstractions, fallbacks, or special cases. Forgive exceptions until repeated evidence shows that the exception is actually part of the shape of the problem. + +This applies to code and to the content these tools help produce. Complexity introduced to prevent every possible imperfection often damages the work more than the imperfection would have. + +## Follow evidence without an agenda + +Investigate the actual code, data, failures, and outputs rather than speculating about what they probably mean. Do not steer evidence toward a preferred architecture or conclusion. + +For translation and ancient-text work, the received text is the authority. Tradition is context, not a destination. We are not trying to reinforce tradition or tear it down, and we do not bend the text toward doctrine, dogma, skepticism, apologetics, or novelty. The aim is unbiased, approachable, useful, compelling translation of ancient wisdom. + +Not every participant in a creative or translation pipeline produces evidence. Explorers, philosophers, and literary voices may speculate, reach, or occasionally indulge wishful thinking when that is useful to their role. Be rigorous about what is called evidence and which roles have authority to alter the received text; do not turn the entire endeavor into an academic apparatus in pursuit of impossible perfection. + +## Synchronous blocking execution is the intended project-family architecture + +The applications using Optimus are blocking batch tools, not concurrent servers. Their desired control flow is one path at a time: ensure one dependency, finish it, persist/publish it, return, then continue. Do not treat Node's conventional async style as a design requirement. + +Optimus currently contains Promise-aware plumbing because the existing projects still contain legacy async functions. That is transitional compatibility, not an invitation to spread async/await, Promise returns, callback orchestration, parallel sibling ensures, or queues. A separate refactor will unwind this plumbing. Until then, do not make that future conversion harder. + +# Optimus + +Optimus is a lightly opinionated framework for organizing pull-driven transformer operations. + +Like Optimus Prime, Optimus does not solve every problem itself. It leads a team that works by a recognizable method. An Optimus project should clearly look and behave like an Optimus project even though its modules remain loosely coupled and domain-specific. + +Optimus organizes modules. Some modules are transformers. Some are not. Optimus also participates directly by providing the shared services that let modules locate one another, request work, wrap results in metadata, persist artifacts, and determine whether previously completed work can still be trusted. + +## Core concepts + +### Modules are the team + +A module is a participant in an Optimus operation. It may transform data, provide services, coordinate work, interact with an LLM, interact with a human, import external material, publish results, or do something else entirely. + +Optimus gives modules a shared project environment and a way to locate one another without requiring a central monolith. + +### Peer dependencies are resolved by Optimus + +Treat each registered module as a dependency-injection boundary. A module may use relative imports for private implementation files inside its own module directory. It should not know the filesystem location of a peer module. + +When one module depends on another, resolve that dependency by semantic name through `utils.loadModule(name)`. `settings/modules.json` is the composition map that decides which implementation/location satisfies that name. + +```js +module.exports = utils => { + const source = utils.loadModule("standard-source"); + return { /* ... */ }; +}; +``` + +Do not bypass Optimus with sideways imports such as `require("../standard-source")` or `require("../lib/...")` when that neighboring directory is functioning as a peer module. If shared code deserves an independent neighboring module directory, register it and load it through Optimus. If it is private to one module, keep it inside that module. + +The reason is architectural rather than stylistic. Consumers should depend on a peer's semantic contract, not today's repository layout. That allows the project mapping to relocate, extract, package, or replace modules later without rewriting their consumers, and it prevents two competing dependency-resolution systems from emerging without two distinct needs. + +### Transformers are artifact-producing modules + +A transformer is a module that can be asked for an artifact and can determine whether an existing artifact is stale according to that transformer's needs. + +All transformers are modules. Not all modules are transformers. + +A transformer is not required to be a tiny one-transformation machine. One coherent transformer module may own several closely related transformations and several artifact layers. For example, an importer may naturally produce volume-, book-, and chapter-level artifacts. Prefer coherent responsibility over artificial micro-modules. + +### Artifacts are durable work, not a private cache + +A transformer's artifact area is an organized workbench and warehouse. Humans should be able to enter it and directly find the artifact they want to inspect. Do not turn artifact storage into an opaque hash cache or private implementation laboratory. + +Artifacts may be produced by deterministic code, LLMs, humans, external systems, or combinations of them. Optimus does not privilege one producer type over another. + +Caching is a useful behavior of durable artifacts, not their identity. Persist work because the work is meaningful, inspectable, reusable, expensive, nondeterministic, or useful for evaluating freshness—not because every function deserves a cache entry. + +### Pull drives the operation + +Optimus is a pull queue, not a push pipeline runner. + +A caller asks for a desired artifact. The responsible module asks for what it needs. Those modules ask for what they need. Existing work is reused where it remains valid, and work happens only where the dependency chain requires it. + +Do not replace this with a centrally scheduled sequence or a duplicate declarative DAG unless concrete evidence proves the ordinary module calls are insufficient. + +## Transformer-owned validity + +Optimus provides services that make freshness easy to record and evaluate. Optimus does not own the semantic definition of freshness for every transformation. + +The transformer owns its recipe: which inputs matter, which implementation or settings changes matter, and what must be compared before an artifact can be reused. `resolveArtifact()` and `sameSourceHash()` provide a small, useful exact-parent-hash policy, but they are framework services, not a restriction that every transformer must define validity in exactly the same way. + +Every transformer is responsible for verifying that the artifacts it returns are current according to its own declared needs. + +That ownership includes artifact lifecycle and cleanup, not only dependency hashes. A transformer should understand whether its work is cheap or expensive, deterministic or flexible/nondeterministic, and whether payload-level defects can make an otherwise well-provenanced artifact unusable. Cheap deterministic work may choose eager recalculation. Expensive LLM work will often be more conservative, while still needing a deliberate way to force a fresh call when the actual result is not viable. + +There is no universal Optimus staleness policy and there should not become one. Named logic revisions and accepted-revision sets are an available pattern when a transformer needs compatibility tracking, not a requirement that every transformer version itself. Likewise, a shared utility or wisdom stack may expose a revision identity without making every consumer stale; the consuming transformer decides whether that revision participates in its own validity rule. + +Changes to those validity judgments are behavioral decisions. Discuss them deliberately rather than allowing a cleanup/refactor to redefine artifact freshness accidentally. + +A transformer also owns keeping its artifact warehouse meaningful. Preserve useful durable history, but do not knowingly retain junk artifacts that are no longer valid and cannot participate in the active graph. + +Do not centralize domain-specific invalidation policy into Optimus merely because several transformers use the same helper today. + +## Services, not restrictions + +Optimus is a framework, but it should preserve maximum flexibility within its operating method. + +Optimus should make it easy to: + +- organize modules; +- locate modules by semantic name; +- read project settings; +- request named top-level artifacts; +- pull dependencies recursively through ordinary code; +- wrap work in content/provenance metadata; +- persist and read durable artifacts; +- evaluate common freshness patterns; +- invalidate targeted persisted work; +- report artifact ensure/build decisions according to project presentation settings. + +Optimus should not decide: + +- what a domain artifact means; +- what a transformer's complete recipe is; +- how a human participates in a transformation; +- how an LLM is configured or called; +- how a translation is judged; +- whether a module must be a transformer; +- how many related transformations one module may own; +- what every artifact directory must contain beyond what the owning transformer needs. + +If a human-interaction workflow becomes useful, a module such as a future Bumblebee transformer can own that experience and persist/stamp its results. Optimus does not need a generic human-task system in order to permit human-produced artifacts. + +## Intentional boundaries + +The following behavior is deliberate. Do not remove or substantially reshape it without discussion: + +- Optimus is pull-driven rather than a centrally pushed stage runner. +- Modules are the primary participants; transformers are a subset of modules. +- Peer-module dependencies are resolved by semantic name through Optimus; modules do not reach across peer boundaries by filesystem path. +- Ordinary module calls may express the dependency graph. A second graph definition is not required. +- Transformer modules may own multiple closely related transformations. +- Transformers own their freshness semantics; Optimus supplies common mechanisms. +- Durable artifacts are human-inspectable work products, not opaque cache internals. +- Content hashes stop unnecessary downstream propagation when rebuilt content is unchanged. +- Human-, LLM-, code-, and externally-produced work may all become legitimate artifacts when the owning transformer knows how to validate them. +- Side effects and diagnostics do not become semantic dependencies merely because they are useful to retain. +- Presentation (`showOnEnsure`, `showOnBuild`, `reportEnsure()`, `reportBuild()`, and legacy `setArtifactOutcome()`) is reporting only and never participates in artifact identity or freshness. +- Settings remain domain-agnostic JSON owned by the Optimus project. Optimus does not need to understand their meaning. +- Module initialization is free to do the work its module actually needs. Do not add lifecycle restrictions merely to force every module into the same shape. + +## Current direction + +The current Optimus runtime already expresses this vision with a small amount of machinery: settings, modules, named artifacts, recursive module calls, artifact nodes, persistence helpers, hashing, invalidation, and CLI orchestration. + +The present direction is therefore to clarify and protect the framework rather than expand it. Add capability only when an actual Optimus project demonstrates that the current services are insufficient. + +## Deliberately not doing yet + +- generic human-task or approval workflow infrastructure; +- a universal transformer interface beyond the behavior actual modules already need; +- one-module-per-transformation enforcement; +- a central declarative dependency graph; +- schemas or type systems for arbitrary project settings; +- an opaque content-addressed artifact cache replacing human-readable artifact warehouses; +- generalized workflow states, queues, schedulers, or orchestration engines beyond the pull method already in use; +- framework-level understanding of LLM providers, translation semantics, publishing semantics, or other domain relationships that belong in modules. diff --git a/docs/history.md b/docs/history.md new file mode 100644 index 0000000..2f4c723 --- /dev/null +++ b/docs/history.md @@ -0,0 +1,95 @@ +# Design History + +This is a reasoning history, not a commit log. It records the problems that shaped Optimus so later changes can distinguish intentional design from accidental implementation. + +## Durable work instead of rerunning pipelines + +Optimus grew around a practical problem: expensive and nondeterministic work should survive restarts and downstream changes. + +A conventional pipeline runner tends to think in execution order. Optimus instead asks for a desired artifact and walks downward through the work needed to establish it. This made persisted intermediate results first-class rather than incidental cache files. + +The important consequence was a pull-driven operation: request what you want, recursively establish what it depends on, and wake only the work that is actually missing or stale. + +## Content identity stopped unnecessary invalidation + +A parent transformation can become stale because its recipe changed and still reproduce exactly the same semantic output. + +If every downstream artifact invalidated merely because the parent reran, expensive/nondeterministic work would be repeated unnecessarily. Optimus therefore uses content hashes as the identity passed downstream. A rebuilt parent with unchanged content does not force descendants to rebuild. + +This was especially valuable for LLM-heavy pipelines where unnecessary reruns can produce different answers even when nothing semantically changed. + +## Complete named parent sets became a useful default recipe check + +`resolveArtifact()` compares the complete named set of source hashes rather than only overlapping hashes. Adding, removing, or renaming a semantic parent is therefore a recipe change under that helper. + +The names matter because they describe roles, not just byte values. + +This exact-source-set policy remains a useful framework service, but later clarification made an important boundary explicit: transformers own their own semantic freshness rules. `resolveArtifact()` is a strong default mechanism, not a universal definition imposed by Optimus. + +## Artifacts remained readable instead of becoming an opaque cache + +As more intermediate work became durable, it became useful to inspect it directly while debugging, evaluating LLM output, comparing translations, and understanding provenance. + +Artifact directories therefore function as organized workbenches/warehouses. They are not intended to become private implementation storage addressed only by hashes. + +`sourceRef` supports human navigation while `sourceHash` remains the content-validity mechanism. + +## Modules became the team; transformers remained a subset + +Optimus projects naturally accumulated participants that did not fit a strict "one transformer = one stage" model: source loaders, publishers, LLM wrappers, coordination helpers, and other services. + +The resulting model is deliberately loose: + +- Optimus organizes modules. +- Some modules are transformers. +- A transformer may own several closely related transformations. +- Ordinary module calls may express dependency relationships. + +This avoids both a central monolith and artificial micro-transformers. + +## Humans are legitimate artifact producers + +The first Optimus projects mostly received human-authored material through input folders and then transformed it mechanically or through LLMs. + +The framework was later clarified to permit humans as active participants inside transformations as well. A module may interview a human, collect approvals, accept manually authored guide entries, or allow a human to stamp prepared material as valid. + +No Optimus-level human workflow system was added. If recurring human interaction needs reusable machinery, it can emerge as its own module (for example a future Bumblebee transformer) once real implementations provide evidence for what that machinery should be. + +## 2026-09-09 — framework vision documented without runtime change + +The project documentation was revised to describe Optimus as a lightly opinionated pull-driven transformer framework rather than primarily as a durable artifact resolver. + +This was a clarification of the implementation's existing shape, not a runtime redesign. + +The discussion established these intentional boundaries: + +- Optimus organizes modules and participates through shared framework services. +- Transformers are artifact-producing/validating modules, not mandatory micro-machines. +- Freshness semantics ultimately belong to each transformer. +- Artifact areas are readable workbenches/warehouses. +- Human, LLM, external, and deterministic producers are all permitted. +- Optimus provides services rather than domain restrictions. +- No generic human-task system, central DAG, universal transformer interface, or other speculative framework machinery should be added without evidence. + +## 2026-09-10 — useful build reporting without the full role call + +Real translation runs showed that printing every already-current artifact check made normal console output noisy. The useful operational fact was usually the moment Optimus decided that work actually had to run. + +Optimus therefore gained two optional presentation settings: `showOnEnsure` (default false) and `showOnBuild` (default true). Standard `resolveArtifact()` work reports automatically, while custom-validity transformers can report the same events through tiny framework hooks. Presentation remains completely outside artifact semantics. + +This also reinforced an earlier framework principle: Optimus conveniences are services, not contracts. A transformer with unusual validity rules does not have to adopt `resolveArtifact()` merely to obtain consistent console behavior. + + + +## 2026-10-06 — ensure remains the dependency contract + +Publication work exposed an important distinction between expensive evergreen artifacts and intentionally frozen editions. The tempting shortcut was to read an existing expensive artifact directly so a downstream publisher could not accidentally wake it. That would have inverted Optimus's pull model: the downstream consumer, rather than the owning transformer, would decide whether a historical copy was acceptable. + +The clarified strategy is: + +- live dependencies are ensured normally; +- if an ensure wakes work unnecessarily, the owning transformer's freshness inputs or validity policy are too broad and should be corrected there; +- low-level artifact reads remain available for transformer-owned validity, migration, repair, and inspection; +- an accepted result that should no longer be evergreen is exported/ejected and becomes ordinary input to another project, intentionally severing the live dependency edge. + +This was a documentation clarification rather than a runtime change. diff --git a/docs/ideas.md b/docs/ideas.md new file mode 100644 index 0000000..5ad2553 --- /dev/null +++ b/docs/ideas.md @@ -0,0 +1,35 @@ +# Ideas and Deferred Possibilities + +This file is intentionally not a roadmap. Items here are possibilities or observations that do not yet have enough evidence to justify framework complexity. + +The default action for every item is: leave it alone until real Optimus projects demonstrate the need. + +## Human-interaction modules + +A future module (informally imagined as something like Bumblebee) could own reusable human interaction: interviews, approval queues, manual guide entry, or explicit stamping of human-authored artifacts. + +Optimus itself does not need a human-task subsystem. Build a concrete module first if/when a real workflow requires one. Only repeated implementations should motivate shared machinery. + +## More transformer helpers + +Different domains may eventually repeat freshness or persistence patterns that are not covered cleanly by `resolveArtifact()` and the current node helpers. + +Do not add generic recipe objects, transformer base classes, validation interfaces, or capability registries in anticipation of that possibility. Let several real transformers reveal the common shape first. + +## Artifact browsing tools + +Because artifact areas are intended to be human-readable warehouses, a project may someday benefit from optional browsing/search tooling. + +Do not restructure artifact storage around such a tool. The files should remain directly understandable without it. + +## Module initialization + +Modules currently initialize at project startup while transformation work remains pull-driven. + +If a future project demonstrates that initialization itself is expensive or has harmful side effects, reconsider lazy initialization then. Do not add lifecycle machinery solely for architectural symmetry. + +## Additional orchestration concepts + +Queues, concurrency controls, distributed execution, human wait states, scheduling, and workflow status models are all conceivable around transformer operations. + +None belong in Optimus merely because they are imaginable. Introduce only the smallest capability demanded by concrete work when that work arrives. diff --git a/docs/intentional-behavior.md b/docs/intentional-behavior.md new file mode 100644 index 0000000..a9f3059 --- /dev/null +++ b/docs/intentional-behavior.md @@ -0,0 +1,105 @@ +# Intentional Behavior + +This document records Optimus behavior and boundaries that are deliberate. They should not be removed, generalized, centralized, or "cleaned up" without discussion about why they exist. + +## Optimus is a pull framework + +A desired artifact is requested at the top. Modules recursively request what they need. Work wakes up where the requested dependency chain finds missing or stale results. + +Do not replace this with a centrally pushed stage sequence merely because a particular project happens to have a visually linear flow. + +Ordinary module calls are allowed to be the dependency graph. A duplicate declarative DAG is not required. + +A consumer normally establishes another module's artifact by ensuring it. Reading that module's persisted artifact directly in order to suppress a possible rebuild is intentionally not a second dependency mechanism. If an ensure rebuilds work that is not semantically stale, fix the owning transformer's freshness rule. + +If a result is intentionally no longer evergreen, make that break explicit: publish/eject the accepted result and use the exported file as input to a separate project or graph. A frozen handoff and a live Optimus dependency are different concepts. + +## Modules are broader than transformers + +Optimus organizes modules. + +A transformer is a module that can produce an artifact and determine whether an existing artifact remains current according to its own needs. Not every module has to produce artifacts. + +Do not force service modules, human-facing modules, LLM wrappers, publishers, or other legitimate participants into an artificial transformer interface. + +## Peer modules are resolved by semantic name + +`settings/modules.json` is the project's composition map. Peer modules depend on one another by semantic module name and obtain one another through Optimus, normally with `utils.loadModule(name)`. + +A module may freely use relative imports among private files inside its own module directory. It should not import a neighboring peer module by filesystem location. A neighboring directory that provides a real cross-module service should have a registered module identity; implementation that is private to one module should live inside that module instead. + +This boundary is intentional. Optimus is the dependency resolver for peer modules, so consumers do not need to know whether a collaborator currently lives beside them in `src/`, is later extracted, or is otherwise mapped differently by the project. Avoid introducing a second peer-resolution convention based on `../some-module` paths merely because today's checkout makes that path convenient. + +The current runtime reads filesystem entry paths from `settings/modules.json`. That is composition detail owned by the project mapping, not knowledge that should leak into consumers. + +## Transformers may own several related transformations + +Transformer is a responsibility, not a microservice size rule. + +A coherent module may produce multiple artifact types or layers when those transformations genuinely belong together. Avoid both monoliths and artificial fragmentation. + +## Freshness belongs to the transformer + +Optimus supplies reusable mechanisms such as `resolveArtifact()` and `sameSourceHash()`. These make exact named-parent-hash freshness easy. + +They are not the universal semantic definition of stale. + +The owning transformer decides which inputs and rules matter to its output and is responsible for verifying those conditions before returning persisted work as current. + +Do not move domain-specific invalidation policy into Optimus simply to make all transformers look identical. + +Freshness sensitivity is a judgment call owned by the transformer and its pipeline. Cheap deterministic work may intentionally be highly sensitive because reconsideration costs almost nothing. Expensive or nondeterministic work may deliberately use a narrower validity contract. Hash helpers are tools, not requirements to collect every available dependency. + +Artifact boundaries are likewise judgment calls. Granularity is valuable when it creates useful independent stability or clearer organization, but Optimus does not prescribe one artifact per consumer, one artifact per source node, or maximum fragmentation. + +## Content hashes contain propagation + +Children key off parent content identity, not the fact that the parent happened to rerun. + +When a parent is rebuilt from a changed recipe but produces identical semantic content, downstream artifacts may remain current. + +This is intentional and particularly important for expensive or nondeterministic work. + +## Artifact storage is a workbench and warehouse + +Artifact folders are intended to be useful to humans. + +Do not replace readable artifact organization with opaque hash-only cache directories or structures that require special tooling merely to locate a known result. + +Metadata should support provenance and freshness while leaving the actual work discoverable. + +## Artifacts may have many kinds of producers + +An artifact may be produced by deterministic code, an LLM, a human, an imported external source, or a combination. + +Optimus does not require a generic human-task system or LLM subsystem to permit those producers. The responsible module owns the interaction and validity semantics. + +## Side effects do not become semantic inputs automatically + +Reasoning traces, request transcripts, timing, retries, token counts, diagnostics, and progress information can be valuable to keep. They are not semantic dependencies merely because they were generated during the work. + +Do not make semantic artifacts depend on side-effect files unless their content has genuinely become part of the transformation's meaning. + +## Settings are domain-agnostic + +`getSettings(name)` gives Optimus projects a simple shared settings mechanism. Optimus does not interpret arbitrary setting content. + +Do not add schemas, typed configuration domains, or framework ownership of settings that belong to modules without concrete evidence that the simple JSON model has failed. + +## Presentation is reporting only + +Optimus recognizes `presentation.showOnEnsure` and `presentation.showOnBuild`. Missing settings default to quiet ensure checks and visible actual builds. `resolveArtifact()` reports these decisions automatically; custom-validity transformers may call `reportEnsure()` / `reportBuild()` without owning console policy. + +These settings and reporting hooks do not participate in artifact identity, freshness, ancestry, or persistence. Application-owned presentation settings may coexist in the same settings object and are ignored by Optimus. + +`setArtifactOutcome()` remains as a compatibility reporting hook; it is also non-semantic. + +## Module initialization is free + +Current modules are initialized at project startup. A module may use initialization merely for setup or may synchronously establish substantial working state when its real responsibility requires that. Optimus does not impose a "lightweight init" rule. + +Do not introduce lifecycle restrictions, lazy-loading machinery, or async conventions merely to make modules look uniform. + +## Blocking flow is intentional + +The project family intentionally targets synchronous, blocking batch execution. Promise-aware behavior that exists today supports legacy callers pending a separate unwind; it is not the desired public programming model. Do not add concurrency or Promise-driven orchestration as an optimization.