Skip to content

docs: Token Behavior Matrix — Scala TDD-ready specification#114

Closed
ottobot-ai wants to merge 1 commit into
scasplte2:developfrom
ottobot-ai:feat/token-behavior-scala
Closed

docs: Token Behavior Matrix — Scala TDD-ready specification#114
ottobot-ai wants to merge 1 commit into
scasplte2:developfrom
ottobot-ai:feat/token-behavior-scala

Conversation

@ottobot-ai

Copy link
Copy Markdown
Collaborator

Summary

Comprehensive TDD-ready specification for implementing TokenBehavior sealed trait in the Scala metagraph codebase, achieving cross-language equivalence with TypeScript SDK (PR #45).

Trello Card

Token Behavior Matrix — Scala Specification

Key Decisions (from @research feasibility)

Decision Choice Rationale
Module modules/models/ Same as StateMachineDefinition; pure data, no IO
Proto New token.proto under ottochain/v1/ Establishes domain-proto convention
Guards Use sequenceNumber Fixes TypeScript $ordinal bug (defaults to 0)

Deliverables

  1. TokenBehavior — Sealed trait with 16 case objects (TDEG model)
  2. TokenBehaviorBuilder.toStateMachineDefinition(behavior) — Factory
  3. TokenBehavior.isOperationAllowed(behavior, op) — Legality API
  4. ProtoTokenBehaviorType + TokenOperationType enums

Test Coverage

58 TDD test cases in 7 groups:

  • Group 1: Predicates (6 tests)
  • Group 2: Structure — All 16 types (16 tests)
  • Group 3: Transition presence by flag (12 tests)
  • Group 4: Wire format correctness (6 tests)
  • Group 5: Operation legality (8 tests)
  • Group 6: Named presets (5 tests)
  • Group 7: Cross-language equivalence (5 tests)

References

Next Steps

After spec review:

  1. Move card to 🧪 Test Definition
  2. @code writes failing tests per spec
  3. @work implements to make tests pass

Spec by @Think | 2026-02-25

Comprehensive specification for implementing TokenBehavior sealed trait
in Scala metagraph codebase, matching TypeScript SDK (PR scasplte2#45).

Key decisions:
- Module: modules/models/ (same as StateMachineDefinition)
- Proto: New token.proto under ottochain/v1/
- Guards use sequenceNumber (fixes TypeScript $ordinal bug)

Deliverables:
- TokenBehavior sealed trait with 16 case objects
- TokenBehaviorBuilder.toStateMachineDefinition(behavior)
- TokenBehavior.isOperationAllowed(behavior, op)
- Proto: TokenBehaviorType enum, TokenOperationType enum

58 TDD test cases in 7 groups covering:
- Predicates, structure, transitions, wire format
- Operation legality, named presets
- Cross-language equivalence

Trello: 6996301447b41cda59369256
Refs: TypeScript SDK PR scasplte2#45 (84 tests)
@ottobot-ai

Copy link
Copy Markdown
Collaborator Author

Moving to feature branch feat/token-behavior-matrix on ottobot-ai/ottochain for agent iteration. Will submit rollup PR to upstream when ready.

@ottobot-ai ottobot-ai closed this Feb 26, 2026
ottobot-ai added a commit to ottobot-ai/ottochain that referenced this pull request Feb 26, 2026
Implements the 16-type token behavior system using a 4-boolean TDEG matrix.

## Deliverables
- `TokenBehavior` sealed trait with 16 case objects (modules/models/)
- `TokenBehaviorBuilder.toStateMachineDefinition(behavior)` factory
- `TokenBehavior.isOperationAllowed(behavior, op)` legality API
- `TokenOperation` enum (8 operations)
- `token.proto` with `TokenBehaviorType` + `TokenOperationType` enums
- 58 TDD tests — all passing

## Key Design
- 4-bit encoding: T=Transferable(8), D=Divisible(4), E=Expirable(2), G=Governable(1)
- States: ACTIVE (initial), BURNED (terminal), EXPIRED (terminal, E=1 only)
- Expiry guard uses `sequenceNumber` (fixes TypeScript $ordinal latent bug, AC4)
- Cross-language equivalence with TypeScript SDK PR scasplte2#45

## References
- Trello: https://trello.com/c/6996301447b41cda59369256
- Spec: scasplte2#114
- TypeScript reference: ottobot-ai/ottochain-sdk PR scasplte2#45

Co-authored-by: OttoWork <ottobot@kd5ujc.xyz>
ottobot-ai added a commit to ottobot-ai/ottochain that referenced this pull request Mar 23, 2026
Implements the 16-type token behavior system using a 4-boolean TDEG matrix.

## Deliverables
- `TokenBehavior` sealed trait with 16 case objects (modules/models/)
- `TokenBehaviorBuilder.toStateMachineDefinition(behavior)` factory
- `TokenBehavior.isOperationAllowed(behavior, op)` legality API
- `TokenOperation` enum (8 operations)
- `token.proto` with `TokenBehaviorType` + `TokenOperationType` enums
- 58 TDD tests — all passing

## Key Design
- 4-bit encoding: T=Transferable(8), D=Divisible(4), E=Expirable(2), G=Governable(1)
- States: ACTIVE (initial), BURNED (terminal), EXPIRED (terminal, E=1 only)
- Expiry guard uses `sequenceNumber` (fixes TypeScript $ordinal latent bug, AC4)
- Cross-language equivalence with TypeScript SDK PR scasplte2#45

## References
- Trello: https://trello.com/c/6996301447b41cda59369256
- Spec: scasplte2#114
- TypeScript reference: ottobot-ai/ottochain-sdk PR scasplte2#45

Co-authored-by: OttoWork <ottobot@kd5ujc.xyz>
ottobot-ai added a commit to ottobot-ai/ottochain that referenced this pull request Mar 23, 2026
… matrix)

Implements the 16-type token behavior system using a 4-boolean TDEG matrix.

## Deliverables
- TokenBehavior sealed trait with 16 case objects (modules/models/)
- TokenBehaviorBuilder.toStateMachineDefinition(behavior) factory
- TokenBehavior.isOperationAllowed(behavior, op) legality API
- TokenOperation enum (8 operations)
- token.proto with TokenBehaviorType + TokenOperationType enums
- 58 TDD tests — all passing

## Key Design
- 4-bit encoding: T=Transferable(8), D=Divisible(4), E=Expirable(2), G=Governable(1)
- States: ACTIVE (initial), BURNED (terminal), EXPIRED (terminal, E=1 only)
- Expiry guard uses sequenceNumber (fixes TypeScript $ordinal latent bug, AC4)

- Cross-language equivalence with TypeScript SDK PR scasplte2#45

## References
- Trello: https://trello.com/c/6996301447b41cda59369256
- Spec: scasplte2#114
- TypeScript reference: ottobot-ai/ottochain-sdk PR scasplte2#45

Co-authored-by: OttoWork <ottobot@kd5ujc.xyz>
ottobot-ai added a commit to ottobot-ai/ottochain that referenced this pull request Mar 23, 2026
Implements the 16-type token behavior system using a 4-boolean TDEG matrix.

## Deliverables
- TokenBehavior sealed trait with 16 case objects (modules/models/)
- TokenBehaviorBuilder.toStateMachineDefinition(behavior) factory
- TokenBehavior.isOperationAllowed(behavior, op) legality API
- TokenOperation enum (8 operations)
- token.proto with TokenBehaviorType + TokenOperationType enums
- 58 TDD tests — all passing

## Key Design
- 4-bit encoding: T=Transferable(8), D=Divisible(4), E=Expirable(2), G=Governable(1)
- States: ACTIVE (initial), BURNED (terminal), EXPIRED (terminal, E=1 only)
- Expiry guard uses sequenceNumber (fixes TypeScript $ordinal latent bug, AC4)

- Cross-language equivalence with TypeScript SDK PR scasplte2#45

## References
- Trello: https://trello.com/c/6996301447b41cda59369256
- Spec: scasplte2#114
- TypeScript reference: ottobot-ai/ottochain-sdk PR scasplte2#45

Co-authored-by: OttoWork <ottobot@kd5ujc.xyz>
ottobot-ai added a commit that referenced this pull request Mar 23, 2026
Implements the 16-type token behavior system using a 4-boolean TDEG matrix.

## Deliverables
- TokenBehavior sealed trait with 16 case objects (modules/models/)
- TokenBehaviorBuilder.toStateMachineDefinition(behavior) factory
- TokenBehavior.isOperationAllowed(behavior, op) legality API
- TokenOperation enum (8 operations)
- token.proto with TokenBehaviorType + TokenOperationType enums
- 58 TDD tests — all passing

## Key Design
- 4-bit encoding: T=Transferable(8), D=Divisible(4), E=Expirable(2), G=Governable(1)
- States: ACTIVE (initial), BURNED (terminal), EXPIRED (terminal, E=1 only)
- Expiry guard uses sequenceNumber (fixes TypeScript $ordinal latent bug, AC4)

- Cross-language equivalence with TypeScript SDK PR #45

## References
- Trello: https://trello.com/c/6996301447b41cda59369256
- Spec: #114
- TypeScript reference: ottobot-ai/ottochain-sdk PR #45

Co-authored-by: OttoWork <ottobot@kd5ujc.xyz>
ottobot-ai added a commit to ottobot-ai/ottochain that referenced this pull request Mar 23, 2026
Implements the 16-type token behavior system using a 4-boolean TDEG matrix.

## Deliverables
- TokenBehavior sealed trait with 16 case objects (modules/models/)
- TokenBehaviorBuilder.toStateMachineDefinition(behavior) factory
- TokenBehavior.isOperationAllowed(behavior, op) legality API
- TokenOperation enum (8 operations)
- token.proto with TokenBehaviorType + TokenOperationType enums
- 58 TDD tests — all passing

## Key Design
- 4-bit encoding: T=Transferable(8), D=Divisible(4), E=Expirable(2), G=Governable(1)
- States: ACTIVE (initial), BURNED (terminal), EXPIRED (terminal, E=1 only)
- Expiry guard uses sequenceNumber (fixes TypeScript $ordinal latent bug, AC4)

- Cross-language equivalence with TypeScript SDK PR scasplte2#45

## References
- Trello: https://trello.com/c/6996301447b41cda59369256
- Spec: scasplte2#114
- TypeScript reference: ottobot-ai/ottochain-sdk PR scasplte2#45

Co-authored-by: OttoWork <ottobot@kd5ujc.xyz>
ottobot-ai added a commit that referenced this pull request Mar 24, 2026
Implements the 16-type token behavior system using a 4-boolean TDEG matrix.

## Deliverables
- TokenBehavior sealed trait with 16 case objects (modules/models/)
- TokenBehaviorBuilder.toStateMachineDefinition(behavior) factory
- TokenBehavior.isOperationAllowed(behavior, op) legality API
- TokenOperation enum (8 operations)
- token.proto with TokenBehaviorType + TokenOperationType enums
- 58 TDD tests — all passing

## Key Design
- 4-bit encoding: T=Transferable(8), D=Divisible(4), E=Expirable(2), G=Governable(1)
- States: ACTIVE (initial), BURNED (terminal), EXPIRED (terminal, E=1 only)
- Expiry guard uses sequenceNumber (fixes TypeScript $ordinal latent bug, AC4)

- Cross-language equivalence with TypeScript SDK PR #45

## References
- Trello: https://trello.com/c/6996301447b41cda59369256
- Spec: #114
- TypeScript reference: ottobot-ai/ottochain-sdk PR #45

Co-authored-by: OttoWork <ottobot@kd5ujc.xyz>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant