Add durable self-dev customization records#187
Open
aayu22809 wants to merge 4 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Introduces a first durable “self-dev customization record” slice so Jcode can persist user-local customizations (including metadata and patch provenance), expose them via selfdev tool actions, and incorporate active customizations into update/install reporting (including optional validation command execution with recorded outcomes).
Changes:
- Add versioned
SelfDevCustomizationRecordtypes plus build-support helpers to persist/list/disable records and append outcomes. - Add
selfdevactions to record/list/inspect/disable customizations and surface active customizations inselfdev status. - Integrate active customizations into update/install flows by recording “needs review” or running validation commands and storing pass/fail output.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
src/update.rs |
Records per-customization update outcomes and runs validation commands during update/install reporting. |
src/tool/selfdev/mod.rs |
Extends the selfdev tool schema/actions to include customization record operations. |
src/tool/selfdev/customization.rs |
Implements record/list/inspect/disable customization actions and compact-memory integration. |
src/tool/selfdev/status.rs |
Displays active customization records in selfdev status output. |
src/tool/selfdev/tests.rs |
Adds integration tests for recording and disabling customizations via the tool. |
crates/jcode-selfdev-types/src/lib.rs |
Defines the durable customization record schema (status, provenance, validation, outcomes). |
crates/jcode-selfdev-types/Cargo.toml |
Adds serde_json dev-dependency for schema tests. |
crates/jcode-build-support/src/customizations.rs |
Adds on-disk storage helpers for records/patches plus record ID sanitization and outcome appends. |
crates/jcode-build-support/src/source_state.rs |
Adds helper to build a patch including untracked files. |
crates/jcode-build-support/src/lib.rs |
Re-exports customization APIs and new patch helper. |
crates/jcode-build-support/src/tests.rs |
Adds round-trip, untracked patch, and outcome persistence tests. |
Cargo.lock |
Locks new dev-dependency resolution. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+976
to
+1012
| fn run_customization_validation_commands( | ||
| repo_dir: &Path, | ||
| commands: &[String], | ||
| ) -> (build::SelfDevCustomizationOutcomeStatus, String) { | ||
| let mut combined = String::new(); | ||
| for command in commands { | ||
| let output = if cfg!(windows) { | ||
| std::process::Command::new("cmd") | ||
| .args(["/C", command]) | ||
| .current_dir(repo_dir) | ||
| .output() | ||
| } else { | ||
| std::process::Command::new("sh") | ||
| .args(["-c", command]) | ||
| .current_dir(repo_dir) | ||
| .output() | ||
| }; | ||
|
|
||
| let output = match output { | ||
| Ok(output) => output, | ||
| Err(error) => { | ||
| return ( | ||
| build::SelfDevCustomizationOutcomeStatus::ValidationFailed, | ||
| truncate_chars( | ||
| &format!("Validation command `{command}` failed to start: {error}"), | ||
| CUSTOMIZATION_VALIDATION_OUTPUT_LIMIT, | ||
| ), | ||
| ); | ||
| } | ||
| }; | ||
|
|
||
| append_validation_output(&mut combined, command, &output); | ||
| if !output.status.success() { | ||
| return ( | ||
| build::SelfDevCustomizationOutcomeStatus::ValidationFailed, | ||
| truncate_chars(&combined, CUSTOMIZATION_VALIDATION_OUTPUT_LIMIT), | ||
| ); |
Comment on lines
+1022
to
+1044
| fn append_validation_output(combined: &mut String, command: &str, output: &std::process::Output) { | ||
| if !combined.is_empty() { | ||
| combined.push_str("\n\n"); | ||
| } | ||
| combined.push_str(&format!( | ||
| "Command: `{}`\nStatus: {}\n", | ||
| command, | ||
| output.status.code().map_or_else( | ||
| || "terminated by signal".to_string(), | ||
| |code| code.to_string() | ||
| ) | ||
| )); | ||
| let stdout = String::from_utf8_lossy(&output.stdout); | ||
| if !stdout.trim().is_empty() { | ||
| combined.push_str("Stdout:\n"); | ||
| combined.push_str(stdout.trim()); | ||
| combined.push('\n'); | ||
| } | ||
| let stderr = String::from_utf8_lossy(&output.stderr); | ||
| if !stderr.trim().is_empty() { | ||
| combined.push_str("Stderr:\n"); | ||
| combined.push_str(stderr.trim()); | ||
| combined.push('\n'); |
Comment on lines
+906
to
+907
| let Ok(active) = build::list_active_customization_records() else { | ||
| return; |
Comment on lines
+194
to
+196
| pub fn current_git_patch_with_untracked(repo_dir: &Path) -> Result<String> { | ||
| let mut patch = current_git_diff(repo_dir)?; | ||
| let untracked = git_output_bytes( |
| let mut clean = String::with_capacity(id.len()); | ||
| for ch in id.chars() { | ||
| if ch.is_ascii_alphanumeric() || matches!(ch, '-' | '_') { | ||
| clean.push(ch); |
Comment on lines
+57
to
+65
| record.id = sanitize_record_id(&record.id); | ||
| let now = Utc::now(); | ||
| record.updated_at = now; | ||
| if record.created_at > now { | ||
| record.created_at = now; | ||
| } | ||
|
|
||
| if let Some(patch) = patch.filter(|patch| !patch.trim().is_empty()) { | ||
| let patch_path = customization_patch_path(&record.id)?; |
| } | ||
|
|
||
| pub fn save_customization_record(record: &SelfDevCustomizationRecord) -> Result<()> { | ||
| storage::write_json(&customization_record_path(&record.id)?, record) |
| let diff = if Self::is_test_session() { | ||
| String::new() | ||
| } else { | ||
| build::current_git_patch_with_untracked(&repo_dir).unwrap_or_default() |
Comment on lines
+109
to
+111
| if let Some(validation_status) = record.validation.last_status.as_ref() { | ||
| status.push_str(&format!(" Last validation: {:?}\n", validation_status)); | ||
| } |
Author
|
Reviewed Copilot suggestions and pushed follow-up commit Accepted/addressed:
Validated with: cargo test -p jcode-build-support customization --lib
cargo test -p jcode-selfdev-types --lib
cargo test record_customization_creates_record_and_list_output --lib
cargo test disable_customization_removes_compact_memory_and_active_status --lib
cargo test test_record_customization_update_reports_validation_pass --lib
cargo test test_record_customization_update_reports_validation_failure_is_report_only --lib
cargo check |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds durable self-dev customization records so Jcode can persist, inspect, and report user-local adaptations across update/install flows.
This PR implements the first self-dev customization slice from #32 and addresses issues #35, #36, and #37:
SelfDevCustomizationRecordschema with stable IDs, timestamps, active/disabled state, base version metadata, provenance, rationale, validation commands, and update hints.selfdevtool actions for recording, listing, disabling, and inspecting active customizations.Fixes #35
Fixes #36
Fixes #37
Testing
Passed on the rebased branch:
Notes:
cargo checkandcargo buildpass with existing warnings.cargo test selfdev --librun hit two unrelated/flaky failures on macOS:cli::tui_launch::tests::spawn_selfdev_in_new_terminal_uses_handterm_exec_modedue to/private/varvs/vartemp path normalization.tool::selfdev::tests::build_dedupes_identical_reason_and_version_with_attached_watcherdue to a background task timeout.origin/master.Need help on this PR? Tag
@codesmithwith what you need.