Skip to content

Commit 2a7656d

Browse files
noahgiftclaude
andcommitted
docs: Update spec with implementation status and add book chapter (Refs DEPYLER-O1MAP-001)
- Add Appendix B: Implementation Status (completed vs remaining) - Add Appendix C: Changelog with v1.1.0 release notes - Add module-mapping.md to TDD book - Update SUMMARY.md with new chapter link 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent c658d3f commit 2a7656d

File tree

3 files changed

+102
-4
lines changed

3 files changed

+102
-4
lines changed

docs/specifications/o-1-lookup-lib-mapping-rust-python-spec.md

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,40 @@ String interning (future) 12.1 KB 4.1 KB
582582

583583
---
584584

585-
## Appendix B: Changelog
585+
## Appendix B: Implementation Status
586+
587+
### Completed (v1.1.0)
588+
589+
| Component | File | Status |
590+
|-----------|------|--------|
591+
| O(1) HashMap Lookup | `module_mapper.rs` | ✅ Production |
592+
| 35+ Module Mappings | `module_mapper.rs` | ✅ Production |
593+
| Batuta Stack (numpy→trueno, sklearn→aprender) | `module_mapper.rs` | ✅ Production |
594+
| Typeshed Ingestion Parser | `typeshed_ingest.rs` | ✅ Complete (8 tests) |
595+
| Multiline .pyi Parsing | `typeshed_ingest.rs` | ✅ Complete |
596+
| Semantic Bridge Configs | `typeshed_ingest.rs` | ✅ Complete |
597+
| Specification Document | This file | ✅ Complete |
598+
599+
### Remaining Work (Future)
600+
601+
| Component | Priority | Effort | Notes |
602+
|-----------|----------|--------|-------|
603+
| PHF Compile-Time Migration | P1 | Medium | Replace HashMap with `phf` crate |
604+
| Full Typeshed Corpus Integration | P1 | Medium | CI pipeline to ingest all stdlib stubs |
605+
| Semantic Equivalence Test Suite | P2 | High | Golden tests for all mappings |
606+
| Performance Benchmarks | P2 | Low | Measure actual lookup times |
607+
| Property-Based Tests | P2 | Medium | QuickCheck/Proptest for mappings |
608+
| depyler.toml Config Support | P3 | Low | User-defined mapping overrides |
609+
610+
---
611+
612+
## Appendix C: Changelog
613+
614+
### v1.1.0 (2025-12-07)
615+
- **IMPLEMENTED**: `typeshed_ingest.rs` - .pyi stub parser for auto-mapping
616+
- Added Section 5: Automation Strategy (Typeshed Ingestion)
617+
- Added Appendix B: Implementation Status tracking
618+
- 8 passing tests for json, math, os, and unknown module ingestion
586619

587620
### v1.0.0 (2025-12-07)
588621
- Initial specification based on `module_mapper.rs` implementation
@@ -591,6 +624,3 @@ String interning (future) 12.1 KB 4.1 KB
591624
- Established semantic equivalence validation contracts
592625
- Added Toyota Way design principles alignment
593626
- Included 12 peer-reviewed citations
594-
595-
### v1.1.0 (2025-12-07)
596-
- Added Section 5: Automation Strategy (Typeshed Ingestion) to eliminate manual mapping bottleneck

tdd-book/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,4 @@
7171
- [Hunt Mode: Automated Calibration](./hunt-mode.md)
7272
- [Corpus Report: Scientific Analysis](./corpus-report.md)
7373
- [CITL Corpus Extraction](./citl-corpus-extraction.md)
74+
- [O(1) Module Mapping](./module-mapping.md)

tdd-book/src/module-mapping.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# O(1) Module Mapping
2+
3+
This document provides an overview of depyler's module mapping system, which translates Python standard library and third-party modules to their Rust equivalents.
4+
5+
## Architecture
6+
7+
Depyler uses an O(1) amortized lookup HashMap to map Python modules to Rust crates:
8+
9+
```rust
10+
// Core lookup in module_mapper.rs
11+
pub fn get_mapping(&self, module_name: &str) -> Option<&ModuleMapping> {
12+
self.module_map.get(module_name) // O(1) amortized
13+
}
14+
```
15+
16+
## Supported Modules
17+
18+
| Python Module | Rust Crate | Priority |
19+
|---------------|------------|----------|
20+
| `argparse` | `clap` | P0 |
21+
| `json` | `serde_json` | P0 |
22+
| `numpy` | `trueno` | P0 |
23+
| `sklearn.*` | `aprender::*` | P0 |
24+
| `re` | `regex` | P0 |
25+
| `datetime` | `chrono` | P1 |
26+
| `random` | `rand` | P1 |
27+
28+
See the full mapping table in the [specification](../docs/specifications/o-1-lookup-lib-mapping-rust-python-spec.md).
29+
30+
## Typeshed Ingestion
31+
32+
To eliminate manual mapping effort, depyler can auto-generate mappings from Python's typeshed `.pyi` stub files:
33+
34+
```rust
35+
use depyler_core::typeshed_ingest::parse_pyi;
36+
37+
let json_pyi = std::fs::read_to_string("typeshed/stdlib/json.pyi")?;
38+
let mapping = parse_pyi(&json_pyi, "json");
39+
// mapping.item_map contains: loads→from_str, dumps→to_string, etc.
40+
```
41+
42+
## Specification
43+
44+
Full specification: [DEPYLER-O1MAP-001](../docs/specifications/o-1-lookup-lib-mapping-rust-python-spec.md)
45+
46+
### Implementation Status
47+
48+
| Component | Status |
49+
|-----------|--------|
50+
| HashMap O(1) Lookup | ✅ Production |
51+
| 35+ Module Mappings | ✅ Production |
52+
| Typeshed Parser | ✅ Complete |
53+
| PHF Optimization | ⏳ Future |
54+
55+
## Usage
56+
57+
```rust
58+
use depyler_core::module_mapper::ModuleMapper;
59+
60+
let mapper = ModuleMapper::new();
61+
62+
// Get mapping for a Python module
63+
if let Some(mapping) = mapper.get_mapping("json") {
64+
println!("Rust crate: {}", mapping.rust_path); // "serde_json"
65+
println!("External: {}", mapping.is_external); // true
66+
}
67+
```

0 commit comments

Comments
 (0)