Commit Graph

54 Commits

Author SHA1 Message Date
ef8451bb19 Merge graph/subgraph-and-validation: subgraph and validation methods, 43 tests 2026-04-27 12:47:07 +00:00
cedbf3098b Merge analysis/bottlenecks: betweenness centrality bottlenecks, 20 tests
# Conflicts:
#	test/analysis.test.ts
2026-04-27 12:46:12 +00:00
c3649256cc feat(graph/subgraph-and-validation): implement subgraph and validation methods
- Add subgraph() method using graphology-operators.subgraph (ADR-007: internal-only edges)
- Add validateSchema() using TypeBox Value.Check/Value.Errors
- Add validateGraph() detecting cycles and dangling references
- Add validate() combining both validations
- Define ValidationError, GraphValidationError, AnyValidationError types in error module
- Add standalone validation functions in src/graph/validation.ts
- Export validation module from src/graph/index.ts
- Add 43 unit tests for subgraph filtering and validation
2026-04-27 12:41:51 +00:00
e074275bcf docs(analysis/bottlenecks): mark task as completed 2026-04-27 12:36:14 +00:00
62e23b5989 feat(analysis/bottlenecks): implement bottlenecks function using graphology-metrics betweenness centrality
- Implements bottlenecks(graph: TaskGraph): BottleneckResult[] with normalized scores (0.0-1.0)
- Uses graphology-metrics centrality.betweenness with normalized: true
- Returns array sorted by score descending, includes all nodes (even score 0)
- Handles empty graph edge case (returns empty array)
- 20 unit tests covering: linear chain, star graph, independent nodes,
  disconnected graph, diamond, empty graph, single node
2026-04-27 12:35:48 +00:00
8d1b478a8c Merge analysis/critical-path: criticalPath and weightedCriticalPath, 20 tests 2026-04-27 12:34:51 +00:00
4fe8532176 feat(analysis/critical-path): implement criticalPath and weightedCriticalPath
Implement longest-path-in-DAG algorithms using topological order + dynamic programming.

- criticalPath(graph): finds unweighted longest path (each node = weight 1)
- weightedCriticalPath(graph, weightFn): finds path with highest cumulative weight
- Both throw CircularDependencyError on cyclic graphs
- Empty graph returns [], single-node graph returns [nodeId]
- 20 unit tests covering linear chains, diamonds, weighted variants, cyclic detection
2026-04-27 12:34:35 +00:00
37179bc1de feat(analysis/parallel-groups): implement parallelGroups function with tests 2026-04-27 12:31:43 +00:00
b0d943f4e6 Merge graph/queries: 7 query methods with 45 tests
# Conflicts:
#	src/graph/construction.ts
2026-04-27 12:13:15 +00:00
95c8146af7 Merge graph/construction: fromTasks, fromRecords, fromJSON, addTask, addDependency
# Conflicts:
#	src/graph/construction.ts
2026-04-27 12:07:41 +00:00
98cc05d266 feat(graph/queries): implement query methods — hasCycles, findCycles, topologicalOrder, dependencies, dependents, taskCount, getTask
- hasCycles(): uses graphology-dag.hasCycle() as fast boolean check
- findCycles(): SCC pre-check + custom 3-color DFS for cycle path extraction
- topologicalOrder(): graphology-dag.topologicalSort + CircularDependencyError on cycle
- dependencies/dependents: inNeighbors/outNeighbors with TaskNotFoundError
- taskCount(): graph.order, getTask(): node attributes or undefined
- 45 unit tests covering all acceptance criteria
2026-04-27 12:00:17 +00:00
8d384a7b3e feat(graph/construction): implement TaskGraph construction methods
- fromTasks: bulk import via serialized blob, orphan nodes for dangling refs,
  DuplicateNodeError for duplicates, edge dedup, null→undefined stripping
- fromRecords: strict validation (TaskNotFoundError for dangling refs,
  DuplicateEdgeError for duplicate edges), per-edge qualityRetention
- fromJSON: TypeBox Value.Check validation, InvalidInputError on schema failure,
  orphan nodes preserved
- addTask: throws DuplicateNodeError if ID exists
- addDependency: throws TaskNotFoundError/DuplicateEdgeError, deterministic
  edge keys per ADR-006, default qualityRetention 0.9
- taskInputToNodeAttrs: strips null→undefined for categorical fields,
  drops non-graph fields (tags, assignee, due, created, modified)
