jason810496 commented on code in PR #67161:
URL: https://github.com/apache/airflow/pull/67161#discussion_r3296433143


##########
task-sdk/src/airflow/sdk/coordinators/executable/coordinator.py:
##########
@@ -0,0 +1,324 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""Native executable coordinator that launches a binary subprocess for task 
execution."""
+
+from __future__ import annotations
+
+import os
+import pathlib
+import selectors
+import socket
+import struct
+import subprocess
+import time
+from typing import TYPE_CHECKING, Any, NamedTuple, cast
+
+import attrs
+import psutil
+import structlog
+import yaml
+
+from airflow.sdk.execution_time.coordinator import BaseCoordinator
+from airflow.sdk.execution_time.supervisor import ActivitySubprocess
+
+if TYPE_CHECKING:
+    from collections.abc import Sequence
+
+    from structlog.typing import FilteringBoundLogger
+    from typing_extensions import Self
+
+    from airflow.sdk.api.client import Client
+    from airflow.sdk.api.datamodels._generated import BundleInfo
+    from airflow.sdk.execution_time.workloads.task import TaskInstanceDTO
+
+log: FilteringBoundLogger = 
structlog.get_logger(logger_name="coordinators.executable")
+
+
+FOOTER_MAGIC = b"AFBNDL01"
+FOOTER_SIZE = 32
+FOOTER_VERSION = 1
+
+
+class _Footer(NamedTuple):
+    source_len: int
+    metadata_len: int
+    footer_ver: int
+
+
+def _read_footer(path: pathlib.Path) -> _Footer | None:

Review Comment:
   I will need to rewrite the footer metadata discovery if there isn't any 
objective base on 
https://github.com/apache/airflow/pull/67153#discussion_r3296414009 comment.



##########
task-sdk/docs/bundle-spec.rst:
##########
@@ -0,0 +1,252 @@
+ .. Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+ ..   http://www.apache.org/licenses/LICENSE-2.0
+
+ .. Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+Bundle Spec Format
+==================
+
+This document specifies the on-disk format of a build artifact produced by an
+Airflow native-executable SDK (Go, Rust, C++, Zig, ...) and consumed by
+:class:`~airflow.sdk.coordinators.executable.ExecutableCoordinator`
+at deployment time.
+
+The goal is a single, language-agnostic *bundle* shape so that scheduler,
+worker, and UI behave identically regardless of which compiled SDK produced
+the DAG.
+
+Format version: ``1.0``.
+
+Container
+---------
+
+A bundle is **the compiled executable itself, with a fixed-format footer
+appended after the binary's normal end-of-file**. The executable remains
+directly runnable; the footer is data that follows the last byte the OS
+loader cares about and is invisible to ``exec()``. There is no enclosing
+archive.
+
+A bundle file therefore has three regions, in order from offset 0:
+
+1. The native executable (ELF / Mach-O / PE), including any code-signing
+   structures the platform appends.
+2. The primary DAG source file, embedded verbatim (UTF-8). MAY have length 0.
+3. The build-time manifest (``airflow-metadata.yaml`` content, UTF-8).
+
+The file ends with a fixed 32-byte trailer that locates regions (2) and (3)
+and identifies the file as a bundle. See :ref:`bundle-trailer-layout`.
+
+Filenames follow OS conventions for executables: no extension on Linux/macOS,
+``.exe`` on Windows. The scanner identifies bundles by the trailer's magic,
+not by the filename.
+
+.. _bundle-trailer-layout:
+
+Trailer Layout
+--------------
+
+The last 32 bytes of a conforming bundle are the trailer. All multi-byte
+integers are little-endian.
+
+::
+
+    bytes  0..3   source_len    uint32   length of the source region in bytes
+    bytes  4..7   metadata_len  uint32   length of the metadata region in bytes
+    bytes  8..11  footer_ver    uint32   currently 1
+    bytes 12..23  reserved      12 bytes, MUST be zero
+    bytes 24..31  magic         8 bytes ASCII "AFBNDL01"

Review Comment:
   So does the bundle spec as well.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to