2.3 KiB
2.3 KiB
id, name, status, depends_on, scope, risk, impact, level
| id | name | status | depends_on | scope | risk | impact | level | |
|---|---|---|---|---|---|---|---|---|
| graph/mutation | Implement TaskGraph mutation methods (remove, update, updateEdgeAttributes) | completed |
|
narrow | low | component | implementation |
Description
Implement mutation methods in src/graph/mutation.ts and integrate on TaskGraph. These methods modify the graph in-place.
Acceptance Criteria
removeTask(id: string): void— No-op if node doesn't exist. Removes node and cascades edge removal (graphology handles this automatically).removeDependency(prerequisite: string, dependent: string): void— No-op if edge doesn't exist. Uses deterministic edge key${prerequisite}->${dependent}to identify the edge.updateTask(id: string, attributes: Partial<TaskGraphNodeAttributes>): void— ThrowsTaskNotFoundErrorif ID doesn't exist. UsesmergeNodeAttributesfor shallow merge of provided attributes.updateEdgeAttributes(prerequisite: string, dependent: string, attrs: Partial<TaskGraphEdgeAttributes>): void— ThrowsTaskNotFoundError(actuallyTaskNotFoundErrorfor the edge itself, but per the spec, edge attributes need both endpoints to exist) if the edge doesn't exist. UsesmergeEdgeAttributesfor shallow merge.- All mutations maintain the deterministic edge key format
- Unit tests: remove nonexistent node/edge is no-op, update nonexistent throws, partial updates merge correctly
References
- docs/architecture/api-surface.md — mutation methods
- docs/architecture/errors-validation.md — mutation operation behavior table
- docs/architecture/graph-model.md — edge attributes, mutation semantics
Notes
Implementation follows the architecture spec precisely:
- Standalone functions in
mutation.tstakeTaskGraphInneras first arg - TaskGraph class methods delegate to standalone functions
removeTask/removeDependencyare no-ops on missing targets (idempotent removal)updateTask/updateEdgeAttributesthrowTaskNotFoundErroron missing targets- Deterministic edge key format
${prerequisite}->${dependent}used throughout
Summary
Implemented all four TaskGraph mutation methods with standalone functions and class integration.
- Created:
test/mutation.test.ts(27 tests) - Modified:
src/graph/mutation.ts,src/graph/construction.ts - Tests: 284 total, all passing (27 new mutation tests)