- 47 new unit tests (304 total, all passing)
2026-04-27 11:59:56 +00:00
96e65079c2 Merge cost-benefit/ev-calculation: calculateTaskEv pure function with 30 tests 2026-04-27 11:54:10 +00:00
aabc9e2fb5 Merge graph/mutation: removeTask, removeDependency, updateTask, updateEdgeAttributes 2026-04-27 11:53:42 +00:00
95ef4b023b Merge frontmatter/file-io-and-serialize: parseTaskFile, parseTaskDirectory, serializeFrontmatter 2026-04-27 11:53:13 +00:00
52a951cb6c Merge graph/export: export() and toJSON() methods on TaskGraph 2026-04-27 11:52:33 +00:00
6016e81162 feat(cost-benefit): implement calculateTaskEv pure function
Implement the core EV calculation: EV = p*C_success + (1-p)*C_fail
where C_success = scopeCost*impactWeight, C_fail = scopeCost*impactWeight + fallbackCost + timeLost*expectedRetries.

- expectedRetries = (1-p)/p when p>0, else 0 (geometric series)
- Caps expectedRetries at config.retries when retries > 0
- Multiplies final EV by config.valueRate when non-zero
- 30 unit tests covering formula, edge cases, and Python research model values
2026-04-27 11:51:59 +00:00
5adc712193 feat(graph/mutation): implement removeTask, removeDependency, updateTask, updateEdgeAttributes 2026-04-27 11:51:57 +00:00
6da0cb12ce feat(frontmatter/file-io-and-serialize): implement parseTaskFile, parseTaskDirectory, and serializeFrontmatter 2026-04-27 11:51:34 +00:00
f8cd38f02d review(schemas-and-errors): approved, 0 critical issues, all tests passing 2026-04-27 11:51:27 +00:00
34e227464c feat(graph/export): implement export() and toJSON() methods on TaskGraph 2026-04-27 11:49:11 +00:00
9ad0ec902c Merge graph/taskgraph-class: TaskGraph class skeleton with DirectedGraph, edge keys, fromJSON 2026-04-27 11:30:57 +00:00
e155e1e08a feat(graph/taskgraph-class): implement TaskGraph class skeleton with graphology DirectedGraph 2026-04-27 11:29:59 +00:00
412849501f Merge frontmatter/parsing: parseFrontmatter with YAML 1.2, TypeBox validation, InvalidInputError 2026-04-27 11:28:09 +00:00
7401e4d056 feat(frontmatter/parsing): implement parseFrontmatter with YAML parsing and TypeBox validation 2026-04-27 11:26:55 +00:00
0613a190ce feat(schema/numeric-methods-and-defaults): implement categorical numeric functions and resolveDefaults 2026-04-27 11:25:43 +00:00
30f20a9f26 Merge schema/graph-schemas: node/edge attribute schemas, SerializedGraph generic factory
# Conflicts:
#	test/schema.test.ts
2026-04-27 11:11:07 +00:00
ec30c96671 Merge schema/input-schemas: TaskInput and DependencyEdge schemas with Nullable helper 2026-04-27 11:04:07 +00:00
d2eaa0dd77 feat(schema/graph-schemas): define TaskGraphNodeAttributes, TaskGraphEdgeAttributes, and SerializedGraph generic
Implements graph attribute schemas and the SerializedGraph generic factory
parameterized with <N, E, G> following the graphology JSON format.

- TaskGraphNodeAttributes: name + optional categorical enums (scope, risk,
  impact, level, priority, status) — analysis-relevant metadata only
- TaskGraphNodeAttributesUpdate: Type.Partial(TaskGraphNodeAttributes)
- TaskGraphEdgeAttributes: optional qualityRetention number
- SerializedGraph<N, E, G>: generic factory for graphology JSON format
- TaskGraphSerialized: concrete instantiation with empty graph attributes
- No schema version field per spec

35 new tests covering validation, rejection, and compile-time type safety.
2026-04-27 11:03:07 +00:00
b415d8c86b feat(schema/input-schemas): define TaskInput, DependencyEdge schemas and Nullable re-export
- Add TaskInput schema with all fields per architecture (id, name, dependsOn,
  categorical fields as Optional(Nullable(...)), metadata fields)
- Add DependencyEdge schema with from, to, qualityRetention fields
- Re-export Nullable helper from task.ts for convenience
- Add type aliases: TaskInput, DependencyEdge via Static<typeof>
- Add 49 tests covering validation, nullable fields, edge cases, type correctness
2026-04-27 11:02:40 +00:00
e367215e43 feat(schema/result-types): define analysis result TypeBox schemas 2026-04-27 10:59:57 +00:00
8725a26b43 Merge setup/test-infrastructure: vitest config, shared fixtures, 30 tests passing 2026-04-27 10:49:01 +00:00
167dde68f4 feat(setup/test-infrastructure): configure Vitest with shared test fixtures and helpers
- Add test:coverage script and @vitest/coverage-v8 dev dependency
- Update vitest.config.ts with @/ path alias and v8 coverage config
- Create test/fixtures/graphs.ts with 5 fixture graphs (linearChain,
  diamond, mixedCategory, cyclic, largeGraph) and createTaskGraph helper
