Skip to content

Comments

Fix file descriptor compilation error in zpmod module#60

Closed
Copilot wants to merge 34 commits intomainfrom
copilot/fix-31
Closed

Fix file descriptor compilation error in zpmod module#60
Copilot wants to merge 34 commits intomainfrom
copilot/fix-31

Conversation

Copy link

Copilot AI commented Jul 19, 2025

This pull request introduces significant updates to the repository, including the removal of outdated files and content, the addition of new documentation and templates, and improvements to the CI/CD pipeline. The changes aim to streamline development workflows, enhance documentation consistency, and optimize automation processes.

Removal of outdated files and content:

Addition of new documentation and templates:

CI/CD pipeline enhancements:

  • .github/workflows/ci.yml: Added a new CI/CD workflow leveraging reusable GitHub Actions from the Z-Shell organization for tasks like setting up the development environment, building, and testing the zpmod module. This improves automation and reduces redundancy.

…kip FD paths

Co-authored-by: ss-o <59910950+ss-o@users.noreply.github.com>
Copilot AI changed the title [WIP] [bug]: (eval):ZIModule_:1: can't write zwc file: /proc/self/fd/15.zwc Fix file descriptor compilation error in zpmod module Jul 19, 2025
Copilot finished work on behalf of ss-o July 19, 2025 02:00
Copilot AI requested a review from ss-o July 19, 2025 02:00
@ss-o ss-o marked this pull request as ready for review July 19, 2025 04:19
@ss-o ss-o requested a review from Copilot July 19, 2025 04:20

This comment was marked as outdated.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Sall <59910950+ss-o@users.noreply.github.com>
@ss-o ss-o requested a review from Copilot July 19, 2025 04:22

This comment was marked as outdated.

