orcaflex-model-sanitization

Sanitize OrcaFlex models by stripping client-identifiable references, converting binary .dat to YAML .yml, and organizing into the reference model library.

5 stars

Best use case

orcaflex-model-sanitization is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Sanitize OrcaFlex models by stripping client-identifiable references, converting binary .dat to YAML .yml, and organizing into the reference model library.

Teams using orcaflex-model-sanitization should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/model-sanitization/SKILL.md --create-dirs "https://raw.githubusercontent.com/vamseeachanta/workspace-hub/main/.agents/skills/engineering/marine-offshore/orcaflex/model-sanitization/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/model-sanitization/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How orcaflex-model-sanitization Compares

Feature / Agentorcaflex-model-sanitizationStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Sanitize OrcaFlex models by stripping client-identifiable references, converting binary .dat to YAML .yml, and organizing into the reference model library.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# OrcaFlex Model Sanitization Skill

## Description
Sanitize OrcaFlex models from client projects by stripping identifiable references (project names, vessel names, operator codes, user/machine metadata), converting binary `.dat` to YAML `.yml`, deduplicating, and organizing into the reference model library.

## When to Use
- Importing OrcaFlex models from external/client sources
- Converting `.dat` (binary) to `.yml` (YAML) format
- Stripping client-identifiable references before committing
- Organizing models into the `docs/modules/orcaflex/` library structure
- Deduplicating model collections (hash-based)

## Sanitization Pipeline

### Overview
```
Source .dat/.yml → Dedup → Convert → Sanitize Text → Strip Metadata → Organize → Legal Scan → Extract Spec
```

### Step 1: Inventory & Dedup
- Walk source directory for `.dat` and `.yml` files
- Compute SHA-256 hash for each file
- Skip files with identical content (keep first occurrence)
- Exclude: oversized files (>50MB), non-model files (CAD, reports, scripts)

### Step 2: Format Conversion (.dat → .yml)
```python
import OrcFxAPI
model = OrcFxAPI.Model(str(dat_path))
model.SaveData(str(output_yml_path))
```

**Gotchas:**
- `SaveData()` embeds `User:`, `Machine:`, `File:` metadata in YAML header
- `SaveData()` exports ALL properties including dormant ones
- Binary `.dat` files may reference external DLLs or data files
- Large models (>50MB) may timeout — skip and log

### Step 3: Text-Based Sanitization
Apply regex replacements using a mapping table:

```python
SANITIZATION_MAP = {
    "ClientProject": "generic_project_a",
    "VesselName": "installation_vessel_01",
    # ... sorted by key length descending to avoid partial matches
}

# Sort keys longest-first
sorted_keys = sorted(SANITIZATION_MAP.keys(), key=len, reverse=True)

text = Path(yml_file).read_text(encoding="utf-8", errors="replace")
for key in sorted_keys:
    replacement = SANITIZATION_MAP[key]
    text = text.replace(key, replacement)
```

**Critical: Sort by length descending** — prevents "Seven Arctic" from being partially matched by "Seven".

### Step 4: Strip OrcaFlex Metadata
Remove embedded user/machine/file path lines:
```python
import re
# Remove User/Machine/File header lines
text = re.sub(r"^User:.*$", "", text, flags=re.MULTILINE)
text = re.sub(r"^Machine:.*$", "", text, flags=re.MULTILINE)
text = re.sub(r"^File:.*$", "", text, flags=re.MULTILINE)
# Clean up resulting blank lines
text = re.sub(r"\n{3,}", "\n\n", text)
```

### Step 5: Organize into Library
Target structure:
```
docs/modules/orcaflex/<category>/
├── <subcategory>/
│   ├── monolithic/        # Sanitized original YAML
│   │   ├── model_SZ.yml
│   │   └── model_DZ.yml
│   └── spec.yml           # Extracted spec for modular builder
```

Categories: `jumper/`, `installation/`, `mooring/`, `training/`, `regional/`, `vessel_raos/`

### Step 6: Legal Scan Gate
```bash
bash scripts/legal/legal-sanity-scan.sh --repo=digitalmodel
# Must exit 0 before proceeding to spec extraction
```

### Step 7: Extract Spec
Only after legal scan passes:
```python
from digitalmodel.solvers.orcaflex.modular_generator.extractor import MonolithicExtractor
extractor = MonolithicExtractor(Path("monolithic/model.yml"))
spec_dict = extractor.extract()
```

## Sanitization Mapping Best Practices

### Pattern Categories
| Category | Examples | Replacement Convention |
|----------|----------|----------------------|
| Project names | Field names, codenames | `deepwater_field_a`, `shallow_field_b` |
| Vessel names | Installation vessels, rigs | `installation_vessel_01`, `fpso_01` |
| Operator names | Oil companies, contractors | `operator_a`, `contractor_b` |
| Location names | Pipeline routes, regions | `pipeline_route_a`, `region_b` |
| User/machine IDs | Hostnames, usernames | Remove entirely (empty string) |

### Rules
1. **Longest match first** — sort replacement keys by length descending
2. **Case variants** — include both original case and common variants (CamelCase, snake_case, lowercase)
3. **Empty replacements** — for user/machine IDs, replace with empty string and clean up artifacts
4. **Audit trail** — log every transformation to `sanitization_audit.json`

