setup notes for milestone 1
This commit is contained in:
@ -1,87 +1,78 @@
|
|||||||
# Complete Implementation Plan for Onyx Phase 1
|
# Complete Implementation Plan for Onyx Phase 1
|
||||||
|
|
||||||
|
## Milestone 1: Action Log and onx init
|
||||||
|
|
||||||
## Milestone 0: Foundation and Core Abstractions
|
### Action Log Implementation
|
||||||
|
|
||||||
### Project Structure Setup
|
13. **Create oplog binary format** (`internal/storage/oplog.go`)
|
||||||
|
```go
|
||||||
|
type OplogEntry struct {
|
||||||
|
ID uint64
|
||||||
|
ParentID uint64
|
||||||
|
Timestamp int64
|
||||||
|
Command string
|
||||||
|
StateBefore map[string]string
|
||||||
|
StateAfter map[string]string
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
6. **Create directory structure**
|
14. **Implement oplog writer** (`internal/storage/oplog_writer.go`)
|
||||||
```
|
- `OpenOplog(path string) (*OplogWriter, error)`
|
||||||
onyx/
|
- `AppendEntry(entry *OplogEntry) error`
|
||||||
├── cmd/
|
- Use binary encoding (gob or protobuf)
|
||||||
│ ├── onx/ # CLI entry point
|
- Implement file locking for concurrent access
|
||||||
│ └── onxd/ # Daemon entry point
|
|
||||||
├── internal/
|
|
||||||
│ ├── core/ # Core abstractions
|
|
||||||
│ ├── git/ # Git interaction layer
|
|
||||||
│ ├── models/ # Data models
|
|
||||||
│ ├── storage/ # .onx directory management
|
|
||||||
│ ├── commands/ # CLI command implementations
|
|
||||||
│ ├── daemon/ # Daemon implementation
|
|
||||||
│ └── utils/ # Utilities
|
|
||||||
├── pkg/ # Public APIs (if needed)
|
|
||||||
├── test/ # Integration tests
|
|
||||||
├── docs/ # Documentation
|
|
||||||
└── scripts/ # Build/deployment scripts
|
|
||||||
```
|
|
||||||
|
|
||||||
7. **Set up dependency management**
|
15. **Implement oplog reader** (`internal/storage/oplog_reader.go`)
|
||||||
```bash
|
- `ReadLastEntry() (*OplogEntry, error)`
|
||||||
go get github.com/go-git/go-git/v5@latest
|
- `ReadEntry(id uint64) (*OplogEntry, error)`
|
||||||
go get github.com/spf13/cobra@latest
|
- `GetUndoStack() ([]*OplogEntry, error)`
|
||||||
go get github.com/fsnotify/fsnotify@latest
|
|
||||||
```
|
|
||||||
|
|
||||||
8. **Create Makefile**
|
16. **Create transactional wrapper** (`internal/core/transaction.go`)
|
||||||
```makefile
|
```go
|
||||||
# Makefile
|
func ExecuteWithTransaction(repo *Repository, cmd string,
|
||||||
.PHONY: build test clean install
|
fn func() error) error {
|
||||||
|
// 1. Capture state_before
|
||||||
build:
|
// 2. Create oplog entry
|
||||||
go build -o bin/onx ./cmd/onx
|
// 3. Execute fn()
|
||||||
go build -o bin/onxd ./cmd/onxd
|
// 4. Capture state_after
|
||||||
|
// 5. Finalize oplog entry
|
||||||
test:
|
// 6. Handle rollback on error
|
||||||
go test -v ./...
|
}
|
||||||
|
```
|
||||||
install:
|
|
||||||
go install ./cmd/onx
|
|
||||||
go install ./cmd/onxd
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -rf bin/
|
|
||||||
```
|
|
||||||
|
|
||||||
### Core Abstractions Implementation
|
### onx init Command
|
||||||
|
|
||||||
9. **Define core interfaces** (`internal/core/interfaces.go`)
|
17. **Implement init command** (`internal/commands/init.go`)
|
||||||
```go
|
- Create .git directory (via go-git)
|
||||||
type Repository interface {
|
- Create .onx directory structure
|
||||||
Init(path string) error
|
- Initialize empty oplog file
|
||||||
GetGitRepo() *git.Repository
|
- Create default workstreams.json
|
||||||
GetOnyxMetadata() *OnyxMetadata
|
- Create workspace pointer file
|
||||||
}
|
- Add .onx to .gitignore
|
||||||
|
|
||||||
type GitBackend interface {
|
|
||||||
CreateCommit(tree, parent, message string) (string, error)
|
|
||||||
CreateTree(entries []TreeEntry) (string, error)
|
|
||||||
UpdateRef(name, sha string) error
|
|
||||||
GetRef(name string) (string, error)
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
10. **Implement Repository struct** (`internal/core/repository.go`)
|
18. **Create CLI structure** (`cmd/onx/main.go`)
|
||||||
- Fields: gitRepo (*git.Repository), onyxPath (string), gitPath (string)
|
```go
|
||||||
- Methods: Open(), Close(), IsOnyxRepo()
|
func main() {
|
||||||
- Error handling for missing .git or .onx directories
|
rootCmd := &cobra.Command{
|
||||||
|
Use: "onx",
|
||||||
|
Short: "The iPhone of Version Control",
|
||||||
|
}
|
||||||
|
rootCmd.AddCommand(commands.InitCmd())
|
||||||
|
rootCmd.Execute()
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
11. **Implement Git object operations** (`internal/git/objects.go`)
|
### onx undo Command
|
||||||
- `CreateBlob(content []byte) (string, error)`
|
|
||||||
- `CreateTree(entries []TreeEntry) (string, error)`
|
19. **Implement undo logic** (`internal/commands/undo.go`)
|
||||||
- `CreateCommit(tree, parent, message, author string) (string, error)`
|
- Read last oplog entry
|
||||||
- `GetObject(sha string) (Object, error)`
|
- Restore all refs from state_before
|
||||||
|
- Update workspace pointer
|
||||||
|
- Mark entry as undone in oplog
|
||||||
|
- Perform git checkout to restore working directory
|
||||||
|
|
||||||
|
20. **Add undo tests** (`internal/commands/undo_test.go`)
|
||||||
|
- Test undo after init
|
||||||
|
- Test sequential undos
|
||||||
|
- Test undo with nothing to undo
|
||||||
|
|
||||||
12. **Create data models** (`internal/models/`)
|
|
||||||
- `oplog.go`: OplogEntry struct with serialization
|
|
||||||
- `workstream.go`: Workstream, WorkstreamCommit structs
|
|
||||||
- `workspace.go`: WorkspaceState struct
|
|
||||||
|
@ -1,79 +1,3 @@
|
|||||||
## Milestone 1: Action Log and onx init
|
|
||||||
|
|
||||||
### Action Log Implementation
|
|
||||||
|
|
||||||
13. **Create oplog binary format** (`internal/storage/oplog.go`)
|
|
||||||
```go
|
|
||||||
type OplogEntry struct {
|
|
||||||
ID uint64
|
|
||||||
ParentID uint64
|
|
||||||
Timestamp int64
|
|
||||||
Command string
|
|
||||||
StateBefore map[string]string
|
|
||||||
StateAfter map[string]string
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
14. **Implement oplog writer** (`internal/storage/oplog_writer.go`)
|
|
||||||
- `OpenOplog(path string) (*OplogWriter, error)`
|
|
||||||
- `AppendEntry(entry *OplogEntry) error`
|
|
||||||
- Use binary encoding (gob or protobuf)
|
|
||||||
- Implement file locking for concurrent access
|
|
||||||
|
|
||||||
15. **Implement oplog reader** (`internal/storage/oplog_reader.go`)
|
|
||||||
- `ReadLastEntry() (*OplogEntry, error)`
|
|
||||||
- `ReadEntry(id uint64) (*OplogEntry, error)`
|
|
||||||
- `GetUndoStack() ([]*OplogEntry, error)`
|
|
||||||
|
|
||||||
16. **Create transactional wrapper** (`internal/core/transaction.go`)
|
|
||||||
```go
|
|
||||||
func ExecuteWithTransaction(repo *Repository, cmd string,
|
|
||||||
fn func() error) error {
|
|
||||||
// 1. Capture state_before
|
|
||||||
// 2. Create oplog entry
|
|
||||||
// 3. Execute fn()
|
|
||||||
// 4. Capture state_after
|
|
||||||
// 5. Finalize oplog entry
|
|
||||||
// 6. Handle rollback on error
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### onx init Command
|
|
||||||
|
|
||||||
17. **Implement init command** (`internal/commands/init.go`)
|
|
||||||
- Create .git directory (via go-git)
|
|
||||||
- Create .onx directory structure
|
|
||||||
- Initialize empty oplog file
|
|
||||||
- Create default workstreams.json
|
|
||||||
- Create workspace pointer file
|
|
||||||
- Add .onx to .gitignore
|
|
||||||
|
|
||||||
18. **Create CLI structure** (`cmd/onx/main.go`)
|
|
||||||
```go
|
|
||||||
func main() {
|
|
||||||
rootCmd := &cobra.Command{
|
|
||||||
Use: "onx",
|
|
||||||
Short: "The iPhone of Version Control",
|
|
||||||
}
|
|
||||||
rootCmd.AddCommand(commands.InitCmd())
|
|
||||||
rootCmd.Execute()
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### onx undo Command
|
|
||||||
|
|
||||||
19. **Implement undo logic** (`internal/commands/undo.go`)
|
|
||||||
- Read last oplog entry
|
|
||||||
- Restore all refs from state_before
|
|
||||||
- Update workspace pointer
|
|
||||||
- Mark entry as undone in oplog
|
|
||||||
- Perform git checkout to restore working directory
|
|
||||||
|
|
||||||
20. **Add undo tests** (`internal/commands/undo_test.go`)
|
|
||||||
- Test undo after init
|
|
||||||
- Test sequential undos
|
|
||||||
- Test undo with nothing to undo
|
|
||||||
|
|
||||||
## Milestone 2: Transparent Versioning and onx save
|
## Milestone 2: Transparent Versioning and onx save
|
||||||
|
|
||||||
### Filesystem Daemon Implementation
|
### Filesystem Daemon Implementation
|
||||||
|
Reference in New Issue
Block a user