- Expand graph.test.ts with 26 fixture validation tests
- 30 tests passing, CI-compatible output (vitest run)
2026-04-27 10:48:35 +00:00
196b044ca4 Merge schema/enums: 6 TypeBox enum schemas with type aliases, 21 tests 2026-04-27 10:10:44 +00:00
6003926807 feat(schema/enums): define TypeBox categorical enum schemas and type aliases 2026-04-27 10:08:28 +00:00
e4b5ac3d54 Merge frontmatter/splitter: splitFrontmatter function with 18 tests 2026-04-27 10:05:19 +00:00
15104ff10c feat(frontmatter/splitter): implement splitFrontmatter function with tests 2026-04-27 10:04:31 +00:00
ce68271f4f feat(error/error-hierarchy): implement typed error class hierarchy
- Add typed fields to all error subclasses (taskId, cycles, field, message, prerequisite, dependent)
- Set Object.setPrototypeOf(this, new.target.prototype) in all constructors
- Add InvalidInputError.fromTypeBoxError() static factory for TypeBox Value.Errors() output
- CircularDependencyError accepts string[][] for cycle paths
- 31 unit tests covering instanceof chain, field access, .name property, and error messages
2026-04-27 10:00:40 +00:00
bd8a7b06d0 feat(setup/project-init): initialize TypeScript ESM project skeleton
- package.json with @alkdev/taskgraph, ESM primary, CJS compat exports
- tsconfig.json targeting Node 18+, strict mode, declaration output
- All production deps: graphology suite, @alkdev/typebox, yaml
- Dev deps: typescript, vitest, @types/node
- src/ skeleton: schema, graph, analysis, frontmatter, error modules
- test/ directory with 5 placeholder test files
- .gitignore and vitest.config.ts
2026-04-27 09:54:01 +00:00
131e3e929b Decompose architecture into 28 atomic implementation tasks
Break the @alkdev/taskgraph architecture specs into dependency-ordered
implementation tasks across 8 component directories: setup, schema,
error, graph, analysis, cost-benefit, frontmatter, api, and review.
Each task has clear acceptance criteria referencing specific architecture
docs. Three review tasks serve as quality gates at critical junction
points (schemas-and-errors, graph-complete, complete-library). The
dependency graph is validated acyclic with 9 topological levels enabling
significant parallelism across independent work streams.
2026-04-27 08:30:05 +00:00
e592caed57 Add architecture review findings and address documentation issues
Review of all ADR documents (001-007) and peripheral architecture docs
identified 3 critical, 10 warning, and 7 suggestion issues.

Addressed in this commit:
- W-1: Add draft qualifier to ADR-002 reference to incremental exploration
- W-2: Add Alternatives Considered section to ADR-001
- W-3: Add Document Lifecycle section to README.md (draft/stable/deprecated)
- W-4: Clarify includeCompleted semantics (only 'completed' status triggers exclusion)
- W-5: Document file I/O runtime constraints in frontmatter.md
- W-6: Add ADR reference to architecture.md redirect
- W-7: Verify CVE-2025-64718 (confirmed real, improved description)
- W-9: Convert workspace-absolute paths to relative/monorepo references
- S-7: Add future ADR-008 note to incremental-update-exploration.md

Critical issues (C-1, C-2, C-3) and remaining warnings (W-8, W-10, S-4, S-5)
were addressed by a parallel agent in a prior commit.

All 16 review tasks created and resolved.
2026-04-26 09:41:05 +00:00
4244c054b7 Fix critical architecture review issues
Critical fixes:
- Rename qualityDegradation → qualityRetention across all docs
  (semantically inverted: 0.9 meant 90% quality RETAINED, not 90%
  degradation). Updated schemas, graph-model, cost-benefit, ADRs.
- Add TaskInput → TaskGraphNodeAttributes transformation section
  to graph-model.md, documenting how Nullable(Optional) input fields
  map to Optional graph attributes
- Fix DuplicateEdgeError fields: source/target → prerequisite/dependent
  to match the established edge direction convention
- Fix resolveDefaults signature: Partial<TaskGraphNodeAttributes>
  → Partial<...> & Pick<TaskGraphNodeAttributes, 'name'> to
  require the name field
- Move Nullable helper definition before its first use in schemas.md
- Fix 'construction never throws' contradiction: rephrase to
  'construction enforces uniqueness, not data quality'
- Define all 6 enum value sets in schemas.md (previously only
  TaskScope and TaskRisk were explicit)
- Add EvConfig parameter table with defaults and semantics
- Document WorkflowCostOptions.limit parameter
- Add construction error handling table to graph-model.md
- Add graph.raw mutation safety warning to api-surface.md
- Update build-distribution.md error class list to include
  DuplicateNodeError and DuplicateEdgeError