## Deny List Integration

The sanitization mapping should be mirrored in `.legal-deny-list.yaml`:
- Every key in `SANITIZATION_MAP` → pattern in deny list with `severity: block`
- The sanitization script itself is excluded from scanning

## Commands

### Run sanitization
```bash
uv run python scripts/sanitize_s7_models.py \
  --s7-root D:/workspace-hub/client-b/s7 \
  --output-root docs/modules/orcaflex \
  --dry-run  # Preview first
```

### Run without OrcFxAPI (.yml only)
```bash
uv run python scripts/sanitize_s7_models.py \
  --s7-root D:/workspace-hub/client-b/s7 \
  --output-root docs/modules/orcaflex \
  --skip-dat
```

### Verify sanitization
```bash
# Check no client references remain
grep -ri "ClientProject\|VesselName" docs/modules/orcaflex/

# Run legal scan
bash scripts/legal/legal-sanity-scan.sh --repo=digitalmodel
```

## Audit Output

The sanitization script generates `sanitization_audit.json`:
```json
{
  "timestamp": "2026-02-11T10:00:00",
  "source_root": "D:/workspace-hub/client-b/s7",
  "files_processed": 180,
  "files_skipped_dedup": 45,
  "files_skipped_excluded": 12,
  "files_failed": 3,
  "categories": {
    "jumper": 15,
    "installation": 80,
    "mooring": 10
  },
  "transformations": [
    {
      "source": "s7/ballymore/Jumper_Manifold to PLET/SZ.yml",
      "target": "docs/modules/orcaflex/jumper/manifold_to_plet/monolithic/SZ.yml",
      "hash": "sha256:abc123...",
      "replacements": ["Ballymore→deepwater_field_a", "Candies→installation_vessel_01"],
      "size_bytes": 245000
    }
  ]
}
```

## Related Skills
- `/legal-sanity-scan` — Legal compliance scanning
- `/orcaflex-file-conversion` — Format conversion (.dat ↔ .yml)
- `/orcaflex-monolithic-to-modular` — Monolithic → modular conversion
- `/orcaflex-jumper-analysis` — Jumper-specific modelling concepts
- `/orcaflex-model-generator` — Modular generation from spec.yml

Related Skills

OrcaFlex Specialist Skill

5
from vamseeachanta/workspace-hub

```yaml

orcaflex-reporting-fixture-proof-pattern

5
from vamseeachanta/workspace-hub

Build and extend fixture-backed OrcaFlex reporting proof paths in digitalmodel using stable metadata baselines, normalized HTML snapshots, and reusable reporting test helpers.

digitalmodel-worktree-test-execution-with-shared-venv

5
from vamseeachanta/workspace-hub

Run digitalmodel tests from isolated worktrees without uv editable-dependency failures by using the main repo's existing virtualenv and PYTHONPATH.

digitalmodel-orcawave-orcaflex-proof-workflows

5
from vamseeachanta/workspace-hub

Class-level digitalmodel OrcaWave/OrcaFlex readiness, semantic-proof, fixture-proof, and closeout workflows.

digitalmodel-code-explorer

5
from vamseeachanta/workspace-hub

Fast orientation guide for the digitalmodel codebase, with module lookup, source-to-test mapping, and targeted inspection patterns to avoid repeated bulk-reading of digitalmodel/src and tests.

orcawave-orcaflex-readiness-audit

5
from vamseeachanta/workspace-hub

Audit the real readiness of digitalmodel OrcaWave/OrcaFlex spec-driven workflows by reconciling workspace-hub issues, source/tests, semantic-equivalence boundaries, and wiki synthesis gaps.

digitalmodel-orcawave-orcaflex-workflow

5
from vamseeachanta/workspace-hub

Current-state workflow for navigating and extending digitalmodel OrcaWave/OrcaFlex capabilities across code, tests, issues, queue tooling, and licensed-machine boundaries.

orcawave-orcaflex-semantic-proof-wave-closeout

5
from vamseeachanta/workspace-hub

Close out an OrcaWave/OrcaFlex semantic-proof wave after a PR merges, split unrelated CI blockers, and seed the next semantic-proof issue wave without duplicating existing issues.

segment-anything-model

5
from vamseeachanta/workspace-hub

Foundation model for image segmentation with zero-shot transfer. Use when you need to segment any object in images using points, boxes, or masks as prompts, or automatically generate all object masks in an image.

orcawave-to-orcaflex

5
from vamseeachanta/workspace-hub

Integration specialist for converting OrcaWave diffraction results to OrcaFlex vessel types. Handles hydrodynamic database generation, RAO import, viscous damping addition, and coordinate system transformations.

orcaflex-yaml-gotchas

5
from vamseeachanta/workspace-hub

Production-proven OrcaFlex YAML traps and solutions covering dormant properties, boolean mismatches, section ordering, Pydantic integration, and section name aliases.

orcaflex-visualization

5
from vamseeachanta/workspace-hub

Generate visualizations from OrcaFlex and OrcaWave simulations using the shared OrcFxAPI — model views (SaveModelView), time series plots, range graphs, and interactive HTML reports. Covers both .dat/.sim (OrcaFlex) and .owd (OrcaWave) files via the same API surface.