@latysh-development/monolith 0.0.0-stage → 0.1.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +179 -2
- package/dist/brief/cli.d.ts +30 -0
- package/dist/brief/cli.d.ts.map +1 -0
- package/dist/brief/cli.js +85 -0
- package/dist/brief/collect.d.ts +17 -0
- package/dist/brief/collect.d.ts.map +1 -0
- package/dist/brief/collect.js +342 -0
- package/dist/brief/config.d.ts +40 -0
- package/dist/brief/config.d.ts.map +1 -0
- package/dist/brief/config.js +85 -0
- package/dist/brief/constants.d.ts +12 -0
- package/dist/brief/constants.d.ts.map +1 -0
- package/dist/brief/constants.js +11 -0
- package/dist/brief/docs.d.ts +53 -0
- package/dist/brief/docs.d.ts.map +1 -0
- package/dist/brief/docs.js +229 -0
- package/dist/brief/freshness.d.ts +104 -0
- package/dist/brief/freshness.d.ts.map +1 -0
- package/dist/brief/freshness.js +263 -0
- package/dist/brief/git-signals.d.ts +17 -0
- package/dist/brief/git-signals.d.ts.map +1 -0
- package/dist/brief/git-signals.js +101 -0
- package/dist/brief/index.d.ts +11 -0
- package/dist/brief/index.d.ts.map +1 -0
- package/dist/brief/index.js +5 -0
- package/dist/brief/reconcile.d.ts +75 -0
- package/dist/brief/reconcile.d.ts.map +1 -0
- package/dist/brief/reconcile.js +259 -0
- package/dist/brief/render.d.ts +67 -0
- package/dist/brief/render.d.ts.map +1 -0
- package/dist/brief/render.js +458 -0
- package/dist/brief/sanitize.d.ts +38 -0
- package/dist/brief/sanitize.d.ts.map +1 -0
- package/dist/brief/sanitize.js +48 -0
- package/dist/brief/selectors.d.ts +36 -0
- package/dist/brief/selectors.d.ts.map +1 -0
- package/dist/brief/selectors.js +75 -0
- package/dist/brief/story.d.ts +18 -0
- package/dist/brief/story.d.ts.map +1 -0
- package/dist/brief/story.js +59 -0
- package/dist/brief/types.d.ts +126 -0
- package/dist/brief/types.d.ts.map +1 -0
- package/dist/brief/types.js +11 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +199 -0
- package/dist/cli/init-args.d.ts +16 -0
- package/dist/cli/init-args.d.ts.map +1 -0
- package/dist/cli/init-args.js +24 -0
- package/dist/cli/ui-args.d.ts +23 -0
- package/dist/cli/ui-args.d.ts.map +1 -0
- package/dist/cli/ui-args.js +66 -0
- package/dist/cli/ui.d.ts +40 -0
- package/dist/cli/ui.d.ts.map +1 -0
- package/dist/cli/ui.js +180 -0
- package/dist/coordinatorium/checkpoint.d.ts +44 -0
- package/dist/coordinatorium/checkpoint.d.ts.map +1 -0
- package/dist/coordinatorium/checkpoint.js +124 -0
- package/dist/coordinatorium/cli.d.ts +39 -0
- package/dist/coordinatorium/cli.d.ts.map +1 -0
- package/dist/coordinatorium/cli.js +203 -0
- package/dist/coordinatorium/errors.d.ts +112 -0
- package/dist/coordinatorium/errors.d.ts.map +1 -0
- package/dist/coordinatorium/errors.js +145 -0
- package/dist/coordinatorium/index.d.ts +11 -0
- package/dist/coordinatorium/index.d.ts.map +1 -0
- package/dist/coordinatorium/index.js +5 -0
- package/dist/coordinatorium/lock.d.ts +187 -0
- package/dist/coordinatorium/lock.d.ts.map +1 -0
- package/dist/coordinatorium/lock.js +659 -0
- package/dist/coordinatorium/mission.d.ts +32 -0
- package/dist/coordinatorium/mission.d.ts.map +1 -0
- package/dist/coordinatorium/mission.js +87 -0
- package/dist/coordinatorium/state-keeper.d.ts +115 -0
- package/dist/coordinatorium/state-keeper.d.ts.map +1 -0
- package/dist/coordinatorium/state-keeper.js +396 -0
- package/dist/coordinatorium/types.d.ts +69 -0
- package/dist/coordinatorium/types.d.ts.map +1 -0
- package/dist/coordinatorium/types.js +27 -0
- package/dist/discovery/compose.d.ts +28 -0
- package/dist/discovery/compose.d.ts.map +1 -0
- package/dist/discovery/compose.js +159 -0
- package/dist/discovery/contracts.d.ts +211 -0
- package/dist/discovery/contracts.d.ts.map +1 -0
- package/dist/discovery/contracts.js +555 -0
- package/dist/discovery/docs.d.ts +278 -0
- package/dist/discovery/docs.d.ts.map +1 -0
- package/dist/discovery/docs.js +1182 -0
- package/dist/discovery/facts.d.ts +49 -0
- package/dist/discovery/facts.d.ts.map +1 -0
- package/dist/discovery/facts.js +541 -0
- package/dist/discovery/index.d.ts +8 -0
- package/dist/discovery/index.d.ts.map +1 -0
- package/dist/discovery/index.js +9 -0
- package/dist/discovery/orchestrate.d.ts +35 -0
- package/dist/discovery/orchestrate.d.ts.map +1 -0
- package/dist/discovery/orchestrate.js +32 -0
- package/dist/discovery/render.d.ts +36 -0
- package/dist/discovery/render.d.ts.map +1 -0
- package/dist/discovery/render.js +278 -0
- package/dist/discovery/traverse.d.ts +197 -0
- package/dist/discovery/traverse.d.ts.map +1 -0
- package/dist/discovery/traverse.js +510 -0
- package/dist/durable/assess.d.ts +105 -0
- package/dist/durable/assess.d.ts.map +1 -0
- package/dist/durable/assess.js +239 -0
- package/dist/durable/canonical.d.ts +25 -0
- package/dist/durable/canonical.d.ts.map +1 -0
- package/dist/durable/canonical.js +78 -0
- package/dist/durable/cli.d.ts +37 -0
- package/dist/durable/cli.d.ts.map +1 -0
- package/dist/durable/cli.js +141 -0
- package/dist/durable/errors.d.ts +192 -0
- package/dist/durable/errors.d.ts.map +1 -0
- package/dist/durable/errors.js +323 -0
- package/dist/durable/fs-store.d.ts +254 -0
- package/dist/durable/fs-store.d.ts.map +1 -0
- package/dist/durable/fs-store.js +1493 -0
- package/dist/durable/index.d.ts +20 -0
- package/dist/durable/index.d.ts.map +1 -0
- package/dist/durable/index.js +13 -0
- package/dist/durable/log.d.ts +33 -0
- package/dist/durable/log.d.ts.map +1 -0
- package/dist/durable/log.js +157 -0
- package/dist/durable/memory-store.d.ts +51 -0
- package/dist/durable/memory-store.d.ts.map +1 -0
- package/dist/durable/memory-store.js +302 -0
- package/dist/durable/projection.d.ts +35 -0
- package/dist/durable/projection.d.ts.map +1 -0
- package/dist/durable/projection.js +328 -0
- package/dist/durable/prune-check.d.ts +34 -0
- package/dist/durable/prune-check.d.ts.map +1 -0
- package/dist/durable/prune-check.js +72 -0
- package/dist/durable/register.d.ts +100 -0
- package/dist/durable/register.d.ts.map +1 -0
- package/dist/durable/register.js +532 -0
- package/dist/durable/retention.d.ts +49 -0
- package/dist/durable/retention.d.ts.map +1 -0
- package/dist/durable/retention.js +59 -0
- package/dist/durable/runtime.d.ts +499 -0
- package/dist/durable/runtime.d.ts.map +1 -0
- package/dist/durable/runtime.js +1288 -0
- package/dist/durable/seams.d.ts +44 -0
- package/dist/durable/seams.d.ts.map +1 -0
- package/dist/durable/seams.js +21 -0
- package/dist/durable/testing.d.ts +11 -0
- package/dist/durable/testing.d.ts.map +1 -0
- package/dist/durable/testing.js +25 -0
- package/dist/durable/types.d.ts +442 -0
- package/dist/durable/types.d.ts.map +1 -0
- package/dist/durable/types.js +75 -0
- package/dist/graph/builder.d.ts +11 -0
- package/dist/graph/builder.d.ts.map +1 -0
- package/dist/graph/builder.js +153 -0
- package/dist/graph/identity.d.ts +37 -0
- package/dist/graph/identity.d.ts.map +1 -0
- package/dist/graph/identity.js +46 -0
- package/dist/graph/index.d.ts +7 -0
- package/dist/graph/index.d.ts.map +1 -0
- package/dist/graph/index.js +3 -0
- package/dist/graph/resolver.d.ts +41 -0
- package/dist/graph/resolver.d.ts.map +1 -0
- package/dist/graph/resolver.js +36 -0
- package/dist/graph/types.d.ts +42 -0
- package/dist/graph/types.d.ts.map +1 -0
- package/dist/graph/types.js +1 -0
- package/dist/http/index.d.ts +5 -0
- package/dist/http/index.d.ts.map +1 -0
- package/dist/http/index.js +2 -0
- package/dist/http/server.d.ts +76 -0
- package/dist/http/server.d.ts.map +1 -0
- package/dist/http/server.js +195 -0
- package/dist/http/ui-assets.d.ts +22 -0
- package/dist/http/ui-assets.d.ts.map +1 -0
- package/dist/http/ui-assets.js +100 -0
- package/dist/ideas/cli.d.ts +33 -0
- package/dist/ideas/cli.d.ts.map +1 -0
- package/dist/ideas/cli.js +158 -0
- package/dist/ideas/format.d.ts +38 -0
- package/dist/ideas/format.d.ts.map +1 -0
- package/dist/ideas/format.js +194 -0
- package/dist/ideas/index.d.ts +6 -0
- package/dist/ideas/index.d.ts.map +1 -0
- package/dist/ideas/index.js +3 -0
- package/dist/ideas/store.d.ts +55 -0
- package/dist/ideas/store.d.ts.map +1 -0
- package/dist/ideas/store.js +262 -0
- package/dist/ideas/types.d.ts +54 -0
- package/dist/ideas/types.d.ts.map +1 -0
- package/dist/ideas/types.js +26 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/init/index.d.ts +12 -0
- package/dist/init/index.d.ts.map +1 -0
- package/dist/init/index.js +90 -0
- package/dist/init/prompts.d.ts +3 -0
- package/dist/init/prompts.d.ts.map +1 -0
- package/dist/init/prompts.js +47 -0
- package/dist/init/scaffold.d.ts +29 -0
- package/dist/init/scaffold.d.ts.map +1 -0
- package/dist/init/scaffold.js +208 -0
- package/dist/init/types.d.ts +14 -0
- package/dist/init/types.d.ts.map +1 -0
- package/dist/init/types.js +1 -0
- package/dist/managed/index.d.ts +73 -0
- package/dist/managed/index.d.ts.map +1 -0
- package/dist/managed/index.js +222 -0
- package/dist/readmodel/dashboard.d.ts +40 -0
- package/dist/readmodel/dashboard.d.ts.map +1 -0
- package/dist/readmodel/dashboard.js +236 -0
- package/dist/readmodel/index.d.ts +3 -0
- package/dist/readmodel/index.d.ts.map +1 -0
- package/dist/readmodel/index.js +1 -0
- package/dist/readmodel/types.d.ts +104 -0
- package/dist/readmodel/types.d.ts.map +1 -0
- package/dist/readmodel/types.js +15 -0
- package/dist/root/index.d.ts +186 -0
- package/dist/root/index.d.ts.map +1 -0
- package/dist/root/index.js +430 -0
- package/dist/root/safe-write.d.ts +268 -0
- package/dist/root/safe-write.d.ts.map +1 -0
- package/dist/root/safe-write.js +966 -0
- package/dist/root/write-artifacts.d.ts +20 -0
- package/dist/root/write-artifacts.d.ts.map +1 -0
- package/dist/root/write-artifacts.js +42 -0
- package/dist/scriptorium/compile.d.ts +4 -0
- package/dist/scriptorium/compile.d.ts.map +1 -0
- package/dist/scriptorium/compile.js +185 -0
- package/dist/scriptorium/frontmatter.d.ts +13 -0
- package/dist/scriptorium/frontmatter.d.ts.map +1 -0
- package/dist/scriptorium/frontmatter.js +90 -0
- package/dist/scriptorium/index.d.ts +3 -0
- package/dist/scriptorium/index.d.ts.map +1 -0
- package/dist/scriptorium/index.js +1 -0
- package/dist/scriptorium/markdown.d.ts +31 -0
- package/dist/scriptorium/markdown.d.ts.map +1 -0
- package/dist/scriptorium/markdown.js +88 -0
- package/dist/scriptorium/types.d.ts +78 -0
- package/dist/scriptorium/types.d.ts.map +1 -0
- package/dist/scriptorium/types.js +1 -0
- package/dist/types/enforcement.d.ts +11 -0
- package/dist/types/enforcement.d.ts.map +1 -0
- package/dist/types/enforcement.js +1 -0
- package/dist/types/integrity.d.ts +33 -0
- package/dist/types/integrity.d.ts.map +1 -0
- package/dist/types/integrity.js +1 -0
- package/dist/types/project-definition.d.ts +30 -0
- package/dist/types/project-definition.d.ts.map +1 -0
- package/dist/types/project-definition.js +1 -0
- package/dist/ui/assets/cosmic-glass-bg-Dwx47zPu.webp +0 -0
- package/dist/ui/assets/index-C4NhMaq7.js +28 -0
- package/dist/ui/assets/index-DMZ7ZvZY.css +1 -0
- package/dist/ui/index.html +13 -0
- package/dist/update/cli.d.ts +8 -0
- package/dist/update/cli.d.ts.map +1 -0
- package/dist/update/cli.js +115 -0
- package/dist/update/index.d.ts +78 -0
- package/dist/update/index.d.ts.map +1 -0
- package/dist/update/index.js +285 -0
- package/dist/validate/index.d.ts +6 -0
- package/dist/validate/index.d.ts.map +1 -0
- package/dist/validate/index.js +214 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +1 -0
- package/package.json +67 -4
- package/templates/.gitkeep +0 -0
- package/templates/default-instance/instruction/.cursorrules +59 -0
- package/templates/default-instance/instruction/.windsurfrules +59 -0
- package/templates/default-instance/instruction/CLAUDE.md +57 -0
- package/templates/default-instance/managed/agent.md +20 -0
- package/templates/default-instance/managed/bootstrap.md +7 -0
- package/templates/default-instance/managed/index-idea.md +5 -0
- package/templates/default-instance/managed/routing-idea.md +14 -0
- package/templates/default-instance/monolith/AGENT.md +1 -0
- package/templates/default-instance/monolith/context/boot/HANDOFF.md +49 -0
- package/templates/default-instance/monolith/context/boot/WORK_SESSION.md +30 -0
- package/templates/default-instance/monolith/context/execution/current-state.md +30 -0
- package/templates/default-instance/monolith/context/maps/dependency-map.md +38 -0
- package/templates/default-instance/monolith/context/maps/project-map.md +85 -0
- package/templates/default-instance/monolith/context/maps/roadmap-index.md +41 -0
- package/templates/default-instance/monolith/context/maps/routing-map.md +151 -0
- package/templates/default-instance/monolith/context/maps/semantic-map.md +75 -0
- package/templates/default-instance/monolith/context/models/model-registry.md +37 -0
- package/templates/default-instance/monolith/context/models/privacy-classification.md +35 -0
- package/templates/default-instance/monolith/context/templates/plan-template.md +56 -0
- package/templates/default-instance/monolith/governance/README.md +29 -0
- package/templates/default-instance/monolith/governance/RULE_SCHEMA.md +58 -0
- package/templates/default-instance/monolith/learning/INDEX.md +48 -0
- package/templates/default-instance/monolith/learning/injection-map.md +49 -0
- package/templates/default-instance/monolith/learning/taxonomy.md +30 -0
- package/templates/default-instance/monolith/memory/errors/README.md +26 -0
- package/templates/default-instance/monolith/memory/errors/SCHEMA.md +47 -0
- package/templates/default-instance/monolith/memory/errors/TAXONOMY.md +27 -0
- package/templates/default-instance/monolith/memory/long-term/architecture-principles.md +31 -0
- package/templates/default-instance/monolith/memory/long-term/decisions.md +36 -0
- package/templates/default-instance/monolith/memory/long-term/execution-history.md +20 -0
- package/templates/default-instance/monolith/memory/long-term/tech-debt.md +25 -0
- package/templates/default-instance/monolith/memory/working/active.md +41 -0
- package/templates/default-instance/monolith/memory/working/governance-result.md +0 -0
- package/templates/default-instance/monolith/memory/working/integrity-result.md +0 -0
- package/templates/default-instance/monolith/memory/working/story-index.md +28 -0
- package/templates/default-instance/monolith/protocols/boot/boot-sequence.md +59 -0
- package/templates/default-instance/monolith/protocols/cognition/cognitive-modes.md +90 -0
- package/templates/default-instance/monolith/protocols/cognition/dry-run.md +56 -0
- package/templates/default-instance/monolith/protocols/cognition/execution-trace-format.md +52 -0
- package/templates/default-instance/monolith/protocols/cognition/semantic-planning.md +51 -0
- package/templates/default-instance/monolith/protocols/execution/hybrid-execution.md +37 -0
- package/templates/default-instance/monolith/protocols/execution/local-llm-governance.md +42 -0
- package/templates/default-instance/monolith/protocols/governance/command-policy.md +51 -0
- package/templates/default-instance/monolith/protocols/governance/core-invariants.md +40 -0
- package/templates/default-instance/monolith/protocols/governance/memory-governance.md +54 -0
- package/templates/default-instance/monolith/protocols/governance/metadata-schema.md +62 -0
- package/templates/default-instance/monolith/protocols/governance/skills.md +53 -0
- package/templates/default-instance/monolith/protocols/governance/work-session.md +46 -0
- package/templates/default-instance/monolith/skills/INDEX.md +32 -0
- package/templates/default-instance/monolith/skills/current-status/SKILL.md +47 -0
- package/templates/default-instance/monolith/skills/finalize-story/SKILL.md +86 -0
- package/templates/default-instance/monolith/skills/global-status/SKILL.md +56 -0
- package/templates/default-instance/monolith/skills/idea-capture/SKILL.md +157 -0
- package/templates/default-instance/monolith/skills/self-improvement/SKILL.md +77 -0
- package/templates/default-instance/monolith/state.json +11 -0
- package/templates/default-instance/monolith/tests/INDEX.md +57 -0
- package/templates/default-instance/monolith/tests/scenarios/architecture-review.md +32 -0
- package/templates/default-instance/monolith/tests/scenarios/debug-failure.md +32 -0
- package/templates/default-instance/monolith/tests/scenarios/dry-run-activation.md +33 -0
- package/templates/default-instance/monolith/tests/scenarios/execution-trace-verification.md +31 -0
- package/templates/default-instance/monolith/tests/scenarios/finalize-story.md +35 -0
- package/templates/default-instance/monolith/tests/scenarios/implement-feature.md +36 -0
- package/templates/default-instance/monolith/tests/scenarios/local-llm-delegation.md +31 -0
- package/templates/default-instance/monolith/tests/scenarios/planning-request.md +32 -0
- package/templates/default-instance/monolith/tests/scenarios/sensitive-context-task.md +30 -0
- package/templates/default-instance/monolith/tests/scenarios/validator-verification.md +33 -0
- package/templates/default-instance/monolith/tests/validation/expected-behavior.md +70 -0
- package/templates/default-instance/monolith/tests/validators/INDEX.md +17 -0
- package/templates/default-instance/monolith/tests/validators/delegation-semantics.md +22 -0
- package/templates/default-instance/monolith/tests/validators/mode-consistency.md +25 -0
- package/templates/default-instance/monolith/tests/validators/privacy-routing.md +23 -0
- package/templates/default-instance/monolith/tests/validators/protocol-references.md +27 -0
- package/templates/default-instance/monolith/tests/validators/routing-integrity.md +30 -0
- package/templates/default-instance/projectroot/AGENTS.md +111 -0
- package/templates/default-instance/projectroot/monolith.config.json +32 -0
- package/templates/default-instance/projectroot/project.definition.mjs.template +41 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* COORDINATORIUM — deterministic project state management subsystem.
|
|
3
|
+
*
|
|
4
|
+
* This file defines the v0.1 state schema. Tactical Coordinatorium
|
|
5
|
+
* (mission lifecycle) is implemented. Strategic Coordinatorium (product /
|
|
6
|
+
* subsystem state) is reserved — `strategic.systems` exists in the schema
|
|
7
|
+
* but nothing in this package writes to it yet.
|
|
8
|
+
*/
|
|
9
|
+
export declare const STATE_SCHEMA_VERSION = 2;
|
|
10
|
+
/**
|
|
11
|
+
* The only prior schema version `state-keeper.ts` knows how to migrate
|
|
12
|
+
* from. A v1 file has `tactical.missions` but no reliable
|
|
13
|
+
* `tactical.checkpoints` (COORDINATORIUM-002 bumped the version precisely
|
|
14
|
+
* so that a pre-002 binary — hardcoded to `STATE_SCHEMA_VERSION === 1` —
|
|
15
|
+
* refuses to touch a v2 file instead of silently dropping its checkpoints
|
|
16
|
+
* on its next read-modify-write cycle; see ADR-008's 2026-10-21
|
|
17
|
+
* COORDINATORIUM-002 compatibility-fix addendum).
|
|
18
|
+
*/
|
|
19
|
+
export declare const LEGACY_SCHEMA_VERSION_V1 = 1;
|
|
20
|
+
export type MissionStatus = 'in_progress' | 'completed' | 'failed' | 'cancelled';
|
|
21
|
+
export type MissionResult = Exclude<MissionStatus, 'in_progress'>;
|
|
22
|
+
export interface Mission {
|
|
23
|
+
id: string;
|
|
24
|
+
title: string;
|
|
25
|
+
system: string;
|
|
26
|
+
status: MissionStatus;
|
|
27
|
+
startedAt: string;
|
|
28
|
+
updatedAt: string;
|
|
29
|
+
summary: string | null;
|
|
30
|
+
}
|
|
31
|
+
/** Reserved for the Strategic Coordinatorium. No mutations in v0.1. */
|
|
32
|
+
export interface StrategicState {
|
|
33
|
+
systems: Record<string, unknown>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* A durable, append-only progress note attached to exactly one Mission
|
|
37
|
+
* (COORDINATORIUM-002). Checkpoints are never updated or deleted once
|
|
38
|
+
* created — `id` and `createdAt` are stamped by the keeper, never
|
|
39
|
+
* caller-supplied, exactly like `Mission.id`/`startedAt`.
|
|
40
|
+
*/
|
|
41
|
+
export interface Checkpoint {
|
|
42
|
+
id: string;
|
|
43
|
+
missionId: string;
|
|
44
|
+
createdAt: string;
|
|
45
|
+
summary: string;
|
|
46
|
+
remainingSteps: string[];
|
|
47
|
+
context: string | null;
|
|
48
|
+
}
|
|
49
|
+
export interface TacticalState {
|
|
50
|
+
missions: Record<string, Mission>;
|
|
51
|
+
/**
|
|
52
|
+
* Sibling top-level map to `missions`, not nested inside `Mission` — see
|
|
53
|
+
* ADR-008's 2026-10-21 Mission Checkpoints addendum. Required for
|
|
54
|
+
* `schemaVersion: 2` (the current, in-memory shape returned by
|
|
55
|
+
* `validateState`/`readState` — every v2 writer always includes it).
|
|
56
|
+
* A `schemaVersion: 1` file on disk may be missing this key entirely;
|
|
57
|
+
* `state-keeper.ts`'s v1→v2 migration defaults it to `{}` on read. See
|
|
58
|
+
* `LEGACY_SCHEMA_VERSION_V1`.
|
|
59
|
+
*/
|
|
60
|
+
checkpoints: Record<string, Checkpoint>;
|
|
61
|
+
}
|
|
62
|
+
export interface CoordinatoriumState {
|
|
63
|
+
schemaVersion: typeof STATE_SCHEMA_VERSION;
|
|
64
|
+
revision: number;
|
|
65
|
+
strategic: StrategicState;
|
|
66
|
+
tactical: TacticalState;
|
|
67
|
+
}
|
|
68
|
+
export declare function createInitialState(): CoordinatoriumState;
|
|
69
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/coordinatorium/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,eAAO,MAAM,oBAAoB,IAAI,CAAC;AAEtC;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAE1C,MAAM,MAAM,aAAa,GAAG,aAAa,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,CAAC;AAEjF,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;AAElE,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,aAAa,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED,uEAAuE;AACvE,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC;;;;;;;;OAQG;IACH,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CACzC;AAED,MAAM,WAAW,mBAAmB;IAClC,aAAa,EAAE,OAAO,oBAAoB,CAAC;IAC3C,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,cAAc,CAAC;IAC1B,QAAQ,EAAE,aAAa,CAAC;CACzB;AAED,wBAAgB,kBAAkB,IAAI,mBAAmB,CAOxD"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* COORDINATORIUM — deterministic project state management subsystem.
|
|
3
|
+
*
|
|
4
|
+
* This file defines the v0.1 state schema. Tactical Coordinatorium
|
|
5
|
+
* (mission lifecycle) is implemented. Strategic Coordinatorium (product /
|
|
6
|
+
* subsystem state) is reserved — `strategic.systems` exists in the schema
|
|
7
|
+
* but nothing in this package writes to it yet.
|
|
8
|
+
*/
|
|
9
|
+
export const STATE_SCHEMA_VERSION = 2;
|
|
10
|
+
/**
|
|
11
|
+
* The only prior schema version `state-keeper.ts` knows how to migrate
|
|
12
|
+
* from. A v1 file has `tactical.missions` but no reliable
|
|
13
|
+
* `tactical.checkpoints` (COORDINATORIUM-002 bumped the version precisely
|
|
14
|
+
* so that a pre-002 binary — hardcoded to `STATE_SCHEMA_VERSION === 1` —
|
|
15
|
+
* refuses to touch a v2 file instead of silently dropping its checkpoints
|
|
16
|
+
* on its next read-modify-write cycle; see ADR-008's 2026-10-21
|
|
17
|
+
* COORDINATORIUM-002 compatibility-fix addendum).
|
|
18
|
+
*/
|
|
19
|
+
export const LEGACY_SCHEMA_VERSION_V1 = 1;
|
|
20
|
+
export function createInitialState() {
|
|
21
|
+
return {
|
|
22
|
+
schemaVersion: STATE_SCHEMA_VERSION,
|
|
23
|
+
revision: 0,
|
|
24
|
+
strategic: { systems: {} },
|
|
25
|
+
tactical: { missions: {}, checkpoints: {} },
|
|
26
|
+
};
|
|
27
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DISCOVERY-001C — unified Project Map composer (ADR-021). Internal.
|
|
3
|
+
*
|
|
4
|
+
* A pure transformation of TWO finished results into one Markdown text: a `DiscoveryResult`
|
|
5
|
+
* (structural facts, evidence OBSERVED_FILE-class) and a `DocumentationResult` (what documents
|
|
6
|
+
* claim, evidence DOCUMENT_TEXT). It reads no file, starts no analyzer, calls no model, opens no
|
|
7
|
+
* connection, keeps no clock and modifies neither input.
|
|
8
|
+
*
|
|
9
|
+
* Identity. Neither contract carries a project identity (no id, no root, no digest); both only say
|
|
10
|
+
* that they were derived from "a traversal". So the composer cannot confirm that the two results
|
|
11
|
+
* describe the same project and says so in the output. It does not guess from paths or names.
|
|
12
|
+
*
|
|
13
|
+
* Trust. The two sources are never merged: structure comes from the existing renderer, unchanged;
|
|
14
|
+
* documentation gets its own section, and every statement made by a document is shown as an
|
|
15
|
+
* unverified claim. The statuses of the two analyzers are shown side by side, never combined.
|
|
16
|
+
*
|
|
17
|
+
* Markdown safety. Every untrusted string goes through the renderer's `markdownCodeSpan` (control and
|
|
18
|
+
* bidi characters are shown as [U+XXXX], an inline code span cannot be closed by its content) and sits
|
|
19
|
+
* in a list item; headings and structure are fixed text. Document text is never interpreted.
|
|
20
|
+
*/
|
|
21
|
+
import { type DiscoveryResult } from './contracts.js';
|
|
22
|
+
import { type DocumentationResult } from './docs.js';
|
|
23
|
+
/**
|
|
24
|
+
* Composes the unified Project Map. Throws `DiscoveryError('RESULT_INVALID')` if either input fails
|
|
25
|
+
* its own validator (the message names which input and the first violations, never a value).
|
|
26
|
+
*/
|
|
27
|
+
export declare function composeProjectMap(discovery: DiscoveryResult, documentation: DocumentationResult): string;
|
|
28
|
+
//# sourceMappingURL=compose.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../../src/discovery/compose.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EAAqD,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACzG,OAAO,EAKL,KAAK,mBAAmB,EAEzB,MAAM,WAAW,CAAC;AAgCnB;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,eAAe,EAAE,aAAa,EAAE,mBAAmB,GAAG,MAAM,CAoGxG"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DISCOVERY-001C — unified Project Map composer (ADR-021). Internal.
|
|
3
|
+
*
|
|
4
|
+
* A pure transformation of TWO finished results into one Markdown text: a `DiscoveryResult`
|
|
5
|
+
* (structural facts, evidence OBSERVED_FILE-class) and a `DocumentationResult` (what documents
|
|
6
|
+
* claim, evidence DOCUMENT_TEXT). It reads no file, starts no analyzer, calls no model, opens no
|
|
7
|
+
* connection, keeps no clock and modifies neither input.
|
|
8
|
+
*
|
|
9
|
+
* Identity. Neither contract carries a project identity (no id, no root, no digest); both only say
|
|
10
|
+
* that they were derived from "a traversal". So the composer cannot confirm that the two results
|
|
11
|
+
* describe the same project and says so in the output. It does not guess from paths or names.
|
|
12
|
+
*
|
|
13
|
+
* Trust. The two sources are never merged: structure comes from the existing renderer, unchanged;
|
|
14
|
+
* documentation gets its own section, and every statement made by a document is shown as an
|
|
15
|
+
* unverified claim. The statuses of the two analyzers are shown side by side, never combined.
|
|
16
|
+
*
|
|
17
|
+
* Markdown safety. Every untrusted string goes through the renderer's `markdownCodeSpan` (control and
|
|
18
|
+
* bidi characters are shown as [U+XXXX], an inline code span cannot be closed by its content) and sits
|
|
19
|
+
* in a list item; headings and structure are fixed text. Document text is never interpreted.
|
|
20
|
+
*/
|
|
21
|
+
import { DiscoveryError } from './contracts.js';
|
|
22
|
+
import { validateDiscoveryResult } from './contracts.js';
|
|
23
|
+
import { DOCUMENTATION_DIAGNOSTIC_AFFECTS_COMPLETENESS, validateDocumentationResult, } from './docs.js';
|
|
24
|
+
import { markdownCodeSpan as code, renderProjectMapProposal } from './render.js';
|
|
25
|
+
const plural = (n, one, many) => `${n} ${n === 1 ? one : many}`;
|
|
26
|
+
function textShown(text, status) {
|
|
27
|
+
if (status === 'WITHHELD')
|
|
28
|
+
return '(withheld: contains unsafe characters)';
|
|
29
|
+
return status === 'TRUNCATED' ? `${code(text)} (truncated)` : code(text);
|
|
30
|
+
}
|
|
31
|
+
function lines(o) {
|
|
32
|
+
const { startLine, endLine } = o.source;
|
|
33
|
+
if (startLine === undefined)
|
|
34
|
+
return 'whole file';
|
|
35
|
+
return endLine === undefined || endLine === startLine ? `line ${startLine}` : `lines ${startLine}-${endLine}`;
|
|
36
|
+
}
|
|
37
|
+
function docDiagnosticLine(d) {
|
|
38
|
+
const known = Object.prototype.hasOwnProperty.call(DOCUMENTATION_DIAGNOSTIC_AFFECTS_COMPLETENESS, d.code);
|
|
39
|
+
const origin = d.code.startsWith('TRAVERSAL_')
|
|
40
|
+
? 'reported by the traversal'
|
|
41
|
+
: known && DOCUMENTATION_DIAGNOSTIC_AFFECTS_COMPLETENESS[d.code]
|
|
42
|
+
? 'documentation analysis; makes the result PARTIAL'
|
|
43
|
+
: 'documentation analysis; does not by itself make the result PARTIAL';
|
|
44
|
+
const parts = [`${code(d.code)} (${origin})`];
|
|
45
|
+
if (d.path !== undefined)
|
|
46
|
+
parts.push(`path ${code(d.path)}`);
|
|
47
|
+
if (d.count !== undefined)
|
|
48
|
+
parts.push(`count ${d.count}`);
|
|
49
|
+
return `- ${parts.join(', ')}: ${code(d.message)}`;
|
|
50
|
+
}
|
|
51
|
+
/** Lowers every heading of the (trusted, fixed-text) renderer output by two levels. Project data cannot start a line with `#`: it only appears inside code spans, and line breaks inside it are escaped. */
|
|
52
|
+
const demote = (markdown) => markdown.replace(/^(#+) /gm, '##$1 ');
|
|
53
|
+
/**
|
|
54
|
+
* Composes the unified Project Map. Throws `DiscoveryError('RESULT_INVALID')` if either input fails
|
|
55
|
+
* its own validator (the message names which input and the first violations, never a value).
|
|
56
|
+
*/
|
|
57
|
+
export function composeProjectMap(discovery, documentation) {
|
|
58
|
+
const dv = validateDiscoveryResult(discovery);
|
|
59
|
+
if (dv.length > 0)
|
|
60
|
+
throw new DiscoveryError('RESULT_INVALID', `cannot compose: the DiscoveryResult failed validation (${dv.length} violation(s)): ${dv.slice(0, 3).join('; ')}`);
|
|
61
|
+
const cv = validateDocumentationResult(documentation);
|
|
62
|
+
if (cv.length > 0)
|
|
63
|
+
throw new DiscoveryError('RESULT_INVALID', `cannot compose: the DocumentationResult failed validation (${cv.length} violation(s)): ${cv.slice(0, 3).join('; ')}`);
|
|
64
|
+
const out = [];
|
|
65
|
+
const line = (s = '') => void out.push(s);
|
|
66
|
+
line('# PROJECT MAP');
|
|
67
|
+
line();
|
|
68
|
+
line('This document puts two separate results side by side: structure observed in the project tree, and what the project’s Markdown documents say. They are not merged and not compared with each other. It is a proposal for a reader to review.');
|
|
69
|
+
// ------------------------------------------------------------ structure
|
|
70
|
+
line();
|
|
71
|
+
line('## Observed Project Structure');
|
|
72
|
+
line();
|
|
73
|
+
line('- Source: a Discovery result (evidence from the traversal: directory entries, file names, package.json fields).');
|
|
74
|
+
line('- Where the text below says documentation was not analysed, it refers to this Discovery result only; see Documentation Overview for the separate documentation result.');
|
|
75
|
+
line();
|
|
76
|
+
out.push(demote(renderProjectMapProposal(discovery)).replace(/\n+$/, ''));
|
|
77
|
+
// ---------------------------------------------------------------- docs
|
|
78
|
+
const { stats, observations } = documentation;
|
|
79
|
+
line();
|
|
80
|
+
line('## Documentation Overview');
|
|
81
|
+
line();
|
|
82
|
+
line('- Source: a Documentation result. Everything below is the content of documents as written by their authors. It is UNVERIFIED: it has not been compared with the code and may be wrong or out of date.');
|
|
83
|
+
line(`- Analysis completeness: ${documentation.completeness}`);
|
|
84
|
+
line(documentation.completeness === 'PARTIAL'
|
|
85
|
+
? ' - Some documentation information was not extracted; see Diagnostics below. Counts are lower bounds.'
|
|
86
|
+
: ' - Everything inside the declared scope was handled. COMPLETE does not mean that every Markdown construct was recognised; see the supported subset in Trust & Coverage Notes.');
|
|
87
|
+
line(`- Reproducible: ${documentation.reproducible ? 'Yes' : 'No'}`);
|
|
88
|
+
line(`- Traversal behind it: completeness ${documentation.traversal.completeness}, reproducible ${documentation.traversal.reproducible ? 'Yes' : 'No'}`);
|
|
89
|
+
line(`- Schema version: ${documentation.schemaVersion}`);
|
|
90
|
+
line(`- Documents listed as present: ${stats.candidateDocuments}; analysed: ${stats.documentsAnalyzed}; present but not analysed: ${stats.documentsNotAnalyzed}`);
|
|
91
|
+
line(`- Bytes read: ${stats.bytesRead}; observations recorded: ${stats.observations}`);
|
|
92
|
+
const byPath = new Map();
|
|
93
|
+
for (const o of observations) {
|
|
94
|
+
const g = byPath.get(o.source.path);
|
|
95
|
+
if (g)
|
|
96
|
+
g.push(o);
|
|
97
|
+
else
|
|
98
|
+
byPath.set(o.source.path, [o]);
|
|
99
|
+
}
|
|
100
|
+
line();
|
|
101
|
+
line('### Documents');
|
|
102
|
+
line();
|
|
103
|
+
if (byPath.size === 0)
|
|
104
|
+
line('- No documents were recorded.');
|
|
105
|
+
for (const [path, group] of byPath) {
|
|
106
|
+
line(`- ${code(path)}`);
|
|
107
|
+
for (const o of group) {
|
|
108
|
+
if (o.kind === 'DOCUMENT_PRESENT') {
|
|
109
|
+
const size = [o.bytes === undefined ? '' : plural(o.bytes, 'byte', 'bytes'), o.lines === undefined ? '' : plural(o.lines, 'line', 'lines')].filter(Boolean).join(', ');
|
|
110
|
+
line(` - File observed (evidence ${o.evidence}); ${o.analysis === 'ANALYZED' ? 'content analysed' : 'content NOT analysed'}${size ? `; ${size}` : ''}`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
const headings = group.filter((o) => o.kind === 'HEADING');
|
|
114
|
+
const sections = group.filter((o) => o.kind === 'SECTION');
|
|
115
|
+
const links = group.filter((o) => o.kind === 'LINK');
|
|
116
|
+
if (headings.length > 0) {
|
|
117
|
+
line(` - Headings written in the document (${headings.length} recorded; evidence ${headings[0].evidence}):`);
|
|
118
|
+
for (const o of headings)
|
|
119
|
+
if (o.kind === 'HEADING')
|
|
120
|
+
line(` - ${lines(o)}, level ${o.level}: ${textShown(o.text, o.textStatus)}`);
|
|
121
|
+
}
|
|
122
|
+
if (sections.length > 0) {
|
|
123
|
+
line(` - Text ranges between headings (${sections.length} recorded; evidence ${sections[0].evidence}):`);
|
|
124
|
+
for (const o of sections)
|
|
125
|
+
if (o.kind === 'SECTION')
|
|
126
|
+
line(` - ${lines(o)}, opened by heading ${o.headingOrdinal}${o.parentHeadingOrdinal === undefined ? '' : ` under heading ${o.parentHeadingOrdinal}`}: ${plural(o.ownTextLineGroups, 'text line group', 'text line groups')} of its own`);
|
|
127
|
+
}
|
|
128
|
+
if (links.length > 0) {
|
|
129
|
+
line(` - Inline links written in the document (${links.length} recorded, not necessarily all; evidence ${links[0].evidence}; targets are not resolved or checked):`);
|
|
130
|
+
for (const o of links)
|
|
131
|
+
if (o.kind === 'LINK')
|
|
132
|
+
line(` - ${lines(o)}, ${o.linkType}: target ${code(o.target)}, text ${textShown(o.text, o.textStatus)}`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
line();
|
|
136
|
+
line('### Documentation Diagnostics');
|
|
137
|
+
line();
|
|
138
|
+
if (documentation.diagnostics.length === 0)
|
|
139
|
+
line('- No diagnostics were reported.');
|
|
140
|
+
for (const d of documentation.diagnostics)
|
|
141
|
+
line(docDiagnosticLine(d));
|
|
142
|
+
// --------------------------------------------------------------- trust
|
|
143
|
+
const limits = documentation.limits;
|
|
144
|
+
line();
|
|
145
|
+
line('## Trust & Coverage Notes');
|
|
146
|
+
line();
|
|
147
|
+
line('- Structural facts in Observed Project Structure were obtained by observing the file tree and, for package.json, declared fields. They are observations, not verified descriptions of how the project works.');
|
|
148
|
+
line('- Everything in Documentation Overview is unverified document content (evidence DOCUMENT_TEXT). The only observed item there is that a document file exists (evidence OBSERVED_FILE). No documentary statement has been confirmed by the code.');
|
|
149
|
+
line('- Common origin of the two results is NOT confirmed: neither result carries a project identity, so this document cannot tell whether they describe the same project or the same moment. No such link is asserted.');
|
|
150
|
+
line('- The two analyzers keep separate statuses and they are not combined:');
|
|
151
|
+
line(` - Structural Discovery: completeness ${discovery.completeness}, reproducible ${discovery.reproducible ? 'Yes' : 'No'}`);
|
|
152
|
+
line(` - Documentation Analysis: completeness ${documentation.completeness}, reproducible ${documentation.reproducible ? 'Yes' : 'No'}`);
|
|
153
|
+
line('- COMPLETE refers only to the scope each analyzer declares. It is not a statement that the project or its documents were fully understood.');
|
|
154
|
+
line('- Documentation scope: README.md at the project root and *.md files under docs/ that the traversal listed. Supported Markdown subset: ATX headings; one-line inline links; fenced code blocks, front matter, HTML comment lines and indented lines are skipped. Not recognised: setext headings, reference-style links, autolinks, images, raw HTML, constructs split over lines, headings or links inside quotes or lists.');
|
|
155
|
+
line('- Link and heading counts are counts of recognised constructs, not the number of links or headings in a document.');
|
|
156
|
+
line(`- Documentation limits: documents ${limits.maxDocuments}; bytes per document ${limits.maxDocumentBytes}; total bytes ${limits.maxTotalBytes}; headings per document ${limits.maxHeadingsPerDocument}; links per document ${limits.maxLinksPerDocument}; text length ${limits.maxTextLength}; link target length ${limits.maxTargetLength}; line length ${limits.maxLineLength}; observations ${limits.maxObservations}; diagnostics ${limits.maxDiagnostics}.`);
|
|
157
|
+
line('- Not observing something is not evidence that it does not exist.');
|
|
158
|
+
return `${out.join('\n')}\n`;
|
|
159
|
+
}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Discovery contract, schema version 1 (ADR-021 §2-§4). Internal: not exported from `src/index.ts`.
|
|
3
|
+
*
|
|
4
|
+
* A fact says what the project's bytes show (`DETECTED`) or what a named rule derived from
|
|
5
|
+
* DETECTED facts (`INTERPRETED`). Three properties are kept apart on purpose and never
|
|
6
|
+
* folded into one another:
|
|
7
|
+
* - `completeness`: did the scan cover what it declared (`COMPLETE` | `PARTIAL`);
|
|
8
|
+
* - `reproducible`: would a second scan of the same unchanged tree return this result;
|
|
9
|
+
* - `level` of a fact: how it was obtained. There is no numeric confidence.
|
|
10
|
+
*/
|
|
11
|
+
export declare const DISCOVERY_SCHEMA_VERSION = 1;
|
|
12
|
+
export type DiscoveryLevel = 'DETECTED' | 'INTERPRETED';
|
|
13
|
+
/** The level is a function of the kind (ADR-021 §2): never chosen per fact, checked by the validator. */
|
|
14
|
+
export declare const FACT_LEVEL_BY_KIND: {
|
|
15
|
+
/** A directory exists in the inventory. */
|
|
16
|
+
readonly DIRECTORY: "DETECTED";
|
|
17
|
+
/** A file with a conventional name exists (the basis of an entrypoint candidate). */
|
|
18
|
+
readonly FILE_PRESENT: "DETECTED";
|
|
19
|
+
/**
|
|
20
|
+
* `value` files with extension `object` exist; `subject` is the language that extension maps to.
|
|
21
|
+
* An aggregate: `value` counts every file the traversal listed, `sources` is only a sample of them
|
|
22
|
+
* (see `sourceCoverage`).
|
|
23
|
+
*/
|
|
24
|
+
readonly LANGUAGE_BY_EXTENSION: "DETECTED";
|
|
25
|
+
/** A file with the name of a known manifest exists. Says nothing about its content or about runtime use. */
|
|
26
|
+
readonly MANIFEST_PRESENT: "DETECTED";
|
|
27
|
+
/** A manifest declares dependency `object` in section `value`. Not resolved, not installed, not verified. */
|
|
28
|
+
readonly DEPENDENCY_DECLARED: "DETECTED";
|
|
29
|
+
/** A manifest declares a script named `object`. The command is never stored and never run. */
|
|
30
|
+
readonly SCRIPT_DECLARED: "DETECTED";
|
|
31
|
+
/** A file name convention suggests `subject` may start the program. A candidate, never a verified entrypoint. */
|
|
32
|
+
readonly ENTRYPOINT_CANDIDATE: "INTERPRETED";
|
|
33
|
+
};
|
|
34
|
+
export type DiscoveryFactKind = keyof typeof FACT_LEVEL_BY_KIND;
|
|
35
|
+
export type DiscoveryObservation = 'directory-entry' | 'file-entry' | 'extension' | 'file-name' | 'manifest-field';
|
|
36
|
+
export interface DiscoverySource {
|
|
37
|
+
/** Project-relative, `/`-separated; never absolute, never contains `..`. */
|
|
38
|
+
path: string;
|
|
39
|
+
/** What kind of observation backs the fact. */
|
|
40
|
+
observation: DiscoveryObservation;
|
|
41
|
+
/** For `manifest-field`: an RFC 6901 JSON Pointer into the manifest (e.g. `/dependencies/@scope~1pkg`). */
|
|
42
|
+
field?: string;
|
|
43
|
+
}
|
|
44
|
+
export interface DiscoveryFact {
|
|
45
|
+
/** 16 hex of sha256 over (schemaVersion, kind, subject, object, value); see `computeFactId`. */
|
|
46
|
+
id: string;
|
|
47
|
+
kind: DiscoveryFactKind;
|
|
48
|
+
level: DiscoveryLevel;
|
|
49
|
+
subject: string;
|
|
50
|
+
object?: string;
|
|
51
|
+
value?: string;
|
|
52
|
+
/** Name of the detection (DETECTED) or derivation (INTERPRETED) rule. */
|
|
53
|
+
rule: string;
|
|
54
|
+
/** INTERPRETED only: ids of the DETECTED facts the interpretation rests on. */
|
|
55
|
+
basis?: string[];
|
|
56
|
+
/**
|
|
57
|
+
* At least one; sorted. For a `LANGUAGE_BY_EXTENSION` aggregate these are a deterministic SAMPLE
|
|
58
|
+
* (the first `min(value, limits.maxSourcesPerFact)` paths in UTF-16 order), not the whole evidence:
|
|
59
|
+
* `value` is computed over all files and is checked against the sample size by the validator.
|
|
60
|
+
* Every other kind rests on exactly the sources it lists. See `sourceCoverage`.
|
|
61
|
+
*/
|
|
62
|
+
sources: DiscoverySource[];
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Whether a fact's `sources` are all of its evidence (`FULL`) or a sample of it (`SAMPLE`).
|
|
66
|
+
* Derived, not stored: only a `LANGUAGE_BY_EXTENSION` aggregate with more files than listed sources
|
|
67
|
+
* is a `SAMPLE`. Coverage says nothing about the scan: a count over a `PARTIAL` traversal is a lower
|
|
68
|
+
* bound, and that is stated by `DiscoveryResult.completeness` and `traversal.completeness`.
|
|
69
|
+
*/
|
|
70
|
+
export type SourceCoverage = 'FULL' | 'SAMPLE';
|
|
71
|
+
export declare function sourceCoverage(fact: Pick<DiscoveryFact, 'kind' | 'value' | 'sources'>): SourceCoverage;
|
|
72
|
+
/**
|
|
73
|
+
* Closed list. The value says whether the code makes the result `PARTIAL` (something inside the
|
|
74
|
+
* declared scope was not extracted) or only reports a scope policy or an unanalysed area.
|
|
75
|
+
*/
|
|
76
|
+
export declare const EXTRACTION_DIAGNOSTIC_AFFECTS_COMPLETENESS: {
|
|
77
|
+
readonly INPUT_PATH_REJECTED: true;
|
|
78
|
+
readonly LIMIT_DIRECTORY_FACTS: true;
|
|
79
|
+
readonly LIMIT_LANGUAGE_FACTS: true;
|
|
80
|
+
readonly LIMIT_MANIFEST_FACTS: true;
|
|
81
|
+
readonly LIMIT_MANIFEST_READS: true;
|
|
82
|
+
readonly LIMIT_DEPENDENCIES: true;
|
|
83
|
+
readonly LIMIT_SCRIPTS: true;
|
|
84
|
+
readonly LIMIT_ENTRYPOINT_FACTS: true;
|
|
85
|
+
readonly LIMIT_FACTS: true;
|
|
86
|
+
readonly LIMIT_DIAGNOSTICS: true;
|
|
87
|
+
readonly MANIFEST_READ_FAILED: true;
|
|
88
|
+
readonly MANIFEST_TOO_LARGE: true;
|
|
89
|
+
readonly MANIFEST_PARSE_ERROR: true;
|
|
90
|
+
readonly MANIFEST_FIELD_INVALID: true;
|
|
91
|
+
readonly MANIFEST_VALUE_REJECTED: true;
|
|
92
|
+
readonly MANIFEST_EMPTY: false;
|
|
93
|
+
readonly MANIFEST_NOT_REGULAR_FILE: false;
|
|
94
|
+
readonly MANIFEST_CONTENT_NOT_ANALYZED: false;
|
|
95
|
+
readonly NESTED_MONOLITH_STATE_EXCLUDED: false;
|
|
96
|
+
readonly NESTED_MONOLITH_UNCONFIRMED: false;
|
|
97
|
+
};
|
|
98
|
+
export type ExtractionDiagnosticCode = keyof typeof EXTRACTION_DIAGNOSTIC_AFFECTS_COMPLETENESS;
|
|
99
|
+
/** Whether a second scan of the same unchanged tree must return the same diagnostic. */
|
|
100
|
+
export declare const EXTRACTION_DIAGNOSTIC_IS_STABLE: Record<ExtractionDiagnosticCode, boolean>;
|
|
101
|
+
export interface DiscoveryDiagnostic {
|
|
102
|
+
/** An extraction code, or `TRAVERSAL_<code>` for a diagnostic carried over from the traversal. */
|
|
103
|
+
code: string;
|
|
104
|
+
/** Project-relative path, when the diagnostic concerns one. */
|
|
105
|
+
path?: string;
|
|
106
|
+
/** Total occurrences, present on a summary line. */
|
|
107
|
+
count?: number;
|
|
108
|
+
/** Fixed text; never a raw error message, a file content excerpt or an absolute path. */
|
|
109
|
+
message: string;
|
|
110
|
+
}
|
|
111
|
+
export interface DiscoveryLimits {
|
|
112
|
+
/** Directory facts (paths of at most `maxDirectoryDepth` segments), shallowest first. */
|
|
113
|
+
maxDirectoryFacts: number;
|
|
114
|
+
maxDirectoryDepth: number;
|
|
115
|
+
/** Distinct (language, extension) facts. */
|
|
116
|
+
maxLanguageFacts: number;
|
|
117
|
+
/** Manifest presence facts, shallowest first. */
|
|
118
|
+
maxManifestFacts: number;
|
|
119
|
+
/** Manifests whose content is read (only `package.json` is parsed in this version). */
|
|
120
|
+
maxManifestReads: number;
|
|
121
|
+
/** Size cap of one manifest, bytes. */
|
|
122
|
+
maxManifestBytes: number;
|
|
123
|
+
/** Dependency facts per manifest. */
|
|
124
|
+
maxDependenciesPerManifest: number;
|
|
125
|
+
/** Script facts per manifest. */
|
|
126
|
+
maxScriptsPerManifest: number;
|
|
127
|
+
maxEntrypointFacts: number;
|
|
128
|
+
/** Cap on the whole `facts` array; a final guard, normally never reached. */
|
|
129
|
+
maxFacts: number;
|
|
130
|
+
maxDiagnostics: number;
|
|
131
|
+
/** Longest dependency or script name that is kept. */
|
|
132
|
+
maxNameLength: number;
|
|
133
|
+
/** Sources listed for a language aggregate: a sample of at most this many files. */
|
|
134
|
+
maxSourcesPerFact: number;
|
|
135
|
+
}
|
|
136
|
+
export interface DiscoveryStats {
|
|
137
|
+
/** Traversal entries received. */
|
|
138
|
+
inputEntries: number;
|
|
139
|
+
/**
|
|
140
|
+
* Entries that did not reach extraction: a rejected path or kind, a path repeated in the input
|
|
141
|
+
* (collapsed to one entry) or an entry inside confirmed nested MONOLITH state.
|
|
142
|
+
*/
|
|
143
|
+
excludedEntries: number;
|
|
144
|
+
/** Files whose extension maps to no known language. Reported, not guessed. */
|
|
145
|
+
filesWithoutKnownLanguage: number;
|
|
146
|
+
manifestsFound: number;
|
|
147
|
+
/** `package.json` files a read was attempted on (a failed read counts; see the diagnostics). */
|
|
148
|
+
manifestsRead: number;
|
|
149
|
+
facts: number;
|
|
150
|
+
}
|
|
151
|
+
export interface DiscoveryResult {
|
|
152
|
+
schemaVersion: typeof DISCOVERY_SCHEMA_VERSION;
|
|
153
|
+
limits: DiscoveryLimits;
|
|
154
|
+
/** `PARTIAL` when the traversal was `PARTIAL` or any completeness-affecting diagnostic exists. */
|
|
155
|
+
completeness: 'COMPLETE' | 'PARTIAL';
|
|
156
|
+
/** A second scan of the unchanged tree would return this result (traversal and extraction). */
|
|
157
|
+
reproducible: boolean;
|
|
158
|
+
/** What the traversal reported, kept visible next to the combined verdict. */
|
|
159
|
+
traversal: {
|
|
160
|
+
completeness: 'COMPLETE' | 'PARTIAL';
|
|
161
|
+
reproducible: boolean;
|
|
162
|
+
};
|
|
163
|
+
stats: DiscoveryStats;
|
|
164
|
+
/** Sorted by (kind, subject, object, value) in UTF-16 code-unit order. */
|
|
165
|
+
facts: DiscoveryFact[];
|
|
166
|
+
/**
|
|
167
|
+
* Sorted by `compareDiagnostics`: completeness-affecting extraction codes, then traversal codes,
|
|
168
|
+
* then the other extraction codes; each by code, path, message, count. The one exception is a
|
|
169
|
+
* `LIMIT_DIAGNOSTICS` summary, which is always first when the list was cut.
|
|
170
|
+
*/
|
|
171
|
+
diagnostics: DiscoveryDiagnostic[];
|
|
172
|
+
}
|
|
173
|
+
export type DiscoveryErrorCode = 'INVALID_LIMITS' | 'INVALID_INPUT' | 'ID_COLLISION' | 'RESULT_INVALID';
|
|
174
|
+
/** Extraction cannot proceed safely or produced a result the validator rejects: no result exists (FAILED). */
|
|
175
|
+
export declare class DiscoveryError extends Error {
|
|
176
|
+
readonly code: DiscoveryErrorCode;
|
|
177
|
+
constructor(code: DiscoveryErrorCode, message: string);
|
|
178
|
+
}
|
|
179
|
+
/** UTF-16 code-unit order; never `localeCompare` (ADR-021 §4). */
|
|
180
|
+
export declare function compareUtf16(a: string, b: string): number;
|
|
181
|
+
/** 16 hex of sha256 over the canonical tuple. Provenance, level, rule and positions are excluded. */
|
|
182
|
+
export declare function computeFactId(kind: string, subject: string, object?: string, value?: string): string;
|
|
183
|
+
/** A project-relative POSIX path with no empty, `.` or `..` segment, no NUL/control/backslash and no drive prefix. */
|
|
184
|
+
export declare function isSafeRelativePath(p: unknown): p is string;
|
|
185
|
+
export declare const DEPENDENCY_SECTIONS: readonly ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"];
|
|
186
|
+
/** RFC 6901 token escaping. */
|
|
187
|
+
export declare const pointerToken: (s: string) => string;
|
|
188
|
+
export declare function isKeepableName(name: string, max: number): boolean;
|
|
189
|
+
/**
|
|
190
|
+
* Diagnostic order: completeness-affecting extraction codes (0), traversal codes (1), the other
|
|
191
|
+
* extraction codes (2); then code, path, message, count. `count` closes the tie so that no two
|
|
192
|
+
* different diagnostics compare equal.
|
|
193
|
+
*/
|
|
194
|
+
export declare function compareDiagnostics(a: DiscoveryDiagnostic, b: DiscoveryDiagnostic): number;
|
|
195
|
+
export declare function compareFacts(a: DiscoveryFact, b: DiscoveryFact): number;
|
|
196
|
+
export declare function compareSources(a: DiscoverySource, b: DiscoverySource): number;
|
|
197
|
+
/**
|
|
198
|
+
* Check of a `DiscoveryResult` against the schema-1 contract. Returns the violations (empty = valid);
|
|
199
|
+
* `extractProjectFacts` throws `DiscoveryError('RESULT_INVALID')` rather than return a result that
|
|
200
|
+
* fails it (FAILED, ADR-021 §5).
|
|
201
|
+
*
|
|
202
|
+
* Input is `unknown` on purpose: a malformed value yields violations, never a `TypeError`. A violation
|
|
203
|
+
* names a location (`facts[3]`) and a rule, and never repeats a value from the input, so an untrusted
|
|
204
|
+
* result cannot reach a log through it. At most 100 violations are returned.
|
|
205
|
+
*
|
|
206
|
+
* Scope: plain JSON-like data (a producer's output or `JSON.parse` output). An object with accessors
|
|
207
|
+
* that throw, or a `Proxy`, is not defended against (ADR-021 does not require it). The validator is
|
|
208
|
+
* not a general schema library: it checks this contract and nothing else.
|
|
209
|
+
*/
|
|
210
|
+
export declare function validateDiscoveryResult(result: unknown): string[];
|
|
211
|
+
//# sourceMappingURL=contracts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../src/discovery/contracts.ts"],"names":[],"mappings":"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"}
|