ss-o and others added 2 commits July 19, 2025 05:39
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Sall <59910950+ss-o@users.noreply.github.com>
…access` calls

Signed-off-by: Salvydas Lukosius <ss-o@users.noreply.github.com>
@ss-o ss-o requested a review from Copilot July 19, 2025 06:15

This comment was marked as outdated.

ss-o and others added 2 commits July 19, 2025 07:17
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Sall <59910950+ss-o@users.noreply.github.com>
- Updated README.md to clarify module features and installation instructions.
- Added Scripts/README.md to document available utility scripts.
- Introduced clean.sh for removing build artifacts.
- Implemented copy_from_zsh_src.zsh for syncing with Zsh source.
- Enhanced install.sh to detect Zi and guide users accordingly.
- Modified zp_should_skip_compilation to accept a file stat struct.
- Created release workflow for automated GitHub releases.
- Updated .gitignore to include additional binary files.
- Removed obsolete .vscode/settings.json.

Signed-off-by: Salvydas Lukosius <ss-o@users.noreply.github.com>
Signed-off-by: Salvydas Lukosius <ss-o@users.noreply.github.com>
@ss-o ss-o requested a review from Copilot July 19, 2025 10:23

This comment was marked as outdated.

ss-o and others added 2 commits July 19, 2025 11:26
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Sall <59910950+ss-o@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Sall <59910950+ss-o@users.noreply.github.com>
@ss-o ss-o added bug 🐞 Inconsistencies or issues which will cause a problem for users or implementors. maintenance 📈 Generic maintenance tasks. labels Jul 19, 2025
…in permissions

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Sall <59910950+ss-o@users.noreply.github.com>
ss-o added 4 commits July 19, 2025 18:38
Signed-off-by: Salvydas Lukosius <ss-o@users.noreply.github.com>
- Consolidate all AI instruction files into standardized .github/copilot-instructions.md
- Remove redundant .github/copilot/ and .github/instructions/ directories
- Improve shellcheck compliance in Scripts/advanced-install.sh and Scripts/update-readme.sh
- Follow VS Code standard for GitHub Copilot instructions location
- Add comprehensive project metadata and repository structure
- Improve formatting and organization for better readability
- Include detailed architecture and development workflow guidance
- Add specific examples and error handling patterns
- Enhance consistency guidelines for z-shell organization
- Follow VS Code standards for GitHub Copilot instruction files
- Fix all lint issues and ensure clean formatting
…onventions from Copilot instructions

Signed-off-by: Salvydas Lukosius <ss-o@users.noreply.github.com>
@ss-o ss-o force-pushed the copilot/fix-31 branch from 327938b to 512b422 Compare July 19, 2025 19:03
ss-o added 4 commits July 19, 2025 20:20
- Reorganize docs/ directory following industry-standard Divio documentation system
- Create 4 main categories: tutorials/, how-to/, reference/, explanation/
- Move existing documentation files to appropriate categories:
  - CONTRIBUTING.md → how-to/contributing.md
  - index.md → comprehensive project overview
- Add README.md files for each category with clear guidelines
- Remove empty files (BEST_PRACTICES.md, MODULE_FUNCTIONALITY.md)
- Implement consistent structure for long-term maintainability

This follows the Divio documentation system:
- Tutorials: Learning-oriented, step-by-step guides
- How-to: Problem-oriented, practical instructions
- Reference: Information-oriented, technical specifications
- Explanation: Understanding-oriented, background knowledge
- Remove broken sync-docs.yml workflow that failed due to missing extract_section function
- Remove overly complex advanced-ci-cd.yml workflow (redundant with existing test workflows)
- Fix README.md documentation links to match new reorganized docs structure
- Fix release.yml workflow to point to correct README path
- Remove broken Scripts/update-readme.sh script that had undefined functions

Simplified workflow structure:
- test-linux.yml ✅ Core Linux testing
- test-macos.yml ✅ Core macOS testing
- release.yml ✅ Release automation (fixed)

This resolves workflow failures and maintains only essential, working CI/CD pipelines.
…ines

- Add comprehensive documentation strategy section explaining Divio documentation system
- Define four documentation categories: tutorials/, how-to/, reference/, explanation/
- Include specific guidelines for adding and maintaining documentation
- Emphasize consistency across all Z-Shell organization repositories
- Update contribution guidelines to reference new documentation structure
- Remove reference to deleted Scripts/update-readme.sh script
- Add dedicated Documentation Maintenance section in Best Practices

This ensures the implemented docs/ structure is maintained consistently across all changes and repositories in the organization.
- Create dedicated CodeQL workflow to handle security scanning
- Use --with-tcsetpgrp configure option to avoid TTY requirement in CI
- Disable unnecessary dependencies (GDBM, PCRE) for faster builds
- Set appropriate timeouts and permissions for security analysis
- Schedule weekly scans for continuous security monitoring

This resolves the 'configure: error: no controlling tty' issue by using
CI-friendly configure options while maintaining full code analysis coverage.

Alternative to GitHub's default CodeQL setup which fails due to TTY requirements.
@github-advanced-security
Copy link
Contributor

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

ss-o added 8 commits July 19, 2025 21:05
- Expand Linux test workflow with complete feature coverage:
  • Source-study report generation (basic and list modes)
  • Path cache management and clearing operations
  • Compilation configuration testing (enable/disable/batch modes)
  • Automatic script compilation and .zwc generation
  • Performance tracking and timing analysis
  • Error handling and edge case validation
  • Help command verification

- Enhance macOS test workflow with platform-specific testing:
  • macOS compatibility verification for all core features
  • Platform-specific test scripts and compilation
  • Cross-platform performance validation

- Add comprehensive test file creation for realistic scenarios
- Include detailed verification steps and error reporting
- Test all major zpmod builtin commands and functionality
- Ensure proper module loading and cleanup

These workflows now properly test the implemented features including:
automatic compilation, performance tracking, path caching, and
configuration management that were previously untested.
- Fix corrupted string in Scripts/advanced-install.sh line 493
- Configure shellcheck to ignore copy_from_zsh_src.zsh (not supported by shellcheck)
- Update both test-linux.yml and test-macos.yml workflows
- Ensure all shell scripts pass shellcheck validation

Resolves workflow failures caused by:
1. Malformed variable reference in advanced-install.sh
2. Shellcheck attempting to parse Zsh script (not supported)
…rrect location

- Move ORGANIZATION_ACTIONS_PLAN.md from workspace root to docs/explanation/
- Rename to github-actions-strategy.md following kebab-case naming convention
- Update docs/explanation/README.md to include the new file
- Update docs/index.md to maintain discoverability

This follows the Divio documentation system correctly:
- Organization strategy is explanation-oriented (understanding background)
- Placed in docs/explanation/ directory as specified in Copilot instructions
- Properly integrated with documentation navigation

Fixes: Incorrectly placing documentation outside the established structure
…emove obsolete files

Signed-off-by: Salvydas Lukosius <ss-o@users.noreply.github.com>
Signed-off-by: Salvydas Lukosius <ss-o@users.noreply.github.com>
…to 0644; simplify memory management in zp_lazy_loader_destroy and zp_lazy_loader_register functions.

Signed-off-by: Salvydas Lukosius <ss-o@users.noreply.github.com>
…it flags and avoid CodeQL security warning

Signed-off-by: Salvydas Lukosius <ss-o@users.noreply.github.com>
@ss-o ss-o requested a review from Copilot July 20, 2025 00:21
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements comprehensive documentation, infrastructure improvements, and new advanced features for the zpmod module, transforming it from a basic script compilation tool into a feature-rich performance optimization module with proper documentation and CI/CD infrastructure.

  • Implements comprehensive documentation following the Divio documentation system with tutorials, how-to guides, reference materials, and explanations
  • Adds new advanced features including path caching, compilation optimization, and lazy loading systems
  • Establishes proper CI/CD infrastructure with GitHub Actions workflows for testing, security analysis, and automated releases

Reviewed Changes

Copilot reviewed 55 out of 57 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
docs/ Complete documentation restructure following Divio system with tutorials, how-to guides, reference docs, and explanations
Src/zi/zpmod.c Major module enhancement with new advanced features, improved error handling, and integration of new subsystems
Src/zi/*.c New modular components for path caching, compilation configuration, and lazy loading
.github/workflows/ New CI/CD infrastructure with comprehensive testing, security analysis, and release automation
Scripts/ Enhanced build and installation scripts with advanced options and better error handling

Src/exec.c Outdated
Comment on lines 2219 to 2223
O_WRONLY | O_CREAT | O_TRUNC | O_NOCTTY, 0644);

/* If not clobbering, attempt to create file exclusively. */
if ((fd = open(ufname,
O_WRONLY | O_CREAT | O_EXCL | O_NOCTTY, 0666)) >= 0)
O_WRONLY | O_CREAT | O_EXCL | O_NOCTTY, 0644)) >= 0)
Copy link

Copilot AI Jul 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File permissions changed from 0666 to 0644, which is more secure but may break existing functionality that expects group/other write permissions. Consider if this change is intentional and document the security rationale.

Copilot uses AI. Check for mistakes.
Src/zi/zpmod.c Outdated
zwarn("Unknown option: %s", zp_options[i].name);
}
int i, optno;
for (i = 0; i < sizeof(zp_options) / sizeof(struct zp_option_name) - 10 - 1; ++i)
Copy link

Copilot AI Jul 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magic numbers -10 and -1 in array size calculation make the code fragile. Consider using named constants or calculating the actual array bounds dynamically to prevent buffer overflows if the array structure changes.

Suggested change
for (i = 0; i < sizeof(zp_options) / sizeof(struct zp_option_name) - 10 - 1; ++i)
for (i = 0; i < sizeof(zp_options) / sizeof(struct zp_option_name) - ZP_OPTIONS_OFFSET - ZP_OPTIONS_END_PADDING; ++i)

Copilot uses AI. Check for mistakes.
}

printed = snprintf(NULL, 0, "%4.0lf ms %s\n", node->event.duration,
printed = fprintf(null_fle, "%4.0lf ms %s\n", node->event.duration,
Copy link

Copilot AI Jul 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using fprintf to /dev/null just to calculate string length is inefficient. Consider using snprintf with NULL buffer or strlen-based calculation instead of opening /dev/null for this purpose.

Suggested change
printed = fprintf(null_fle, "%4.0lf ms %s\n", node->event.duration,
printed = snprintf(NULL, 0, "%4.0lf ms %s\n", node->event.duration,

Copilot uses AI. Check for mistakes.
/**/
static int
zp_append_report(const char *nam, const char *target, UNUSED(int target_len), const char *body, int body_len)
zp_append_report(const char *nam, const char *target, int target_len, const char *body, int body_len)
Copy link

Copilot AI Jul 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameter target_len is marked as UNUSED in the original function signature but now being used. Remove the UNUSED annotation or verify the parameter is actually needed and used correctly.

Suggested change
zp_append_report(const char *nam, const char *target, int target_len, const char *body, int body_len)
zp_append_report(const char *nam, const char *target, const char *body, int body_len)

Copilot uses AI. Check for mistakes.

/* Check file size if it's not too large */
struct stat st;
if (stat(file, &st) == 0 && S_ISREG(st.st_mode)) {
Copy link

Copilot AI Jul 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function calls stat() on every file check, but the module already has a path cache system. Consider using zp_path_cache_stat() instead to leverage the existing caching infrastructure.

Copilot uses AI. Check for mistakes.

get_latest_version() {
log "DEBUG" "Fetching latest version information"
curl -s "${RELEASES_URL}/latest" | grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/' || echo "unknown"
Copy link

Copilot AI Jul 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The version detection command uses a fragile parsing approach that could fail silently. Consider using a more robust JSON parsing method or add better error handling when the API response format changes.

Copilot uses AI. Check for mistakes.
ss-o added 3 commits July 20, 2025 04:47
- Removed legacy files and configurations: .cvsignore, .distfiles, and .preconfig from various directories.
- Updated .gitignore to exclude unnecessary files and legacy configurations.
- Modified configuration file paths to align with new structure: moved from ~/.config/zpmod to ~/.config/zi.
- Enhanced security by adjusting file creation permissions to respect user umask settings, preventing world-writable files.
- Added new documentation on security improvements and usage of configuration helpers.
- Introduced new helper functions for performance analysis and troubleshooting in the configuration file.
- Updated README and tutorial documents to reflect changes in configuration and new helper functions.
- Improved code quality by removing magic numbers and ensuring safe buffer usage in the source code.

Signed-off-by: Salvydas Lukosius <ss-o@users.noreply.github.com>
- Introduced `Scripts/maintenance.sh` for comprehensive workspace maintenance tasks including health checks, code linting, documentation updates, version consistency checks, and security scans.
- Implemented commands for deep cleaning build artifacts and validating configuration files.
- Integrated trunk.io code quality tools for automated checks.

refactor: Remove obsolete configuration files

- Deleted unused `.epro` and `.pro` files from `Src/zi` directory to clean up the project structure.

feat: Enhance version management in zpmod

- Added version information constants in `Src/zi/zpmod.c` for better version tracking.
- Implemented a new command to display the current version of the zpmod module.

docs: Update documentation for clarity and completeness

- Revised `docs/explanation/README.md` to provide a clearer overview of available explanations.
- Created `docs/explanation/versioning-architecture.md` detailing the independent versioning system for zpmod.
- Added `docs/how-to/branching-and-tagging-guidelines.md` to outline version management and release processes.
- Updated `docs/index.md` to include new documentation links for versioning and branching guidelines.

Signed-off-by: Salvydas Lukosius <ss-o@users.noreply.github.com>
…ance improvements; add comprehensive quality scripts and update documentation

Signed-off-by: Salvydas Lukosius <ss-o@users.noreply.github.com>
@ss-o ss-o closed this Jul 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🐞 Inconsistencies or issues which will cause a problem for users or implementors. maintenance 📈 Generic maintenance tasks.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants