This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
# work
|
||||
|
||||
**Owns:** Goal, Task and Decision semantics.
|
||||
|
||||
See `architecture/architecture-registry.yaml` for allowed dependencies and DB schema.
|
||||
|
||||
This module may not write another owner's canonical state. Domain code does not import adapters/runtime/providers.
|
||||
@@ -0,0 +1,3 @@
|
||||
package application
|
||||
|
||||
// Package application coordinates work-owned use cases through explicit ports.
|
||||
@@ -0,0 +1,3 @@
|
||||
package domain
|
||||
|
||||
// Package domain contains work domain meaning only. It must not import adapters or runtime packages.
|
||||
@@ -0,0 +1,51 @@
|
||||
package domain
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"git.cin.su/m/Assistant/contracts/authority"
|
||||
contract "git.cin.su/m/Assistant/contracts/work"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrTaskNotFound = errors.New("task not found")
|
||||
ErrTaskTargetMismatch = errors.New("task target does not match canonical task")
|
||||
ErrRevisionConflict = errors.New("task revision conflict")
|
||||
)
|
||||
|
||||
type Task struct {
|
||||
ID contract.TaskID
|
||||
GoalID contract.GoalID
|
||||
ScopeID authority.ScopeID
|
||||
Revision contract.TaskRevision
|
||||
}
|
||||
|
||||
// Store models owner-local task state for the walking skeleton. A caller must
|
||||
// present all target integrity fields; no cross-owner lookup is performed.
|
||||
type Store struct {
|
||||
tasks map[contract.TaskID]Task
|
||||
}
|
||||
|
||||
func NewStore(tasks []Task) Store {
|
||||
stored := make(map[contract.TaskID]Task, len(tasks))
|
||||
for _, task := range tasks {
|
||||
stored[task.ID] = task
|
||||
}
|
||||
return Store{tasks: stored}
|
||||
}
|
||||
|
||||
func (s *Store) Commit(target contract.TaskTarget) (Task, error) {
|
||||
task, ok := s.tasks[target.TaskID]
|
||||
if !ok {
|
||||
return Task{}, ErrTaskNotFound
|
||||
}
|
||||
if task.GoalID != target.GoalID || task.ScopeID != target.ScopeID {
|
||||
return Task{}, ErrTaskTargetMismatch
|
||||
}
|
||||
if task.Revision != target.Revision {
|
||||
return Task{}, ErrRevisionConflict
|
||||
}
|
||||
task.Revision++
|
||||
s.tasks[task.ID] = task
|
||||
return task, nil
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package work
|
||||
|
||||
// Module is an intentionally minimal V1 composition handle. Do not turn it into a God service.
|
||||
type Module struct{}
|
||||
@@ -0,0 +1,3 @@
|
||||
package ports
|
||||
|
||||
// Package ports declares work-owned external dependencies. Ports must be narrow and semantic.
|
||||
Reference in New Issue
Block a user