2026-04-26 09:13:14 +00:00
13d55b981e Add incremental update exploration doc and update ADR-002
Explores the diff-based approach (TypeBox Value.Diff → graphology mutation
mapping) as an alternative to rebuild-on-change. Key findings:

- The diff must happen at the graph level, not the source level, because
  TaskInput.dependsOn doesn't directly map to edge mutations
- graphology's import(merge=true) handles merges but not deletions
- The real win is reactivity (fine-grained event notifications), not performance
- For <200 node graphs, rebuild is always sub-millisecond
- A hybrid approach (diff for attribute-only changes, rebuild for structural
  changes) is possible but adds significant complexity

Decision: defer to v2. ADR-002 (rebuild) stands. The exploration is preserved
for future reference.
2026-04-26 08:41:19 +00:00
ac9dee9c10 Fix TypeBox schema consistency and add TypeBox patterns research
- schemas.md: Replace interface ResolvedTaskAttributes with TypeBox schema
  + Static<typeof> derivation (was the only raw interface in the doc set)
- schemas.md: Add explicit TypeBox naming convention table and pattern guide
- schemas.md: Use Nullable() helper for TaskInput optional categorical fields
  that can be explicitly set to null in YAML
- schemas.md: Reference typebox-patterns.md research for full analysis
- api-surface.md: Add note about Static<typeof> pattern consistency
- errors-validation.md: Use Value.Errors() for structured validation instead
  of bare Value.Check()
- New: docs/research/typebox-patterns.md — comprehensive TypeBox pattern
  evaluation covering Static, Values, Convert, Pointer, TemplateLiteral,
  generics, defaults, and concrete schema recommendations
2026-04-26 07:57:23 +00:00
235328813e Add consumer context guidance to architect role spec
Two additions based on learnings from taskgraph architecture decomposition:
- Gather Requirements now explicitly mentions reading downstream consumer
  architecture to understand constraints, while noting that consumer dispatch
  details belong in the consumer's own docs, not the library's
- Anti-patterns adds 'Consumer dispatch in library docs' — describe what
  consumers need, not how they dispatch it
2026-04-26 06:39:38 +00:00
bde1cc4e70 Decompose monolithic architecture.md into modular docs/architecture/ documents
The 751-line architecture.md violated the SDD process modular documentation
target (~500 lines). It also had duplicate TaskGraph class definitions (one
monolith, one decomposed) that directly contradicted each other, and embedded
consumer-specific tool dispatch mappings that belong in downstream projects.

Changes:
- Split into 8 focused documents + 7 ADR records + redirect page
- Removed the monolithic TaskGraph class (kept only decomposed version)
- Moved CLI→plugin dispatch mapping out (belongs in plugin architecture)
- Extracted implementation code (frontmatter splitter, findCycles, DAG
  propagation) into WHAT/WHY descriptions per architect role spec
- Added proper ADR format for all resolved design decisions
- Fixed review issues: C_fail mapping, DuplicateNodeError/DuplicateEdgeError
  types, ValidationError/GraphValidationError definitions, mutation error
  handling contract, enum naming convention, validation timing clarification
2026-04-26 06:38:52 +00:00
bac335274d Update agent roles and AGENTS.md for open-coordinator and open-memory plugins
Replace outdated worktree_make/worktree_mode/worktree_overview/worktree_cleanup
API references with the new worktree({action, args}) dispatch pattern from
open-coordinator. Add worktree notify tool for implementation/code-review/POC
agents to communicate back to coordinator. Fix stale alkhub_ts paths. Add
open-memory plugin awareness (memory, memory_compact) to AGENTS.md and agent
specs. Update sdd_process.md coordinator section accordingly.
2026-04-26 05:46:20 +00:00
6d391e3ad8 Added agent role defs and ssd_process.md 2026-04-25 12:32:43 +00:00
365e7a61dd Fix supply chain attack date: Sept 2025 → April 2026 2026-04-25 07:14:07 +00:00
3346002fba Resolve all open questions, add class decomposition section
Replace interfaces with typebox equivalents for return types.
Resolve 6 open design questions:
1. Rebuild over incremental (graph sizes too small to matter)
2. Strict internal-only subgraph (matches graphology-operators)
3. Throw CircularDependencyError on cycles (both consumers treat as bugs)
4. Always propagate through completed nodes, exclude from output only
5. Defer depth-escalation to v2 (multiplicative compounding already captures it)
6. Adopt source->target edge keys from the start

Add section decomposing TaskGraph into thin data class + standalone
analysis functions, with operations pattern at the consumer layer.
2026-04-25 05:44:18 +00:00